Skip to content

Commit

Permalink
Fix nasa#1684, Add functional tests for cFE SB Message ID APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Mar 23, 2024
1 parent ed1faf4 commit 37b1b16
Show file tree
Hide file tree
Showing 11 changed files with 109 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
jobs:
codeql:
uses: nasa/cFS/.github/workflows/codeql-reusable.yml@main
with:
with:
component-path: cfe
make: make -j8
test: true
2 changes: 1 addition & 1 deletion cmake/sample_defs/eds/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
</Package>

<Package name="CFE_FS" shortDescription="File Services Configuration">
<Define name="FILE_CONTENT_ID" value="0x63464531" shortDescription="Magic Number for cFE compliant files (= cFE1)" />
<Define name="FILE_CONTENT_ID" value="0x63464531" shortDescription="Magic Number for cFE-compliant files (= cFE1)" />
<Define name="HDR_DESC_MAX_LEN" value="32"/>
</Package>

Expand Down
14 changes: 7 additions & 7 deletions cmake/sample_defs/example_mission_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
*
* This header file contains the mission configuration parameters and
* typedefs with mission scope.
*
*
* This provides values for configurable items that affect
* the interface(s) of this module. This includes the CMD/TLM message
* interface, tables definitions, and any other data products that
* serve to exchange information with other entities.
*
*
* @note It is no longer necessary to provide this file directly in the defs
* directory, but if present, this file is still supported/usable for backward
* directory, but if present, this file is still supported/usable for backward
* compatibility. To use this file, is should be called "cfe_mission_cfg.h".
*
*
* Going forward, more fine-grained (module/purposes-specific) header files are
* included with each submodule. These may be overridden as necessary, but only
* if a definition within that file needs to be changed from the default. This
* approach will reduce the amount of duplicate/cloned definitions and better
* approach will reduce the amount of duplicate/cloned definitions and better
* support alternative build configurations in the future.
*
*
* Note that if this file is present, the fine-grained header files noted above
* will _not_ be used.
*/
Expand Down Expand Up @@ -310,7 +310,7 @@

#define CFE_FS_HDR_DESC_MAX_LEN 32 /**< \brief Max length of description field in a standard cFE File Header */

#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE compliant files (= 'cFE1') */
#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE-compliant files (= 'cFE1') */


/******************************************************************************
Expand Down
4 changes: 2 additions & 2 deletions docs/cFE Application Developers Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -3224,7 +3224,7 @@ typedef struct

The ContentType element is a magic number that identifies this file as
conforming to the cFE standard header type. At the release of this
document, the magic number on all cFE compliant files is 0x63464531
document, the magic number on all cFE-compliant files is 0x63464531
which appears as 'cFE1' when seen in ASCII.

The SubType is an indication of the contents/format of the file. There
Expand All @@ -3241,7 +3241,7 @@ to determine the version of the header type as well as where the user
data is relative to the beginning of the file.

The SpacecraftID, ProcessorID and ApplicationID are all automatically
filled by cFE File Services routines when creating a cFE compliant file.
filled by cFE File Services routines when creating a cFE-compliant file.
These fields help identify where and how the file was created.

The TimeSeconds and TimeSubSeconds elements contain the Spacecraft Time
Expand Down
2 changes: 1 addition & 1 deletion docs/src/cfe_sb.dox
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@

The Pipe IDs are specific to a particular processor (that is, the same ID number
may refer to a different pipe on each processor). The pipe information for all
pipes that have been created, may be requested at anytime by sending the
pipes that have been created, may be requested at any time by sending the
\link #CFE_SB_WRITE_PIPE_INFO_CC 'Write Pipe Info' SB command \endlink. The software
bus also provides a set of figures regarding capacity, current utilization and high
water marks relevant to pipes. This information may be requested by sending the
Expand Down
3 changes: 2 additions & 1 deletion modules/cfe_testcase/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ add_cfe_app(cfe_testcase
src/evs_send_test.c
src/fs_header_test.c
src/fs_util_test.c
src/message_id_test.c
src/msg_api_test.c
src/msg_msg_id_test.c
src/resource_id_misc_test.c
src/sb_msg_id_test.c
src/sb_performance_test.c
src/sb_pipe_mang_test.c
src/sb_sendrecv_test.c
Expand Down
1 change: 1 addition & 0 deletions modules/cfe_testcase/src/cfe_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ void CFE_TestMain(void)
MessageIdTestSetup();
MsgApiTestSetup();
ResourceIdMiscTestSetup();
SBMsgIdTestSetup();
SBPipeMangSetup();
SBSendRecvTestSetup();
SBSubscriptionTestSetup();
Expand Down
1 change: 1 addition & 0 deletions modules/cfe_testcase/src/cfe_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ void FSUtilTestSetup(void);
void MessageIdTestSetup(void);
void MsgApiTestSetup(void);
void ResourceIdMiscTestSetup(void);
void SBMsgIdTestSetup(void);
void SBPerformanceTestSetup(void);
void SBPipeMangSetup(void);
void SBSendRecvTestSetup(void);
Expand Down
File renamed without changes.
92 changes: 92 additions & 0 deletions modules/cfe_testcase/src/sb_msg_id_test.c
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)
{
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");
}
2 changes: 1 addition & 1 deletion modules/fs/config/default_cfe_fs_interface_cfg.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@

#define CFE_FS_HDR_DESC_MAX_LEN 32 /**< \brief Max length of description field in a standard cFE File Header */

#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE compliant files (= 'cFE1') */
#define CFE_FS_FILE_CONTENT_ID 0x63464531 /**< \brief Magic Number for cFE-compliant files (= 'cFE1') */

#endif /* CFE_FS_INTERFACE_CFG_H */

0 comments on commit 37b1b16

Please sign in to comment.