From e17bf7f0a52280146b9053c9ef43031424753832 Mon Sep 17 00:00:00 2001 From: Avi Weiss Date: Sun, 1 Dec 2024 17:38:27 +0100 Subject: [PATCH] Fix #115, Clean up minor bugs in the CS unit tests --- fsw/src/cs_utils.c | 2 +- unit-test/cs_app_cmds_tests.c | 24 ++++++------------------ unit-test/cs_app_tests.c | 3 --- 3 files changed, 7 insertions(+), 22 deletions(-) diff --git a/fsw/src/cs_utils.c b/fsw/src/cs_utils.c index 50a3090..bed1c43 100644 --- a/fsw/src/cs_utils.c +++ b/fsw/src/cs_utils.c @@ -105,7 +105,7 @@ void CS_ZeroAppTempValues(void) /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* */ -/* CS Zero out the temp chcksum values ofthe cFE core */ +/* CS Zero out the temp chcksum values of the cFE core */ /* */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ void CS_ZeroCfeCoreTempValues(void) diff --git a/unit-test/cs_app_cmds_tests.c b/unit-test/cs_app_cmds_tests.c index 8bb2bf3..b91351d 100644 --- a/unit-test/cs_app_cmds_tests.c +++ b/unit-test/cs_app_cmds_tests.c @@ -152,8 +152,6 @@ void CS_EnableAppCmd_Test(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1", @@ -254,8 +252,6 @@ void CS_ReportBaselineAppCmd_Test_NoBaseline(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1", @@ -315,12 +311,13 @@ void CS_ReportBaselineAppCmd_Test_OneShot(void) UT_SetDeferredRetcode(UT_KEY(CS_VerifyCmdLength), 1, true); - /* Execute the function being tested */ - CS_RecomputeBaselineAppCmd(&CmdPacket); UT_SetDeferredRetcode(UT_KEY(CS_GetAppResTblEntryByName), 1, true); UT_SetHandlerFunction(UT_KEY(CS_GetAppResTblEntryByName), CS_APP_CMDS_TEST_CS_GetAppResTblEntryByNameHandler1, NULL); + /* Execute the function being tested */ + CS_RecomputeBaselineAppCmd(&CmdPacket); + /* Verify results */ UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, CS_RECOMPUTE_APP_CHDTASK_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); @@ -377,8 +374,6 @@ void CS_RecomputeBaselineAppCmd_Test_Nominal(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1", @@ -487,12 +482,13 @@ void CS_RecomputeBaselineAppCmd_Test_RecomputeInProgress(void) UT_SetDeferredRetcode(UT_KEY(CS_VerifyCmdLength), 1, true); - /* Execute the function being tested */ - CS_RecomputeBaselineAppCmd(&CmdPacket); UT_SetDeferredRetcode(UT_KEY(CS_GetAppResTblEntryByName), 1, true); UT_SetHandlerFunction(UT_KEY(CS_GetAppResTblEntryByName), CS_APP_CMDS_TEST_CS_GetAppResTblEntryByNameHandler1, NULL); + /* Execute the function being tested */ + CS_RecomputeBaselineAppCmd(&CmdPacket); + /* Verify results */ UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventID, CS_RECOMPUTE_APP_CHDTASK_ERR_EID); UtAssert_INT32_EQ(context_CFE_EVS_SendEvent[0].EventType, CFE_EVS_EventType_ERROR); @@ -549,8 +545,6 @@ void CS_DisableNameAppCmd_Test_Nominal(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1", @@ -605,8 +599,6 @@ void CS_DisableNameAppCmd_Test_UpdateAppsDefinitionTableError(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 2, "CFE_EVS_SendEvent was called %u time(s), expected 2", @@ -711,8 +703,6 @@ void CS_EnableNameAppCmd_Test_Nominal(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 1, "CFE_EVS_SendEvent was called %u time(s), expected 1", @@ -767,8 +757,6 @@ void CS_EnableNameAppCmd_Test_UpdateAppsDefinitionTableError(void) UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - UtAssert_True(CS_AppData.HkPacket.Payload.CmdCounter == 1, "CS_AppData.HkPacket.Payload.CmdCounter == 1"); - call_count_CFE_EVS_SendEvent = UT_GetStubCount(UT_KEY(CFE_EVS_SendEvent)); UtAssert_True(call_count_CFE_EVS_SendEvent == 2, "CFE_EVS_SendEvent was called %u time(s), expected 2", diff --git a/unit-test/cs_app_tests.c b/unit-test/cs_app_tests.c index 4faaaab..08547e1 100644 --- a/unit-test/cs_app_tests.c +++ b/unit-test/cs_app_tests.c @@ -411,9 +411,6 @@ void CS_AppMain_Test_RcvNullBufPtr(void) /* Set to make CS_AppPipe return -1 */ UT_SetDeferredRetcode(UT_KEY(CS_HandleRoutineTableUpdates), 1, -1); - /* Set to satisfy subsequent condition "BufPtr == NULL" */ - UT_SetDataBuffer(UT_KEY(CFE_SB_ReceiveBuffer), Packet, sizeof(CS_NoArgsCmd_t), false); - /* Execute the function being tested */ CS_AppMain();