diff --git a/fsw/unit-test/CMakeLists.txt b/fsw/unit-test/CMakeLists.txt index ed625c7..0ec1acb 100644 --- a/fsw/unit-test/CMakeLists.txt +++ b/fsw/unit-test/CMakeLists.txt @@ -24,20 +24,21 @@ include_directories(${PROJECT_SOURCE_DIR}/fsw/src) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/inc) -# Add a coverage test executable called "sample_app-ALL" that +# Add a coverage test executable called "sample-ALL" that # covers all of the functions in sample_app. # # Also note in a more complex app/lib the coverage test can also # be broken down into smaller units (in which case one should use # a unique suffix other than "ALL" for each unit). For example, # OSAL implements a separate coverage test per source unit. -add_cfe_coverage_test(sample_app ALL +add_cfe_coverage_test(sample ALL "coveragetest/coveragetest_sample_app.c" - "${CFE_SAMPLE_APP_SOURCE_DIR}/fsw/src/sample_app.c" + "../src/sample_app.c" + "../src/sample_device.c" ) -# The sample_app uses library functions provided by sample_lib so must be linked +# The sample uses library functions provided by sample_lib so must be linked # with the sample_lib stub library (this is mainly just an example of how this # can be done). -add_cfe_coverage_dependency(sample_app ALL sample_lib) +#add_cfe_coverage_dependency(sample ALL sample_lib) diff --git a/fsw/unit-test/coveragetest/coveragetest_sample_app.c b/fsw/unit-test/coveragetest/coveragetest_sample_app.c index 7f35eaa..a36b898 100644 --- a/fsw/unit-test/coveragetest/coveragetest_sample_app.c +++ b/fsw/unit-test/coveragetest/coveragetest_sample_app.c @@ -38,7 +38,6 @@ * Includes */ -#include "sample_lib.h" #include "sample_app_coveragetest_common.h" #include "ut_sample_app.h" @@ -131,26 +130,26 @@ static void UT_CheckEvent_Setup(UT_CheckEvent_t *Evt, uint16 ExpectedEvent, cons ********************************************************************************** */ -void Test_SAMPLE_APP_Main(void) +void Test_SAMPLE_AppMain(void) { CFE_SB_MsgId_t MsgId = CFE_SB_INVALID_MSG_ID; /* * Test Case For: - * void SAMPLE_APP_Main( void ) + * void SAMPLE_AppMain( void ) */ UT_CheckEvent_t EventTest; /* - * SAMPLE_APP_Main does not return a value, + * SAMPLE_AppMain does not return a value, * but it has several internal decision points * that need to be exercised here. * * First call it in "nominal" mode where all * dependent calls should be successful by default. */ - SAMPLE_APP_Main(); + SAMPLE_AppMain(); /* * Confirm that CFE_ES_ExitApp() was called at the end of execution @@ -159,7 +158,7 @@ void Test_SAMPLE_APP_Main(void) /* * Now set up individual cases for each of the error paths. - * The first is for SAMPLE_APP_Init(). As this is in the same + * The first is for SAMPLE_AppInit(). As this is in the same * code unit, it is not a stub where the return code can be * easily set. In order to get this to fail, an underlying * call needs to fail, and the error gets propagated through. @@ -172,9 +171,9 @@ void Test_SAMPLE_APP_Main(void) * Just call the function again. It does not return * the value, so there is nothing to test for here directly. * However, it should show up in the coverage report that - * the SAMPLE_APP_Init() failure path was taken. + * the SAMPLE_AppInit() failure path was taken. */ - SAMPLE_APP_Main(); + SAMPLE_AppMain(); /* * This can validate that the internal "RunStatus" was @@ -184,9 +183,9 @@ void Test_SAMPLE_APP_Main(void) * when asserting on conditions, so if/when it fails, the * log will show what the incorrect value was. */ - UtAssert_True(SAMPLE_APP_Data.RunStatus == CFE_ES_RunStatus_APP_ERROR, - "SAMPLE_APP_Data.RunStatus (%lu) == CFE_ES_RunStatus_APP_ERROR", - (unsigned long)SAMPLE_APP_Data.RunStatus); + UtAssert_True(SAMPLE_AppData.RunStatus == CFE_ES_RunStatus_APP_ERROR, + "SAMPLE_AppData.RunStatus (%lu) == CFE_ES_RunStatus_APP_ERROR", + (unsigned long)SAMPLE_AppData.RunStatus); /* * Note that CFE_ES_RunLoop returns a boolean value, @@ -205,7 +204,7 @@ void Test_SAMPLE_APP_Main(void) /* * Invoke again */ - SAMPLE_APP_Main(); + SAMPLE_AppMain(); /* * Confirm that CFE_SB_ReceiveBuffer() (inside the loop) was called @@ -219,66 +218,66 @@ void Test_SAMPLE_APP_Main(void) */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_RunLoop), 1, true); UT_SetDeferredRetcode(UT_KEY(CFE_SB_ReceiveBuffer), 1, CFE_SB_PIPE_RD_ERR); - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_PIPE_ERR_EID, "SAMPLE APP: SB Pipe Read Error, App Will Exit"); + UT_CheckEvent_Setup(&EventTest, SAMPLE_PIPE_ERR_EID, "SAMPLE: SB Pipe Read Error"); /* * Invoke again */ - SAMPLE_APP_Main(); + SAMPLE_AppMain(); /* * Confirm that the event was generated */ - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_APP_PIPE_ERR_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_PIPE_ERR_EID generated (%u)", (unsigned int)EventTest.MatchCount); } -void Test_SAMPLE_APP_Init(void) +void Test_SAMPLE_AppInit(void) { /* * Test Case For: - * int32 SAMPLE_APP_Init( void ) + * int32 SAMPLE_AppInit( void ) */ /* nominal case should return CFE_SUCCESS */ - UT_TEST_FUNCTION_RC(SAMPLE_APP_Init(), CFE_SUCCESS); + UT_TEST_FUNCTION_RC(SAMPLE_AppInit(), CFE_SUCCESS); /* trigger a failure for each of the sub-calls, * and confirm a write to syslog for each. * Note that this count accumulates, because the status * is _not_ reset between these test cases. */ UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, CFE_EVS_INVALID_PARAMETER); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Init(), CFE_EVS_INVALID_PARAMETER); + UT_TEST_FUNCTION_RC(SAMPLE_AppInit(), CFE_EVS_INVALID_PARAMETER); UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 1, "CFE_ES_WriteToSysLog() called"); UT_SetDeferredRetcode(UT_KEY(CFE_SB_CreatePipe), 1, CFE_SB_BAD_ARGUMENT); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Init(), CFE_SB_BAD_ARGUMENT); + UT_TEST_FUNCTION_RC(SAMPLE_AppInit(), CFE_SB_BAD_ARGUMENT); UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 2, "CFE_ES_WriteToSysLog() called"); UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 1, CFE_SB_BAD_ARGUMENT); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Init(), CFE_SB_BAD_ARGUMENT); + UT_TEST_FUNCTION_RC(SAMPLE_AppInit(), CFE_SB_BAD_ARGUMENT); UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 3, "CFE_ES_WriteToSysLog() called"); UT_SetDeferredRetcode(UT_KEY(CFE_SB_Subscribe), 2, CFE_SB_BAD_ARGUMENT); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Init(), CFE_SB_BAD_ARGUMENT); + UT_TEST_FUNCTION_RC(SAMPLE_AppInit(), CFE_SB_BAD_ARGUMENT); UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 4, "CFE_ES_WriteToSysLog() called"); UT_SetDeferredRetcode(UT_KEY(CFE_TBL_Register), 1, CFE_TBL_ERR_INVALID_OPTIONS); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Init(), CFE_TBL_ERR_INVALID_OPTIONS); + UT_TEST_FUNCTION_RC(SAMPLE_AppInit(), CFE_TBL_ERR_INVALID_OPTIONS); UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 5, "CFE_ES_WriteToSysLog() called"); } -void Test_SAMPLE_APP_ProcessCommandPacket(void) +void Test_SAMPLE_ProcessCommandPacket(void) { /* * Test Case For: - * void SAMPLE_APP_ProcessCommandPacket + * void SAMPLE_ProcessCommandPacket */ /* a buffer large enough for any command message */ union { CFE_SB_Buffer_t SBBuf; - SAMPLE_APP_NoopCmd_t Noop; + SAMPLE_NoArgs_cmd_t Noop; } TestMsg; CFE_SB_MsgId_t TestMsgId; CFE_MSG_FcnCode_t FcnCode; @@ -286,41 +285,41 @@ void Test_SAMPLE_APP_ProcessCommandPacket(void) UT_CheckEvent_t EventTest; memset(&TestMsg, 0, sizeof(TestMsg)); - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_INVALID_MSGID_ERR_EID, "SAMPLE: invalid command packet,MID = 0x%x"); + UT_CheckEvent_Setup(&EventTest, SAMPLE_PROCESS_CMD_ERR_EID, "SAMPLE: Invalid command packet, MID = 0x%x"); /* * The CFE_MSG_GetMsgId() stub uses a data buffer to hold the * message ID values to return. */ - TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_CMD_MID); - FcnCode = SAMPLE_APP_NOOP_CC; + TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_CMD_MID); + FcnCode = SAMPLE_NOOP_CC; MsgSize = sizeof(TestMsg.Noop); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &MsgSize, sizeof(MsgSize), false); - SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf); + SAMPLE_ProcessCommandPacket(); - TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); + TestMsgId = CFE_SB_ValueToMsgId(SAMPLE_REQ_HK_TLM); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf); + SAMPLE_ProcessCommandPacket(); /* invalid message id */ TestMsgId = CFE_SB_INVALID_MSG_ID; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false); - SAMPLE_APP_ProcessCommandPacket(&TestMsg.SBBuf); + SAMPLE_ProcessCommandPacket(); /* * Confirm that the event was generated only _once_ */ - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_APP_COMMAND_ERR_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_CMD_ERR_EID generated (%u)", (unsigned int)EventTest.MatchCount); } -void Test_SAMPLE_APP_ProcessGroundCommand(void) +void Test_SAMPLE_ProcessGroundCommand(void) { /* * Test Case For: - * void SAMPLE_APP_ProcessGroundCommand + * void SAMPLE_ProcessGroundCommand */ CFE_MSG_FcnCode_t FcnCode; size_t Size; @@ -328,10 +327,10 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) /* a buffer large enough for any command message */ union { - CFE_SB_Buffer_t SBBuf; - SAMPLE_APP_NoopCmd_t Noop; - SAMPLE_APP_ResetCountersCmd_t Reset; - SAMPLE_APP_ProcessCmd_t Process; + CFE_SB_Buffer_t SBBuf; + SAMPLE_NoArgs_cmd_t Noop; + SAMPLE_NoArgs_cmd_t Reset; + SAMPLE_NoArgs_cmd_t Process; } TestMsg; UT_CheckEvent_t EventTest; @@ -347,64 +346,53 @@ void Test_SAMPLE_APP_ProcessGroundCommand(void) */ /* test dispatch of NOOP */ - FcnCode = SAMPLE_APP_NOOP_CC; + FcnCode = SAMPLE_NOOP_CC; Size = sizeof(TestMsg.Noop); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMANDNOP_INF_EID, NULL); + UT_CheckEvent_Setup(&EventTest, SAMPLE_CMD_NOOP_INF_EID, NULL); - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + SAMPLE_ProcessGroundCommand(); - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_COMMANDNOP_INF_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_CMD_NOOP_INF_EID generated (%u)", (unsigned int)EventTest.MatchCount); /* test dispatch of RESET */ - FcnCode = SAMPLE_APP_RESET_COUNTERS_CC; + FcnCode = SAMPLE_RESET_COUNTERS_CC; Size = sizeof(TestMsg.Reset); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMANDRST_INF_EID, NULL); + UT_CheckEvent_Setup(&EventTest, SAMPLE_CMD_RESET_INF_EID, NULL); - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + SAMPLE_ProcessGroundCommand(); - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_COMMANDRST_INF_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_CMD_RESET_INF_EID generated (%u)", (unsigned int)EventTest.MatchCount); - /* test dispatch of PROCESS */ - /* note this will end up calling SAMPLE_APP_Process(), and as such it needs to - * avoid dereferencing a table which does not exist. */ - FcnCode = SAMPLE_APP_PROCESS_CC; - Size = sizeof(TestMsg.Process); - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); - - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); - /* test an invalid CC */ FcnCode = 1000; UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false); - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMAND_ERR_EID, "Invalid ground command code: CC = %d"); - SAMPLE_APP_ProcessGroundCommand(&TestMsg.SBBuf); + UT_CheckEvent_Setup(&EventTest, SAMPLE_CMD_ERR_EID, "Invalid ground command code: CC = %d"); + SAMPLE_ProcessGroundCommand(); /* * Confirm that the event was generated only _once_ */ - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_APP_COMMAND_ERR_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_CMD_ERR_EID generated (%u)", (unsigned int)EventTest.MatchCount); } -void Test_SAMPLE_APP_ReportHousekeeping(void) +void Test_SAMPLE_ReportHousekeeping(void) { /* * Test Case For: - * void SAMPLE_APP_ReportHousekeeping( const CFE_SB_CmdHdr_t *Msg ) + * void SAMPLE_ReportHousekeeping( const CFE_SB_CmdHdr_t *Msg ) */ CFE_MSG_Message_t *MsgSend; CFE_MSG_Message_t *MsgTimestamp; - CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(SAMPLE_APP_SEND_HK_MID); + CFE_SB_MsgId_t MsgId = CFE_SB_ValueToMsgId(SAMPLE_REQ_HK_TLM); - /* Set message id to return so SAMPLE_APP_Housekeeping will be called */ + /* Set message id to return so SAMPLE_Housekeeping will be called */ UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &MsgId, sizeof(MsgId), false); /* Set up to capture send message address */ @@ -414,15 +402,15 @@ void Test_SAMPLE_APP_ReportHousekeeping(void) UT_SetDataBuffer(UT_KEY(CFE_SB_TimeStampMsg), &MsgTimestamp, sizeof(MsgTimestamp), false); /* Call unit under test, NULL pointer confirms command access is through APIs */ - SAMPLE_APP_ProcessCommandPacket((CFE_SB_Buffer_t *)NULL); + SAMPLE_ProcessCommandPacket(); /* Confirm message sent*/ UtAssert_True(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)) == 1, "CFE_SB_TransmitMsg() called once"); - UtAssert_True(MsgSend == &SAMPLE_APP_Data.HkTlm.TlmHeader.Msg, "CFE_SB_TransmitMsg() address matches expected"); + UtAssert_True(MsgSend == &SAMPLE_AppData.HkTelemetryPkt.TlmHeader.Msg, "CFE_SB_TransmitMsg() address matches expected"); /* Confirm timestamp msg address */ UtAssert_True(UT_GetStubCount(UT_KEY(CFE_SB_TimeStampMsg)) == 1, "CFE_SB_TimeStampMsg() called once"); - UtAssert_True(MsgTimestamp == &SAMPLE_APP_Data.HkTlm.TlmHeader.Msg, + UtAssert_True(MsgTimestamp == &SAMPLE_AppData.HkTelemetryPkt.TlmHeader.Msg, "CFE_SB_TimeStampMsg() address matches expected"); /* @@ -431,94 +419,30 @@ void Test_SAMPLE_APP_ReportHousekeeping(void) UtAssert_True(UT_GetStubCount(UT_KEY(CFE_TBL_Manage)) == 1, "CFE_TBL_Manage() called"); } -void Test_SAMPLE_APP_NoopCmd(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_NoopCmd( const SAMPLE_APP_Noop_t *Msg ) - */ - SAMPLE_APP_NoopCmd_t TestMsg; - UT_CheckEvent_t EventTest; - - memset(&TestMsg, 0, sizeof(TestMsg)); - - /* test dispatch of NOOP */ - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMANDNOP_INF_EID, NULL); - - UT_TEST_FUNCTION_RC(SAMPLE_APP_Noop(&TestMsg), CFE_SUCCESS); - - /* - * Confirm that the event was generated - */ - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_APP_COMMANDNOP_INF_EID generated (%u)", - (unsigned int)EventTest.MatchCount); -} - -void Test_SAMPLE_APP_ResetCounters(void) +void Test_SAMPLE_ResetCounters(void) { /* * Test Case For: - * void SAMPLE_APP_ResetCounters( const SAMPLE_APP_ResetCounters_t *Msg ) + * void SAMPLE_ResetCounters( void ) */ - SAMPLE_APP_ResetCountersCmd_t TestMsg; UT_CheckEvent_t EventTest; - memset(&TestMsg, 0, sizeof(TestMsg)); - - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_COMMANDRST_INF_EID, "SAMPLE: RESET command"); + UT_CheckEvent_Setup(&EventTest, SAMPLE_CMD_RESET_INF_EID, "SAMPLE: RESET command"); - UT_TEST_FUNCTION_RC(SAMPLE_APP_ResetCounters(&TestMsg), CFE_SUCCESS); + SAMPLE_ResetCounters(); /* * Confirm that the event was generated */ - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_APP_COMMANDRST_INF_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_CMD_RESET_INF_EID generated (%u)", (unsigned int)EventTest.MatchCount); } -void Test_SAMPLE_APP_ProcessCC(void) +void Test_SAMPLE_VerifyCmdLength(void) { /* * Test Case For: - * void SAMPLE_APP_ProcessCC( const SAMPLE_APP_Process_t *Msg ) - */ - SAMPLE_APP_ProcessCmd_t TestMsg; - SAMPLE_APP_Table_t TestTblData; - void * TblPtr = &TestTblData; - - memset(&TestTblData, 0, sizeof(TestTblData)); - memset(&TestMsg, 0, sizeof(TestMsg)); - - /* Provide some table data for the SAMPLE_APP_Process() function to use */ - TestTblData.Int1 = 40; - TestTblData.Int2 = 50; - UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TblPtr, sizeof(TblPtr), false); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Process(&TestMsg), CFE_SUCCESS); - - /* - * Confirm that the CFE_TBL_GetAddress() call was done - */ - UtAssert_True(UT_GetStubCount(UT_KEY(CFE_TBL_GetAddress)) == 1, "CFE_TBL_GetAddress() called"); - - /* - * Confirm that the SAMPLE_LIB_Function() call was done - * NOTE: This stub is provided by the sample_lib library - */ - UtAssert_True(UT_GetStubCount(UT_KEY(SAMPLE_LIB_Function)) == 1, "SAMPLE_LIB_Function() called"); - - /* - * Configure the CFE_TBL_GetAddress function to return an error - * Exercise the error return path - */ - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED); - UT_TEST_FUNCTION_RC(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_UNREGISTERED); -} - -void Test_SAMPLE_APP_VerifyCmdLength(void) -{ - /* - * Test Case For: - * bool SAMPLE_APP_VerifyCmdLength + * bool SAMPLE_VerifyCmdLength */ UT_CheckEvent_t EventTest; size_t size = 1; @@ -529,15 +453,15 @@ void Test_SAMPLE_APP_VerifyCmdLength(void) * test a match case */ UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); - UT_CheckEvent_Setup(&EventTest, SAMPLE_APP_LEN_ERR_EID, + UT_CheckEvent_Setup(&EventTest, SAMPLE_LEN_ERR_EID, "Invalid Msg length: ID = 0x%X, CC = %u, Len = %u, Expected = %u"); - SAMPLE_APP_VerifyCmdLength(NULL, size); + SAMPLE_VerifyCmdLength(NULL, size); /* * Confirm that the event was NOT generated */ - UtAssert_True(EventTest.MatchCount == 0, "SAMPLE_APP_LEN_ERR_EID NOT generated (%u)", + UtAssert_True(EventTest.MatchCount == 0, "SAMPLE_LEN_ERR_EID NOT generated (%u)", (unsigned int)EventTest.MatchCount); /* @@ -546,58 +470,15 @@ void Test_SAMPLE_APP_VerifyCmdLength(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &size, sizeof(size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &fcncode, sizeof(fcncode), false); - SAMPLE_APP_VerifyCmdLength(NULL, size + 1); + SAMPLE_VerifyCmdLength(NULL, size + 1); /* * Confirm that the event WAS generated */ - UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_APP_LEN_ERR_EID generated (%u)", + UtAssert_True(EventTest.MatchCount == 1, "SAMPLE_LEN_ERR_EID generated (%u)", (unsigned int)EventTest.MatchCount); } -void Test_SAMPLE_APP_TblValidationFunc(void) -{ - /* - * Test Case For: - * int32 SAMPLE_APP_TblValidationFunc( void *TblData ) - */ - SAMPLE_APP_Table_t TestTblData; - - memset(&TestTblData, 0, sizeof(TestTblData)); - - /* nominal case (0) should succeed */ - UT_TEST_FUNCTION_RC(SAMPLE_APP_TblValidationFunc(&TestTblData), CFE_SUCCESS); - - /* error case should return SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE */ - TestTblData.Int1 = 1 + SAMPLE_APP_TBL_ELEMENT_1_MAX; - UT_TEST_FUNCTION_RC(SAMPLE_APP_TblValidationFunc(&TestTblData), SAMPLE_APP_TABLE_OUT_OF_RANGE_ERR_CODE); -} - -void Test_SAMPLE_APP_GetCrc(void) -{ - /* - * Test Case For: - * void SAMPLE_APP_GetCrc( const char *TableName ) - */ - - /* - * The only branch point here is CFE_TBL_GetInfo() - * - * Either way this function just does a write to syslog, - * and it is the same in both cases, just with - * a different message. This could actually verify - * the message using a hook function, if desired. - */ - - UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetInfo), CFE_TBL_ERR_INVALID_NAME); - SAMPLE_APP_GetCrc("UT"); - UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 1, "CFE_ES_WriteToSysLog() called"); - - UT_ClearDefaultReturnValue(UT_KEY(CFE_TBL_GetInfo)); - SAMPLE_APP_GetCrc("UT"); - UtAssert_True(UT_GetStubCount(UT_KEY(CFE_ES_WriteToSysLog)) == 2, "CFE_ES_WriteToSysLog() called"); -} - /* * Setup function prior to every test */ @@ -616,15 +497,11 @@ void Sample_UT_TearDown(void) {} */ void UtTest_Setup(void) { - ADD_TEST(SAMPLE_APP_Main); - ADD_TEST(SAMPLE_APP_Init); - ADD_TEST(SAMPLE_APP_ProcessCommandPacket); - ADD_TEST(SAMPLE_APP_ProcessGroundCommand); - ADD_TEST(SAMPLE_APP_ReportHousekeeping); - ADD_TEST(SAMPLE_APP_NoopCmd); - ADD_TEST(SAMPLE_APP_ResetCounters); - ADD_TEST(SAMPLE_APP_ProcessCC); - ADD_TEST(SAMPLE_APP_VerifyCmdLength); - ADD_TEST(SAMPLE_APP_TblValidationFunc); - ADD_TEST(SAMPLE_APP_GetCrc); + ADD_TEST(SAMPLE_AppMain); + ADD_TEST(SAMPLE_AppInit); + ADD_TEST(SAMPLE_ProcessCommandPacket); + ADD_TEST(SAMPLE_ProcessGroundCommand); + ADD_TEST(SAMPLE_ReportHousekeeping); + ADD_TEST(SAMPLE_ResetCounters); + ADD_TEST(SAMPLE_VerifyCmdLength); } diff --git a/fsw/unit-test/coveragetest/sample_app_coveragetest_common.h b/fsw/unit-test/coveragetest/sample_app_coveragetest_common.h index c7261d6..376c7a7 100644 --- a/fsw/unit-test/coveragetest/sample_app_coveragetest_common.h +++ b/fsw/unit-test/coveragetest/sample_app_coveragetest_common.h @@ -36,9 +36,8 @@ #include "utstubs.h" #include "cfe.h" -#include "sample_app_events.h" +#include "sample_events.h" #include "sample_app.h" -#include "sample_app_table.h" /* * Macro to call a function and check its int32 return code diff --git a/fsw/unit-test/inc/ut_sample_app.h b/fsw/unit-test/inc/ut_sample_app.h index 8b6995b..4da0456 100644 --- a/fsw/unit-test/inc/ut_sample_app.h +++ b/fsw/unit-test/inc/ut_sample_app.h @@ -41,12 +41,11 @@ * Necessary to include these here to get the definition of the * "SAMPLE_APP_Data_t" typedef. */ -#include "sample_app_events.h" #include "sample_app.h" /* * Allow UT access to the global "SAMPLE_APP_Data" object. */ -extern SAMPLE_APP_Data_t SAMPLE_APP_Data; +//extern SAMPLE_AppData_t SAMPLE_APP_Data; #endif /* UT_SAMPLE_APP_H */