-
Notifications
You must be signed in to change notification settings - Fork 232
Fix #1684, Add functional tests for cFE SB Message ID APIs #2304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thnkslprpt
wants to merge
1
commit into
nasa:main
Choose a base branch
from
thnkslprpt:fix-1684-add-functional-tests-for-SB-MsgId-APIs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /************************************************************************ | ||
| * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” | ||
| * | ||
| * Copyright (c) 2020 United States Government as represented by the | ||
| * Administrator of the National Aeronautics and Space Administration. | ||
| * All Rights Reserved. | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| * not use this file except in compliance with the License. You may obtain | ||
| * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| ************************************************************************/ | ||
|
|
||
| /** | ||
| * \file | ||
| * Functional test of the Software Bus Message ID APIs | ||
| */ | ||
|
|
||
| /* | ||
| * Includes | ||
| */ | ||
| #include "cfe_test.h" | ||
|
|
||
| void TestCheckIfValidMsgId(void) | ||
| { | ||
| UtPrintf("Testing: CFE_SB_IsValidMsgId"); | ||
| bool Result; | ||
| CFE_SB_MsgId_t ValidMsgId = CFE_SB_ValueToMsgId(1); | ||
| CFE_SB_MsgId_t highestValidMsgId = CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID); | ||
| CFE_SB_MsgId_t TooHighMsgId = CFE_SB_ValueToMsgId(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1); | ||
|
|
||
| /* Test for true result with a valid MsgId */ | ||
| Result = CFE_SB_IsValidMsgId(ValidMsgId); | ||
| UtAssert_True(Result == true, "Result == true"); | ||
|
|
||
| /* Test for false result with an invalid MsgId (utilizing CFE_SB_INVALID_MSG_ID) */ | ||
| Result = CFE_SB_IsValidMsgId(CFE_SB_INVALID_MSG_ID); | ||
| UtAssert_True(Result == false, "Result == false"); | ||
|
|
||
| /* Test for true result with the highest valid MsgId (as defined by CFE_PLATFORM_SB_HIGHEST_VALID_MSGID) */ | ||
| Result = CFE_SB_IsValidMsgId(highestValidMsgId); | ||
| UtAssert_True(Result == true, "Result == true"); | ||
|
|
||
| /* | ||
| * Test for false result with a MsgId that is too high (i.e. above the value | ||
| * set for CFE_PLATFORM_SB_HIGHEST_VALID_MSGID in the platform config). | ||
| */ | ||
| Result = CFE_SB_IsValidMsgId(TooHighMsgId); | ||
| UtAssert_True(Result == false, "Result == false"); | ||
| } | ||
|
|
||
| void TestCheckIfMsgIdEqual(void) | ||
Check noticeCode scanning / CodeQL Long function without assertion
All functions of more than 10 lines should have at least one assertion.
|
||
| { | ||
| UtPrintf("Testing: CFE_SB_MsgId_Equal"); | ||
| bool Result; | ||
| CFE_SB_MsgId_t MsgId1 = CFE_SB_ValueToMsgId(1); | ||
| CFE_SB_MsgId_t MsgId2 = CFE_SB_ValueToMsgId(1); | ||
| CFE_SB_MsgId_t MsgId3 = CFE_SB_ValueToMsgId(2); | ||
|
|
||
| /* Test for true result with equal MsgId's */ | ||
| Result = CFE_SB_MsgId_Equal(MsgId1, MsgId2); | ||
| UtAssert_True(Result == true, "Result == true"); | ||
|
|
||
| /* Test for false result with unequal MsgId's */ | ||
| Result = CFE_SB_MsgId_Equal(MsgId2, MsgId3); | ||
| UtAssert_True(Result == false, "Result == false"); | ||
| } | ||
|
|
||
| void TestConvertValueToMsgAndBack(void) | ||
| { | ||
| UtPrintf("Testing: CFE_SB_ValueToMsgId, CFE_SB_MsgIdToValue"); | ||
| uint32 Value = 10; | ||
| CFE_SB_MsgId_t MsgIdResult; | ||
| CFE_SB_MsgId_Atom_t ValueResult; | ||
|
|
||
| /* Test integer value -> MsgId -> integer value */ | ||
| MsgIdResult = CFE_SB_ValueToMsgId(Value); | ||
| ValueResult = CFE_SB_MsgIdToValue(MsgIdResult); | ||
| UtAssert_INT32_EQ(ValueResult, Value); | ||
| } | ||
|
|
||
| void SBMsgIdTestSetup(void) | ||
| { | ||
| UtTest_Add(TestCheckIfValidMsgId, NULL, NULL, "Test Check if a MsgId is valid"); | ||
| UtTest_Add(TestCheckIfMsgIdEqual, NULL, NULL, "Test Check if two MsgId's are equal"); | ||
| UtTest_Add(TestConvertValueToMsgAndBack, NULL, NULL, "Test Convert a value to MsgId and back"); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Long function without assertion