Skip to content

Commit

Permalink
Merge pull request nasa#32 from skliper/fix31-rm_psp_mem_api
Browse files Browse the repository at this point in the history
Fix nasa#31, Remove CFE_PSP_MemSet use for addresses in RAM
  • Loading branch information
astrogeco authored Jun 1, 2022
2 parents 4e55a38 + 4c1d1c0 commit 7743c2a
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 45 deletions.
4 changes: 2 additions & 2 deletions fsw/src/sc_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ int32 SC_AppInit(void)
int32 Result;

/* Clear global data structures */
memset(&SC_OperData, 0, sizeof(SC_OperData_t));
memset(&SC_AppData, 0, sizeof(SC_AppData_t));
memset(&SC_OperData, 0, sizeof(SC_OperData));
memset(&SC_AppData, 0, sizeof(SC_AppData));

/* Number of ATS and RTS commands already executed this second */
SC_OperData.NumCmdsSec = 0;
Expand Down
16 changes: 8 additions & 8 deletions unit-test/sc_app_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -251,11 +251,11 @@ void SC_AppInit_Test_NominalPowerOnReset(void)

/* Set global data structures to non-zero values, to verify that SC_AppInit sets values to 0 (with some exceptions)
*/
memset(&SC_OperData, 1, sizeof(SC_OperData_t));
memset(&SC_AppData, 1, sizeof(SC_AppData_t));
memset(&SC_OperData, 1, sizeof(SC_OperData));
memset(&SC_AppData, 1, sizeof(SC_AppData));

memset(&Expected_SC_OperData, 0, sizeof(SC_OperData_t));
memset(&Expected_SC_AppData, 0, sizeof(SC_AppData_t));
memset(&Expected_SC_OperData, 0, sizeof(Expected_SC_OperData));
memset(&Expected_SC_AppData, 0, sizeof(Expected_SC_AppData));

Expected_SC_AppData.NextProcNumber = SC_NONE;
Expected_SC_AppData.NextCmdTime[SC_ATP] = SC_MAX_TIME;
Expand Down Expand Up @@ -337,11 +337,11 @@ void SC_AppInit_Test_Nominal(void)

/* Set global data structures to non-zero values, to verify that SC_AppInit sets values to 0 (with some exceptions)
*/
memset(&SC_OperData, 1, sizeof(SC_OperData_t));
memset(&SC_AppData, 1, sizeof(SC_AppData_t));
memset(&SC_OperData, 1, sizeof(SC_OperData));
memset(&SC_AppData, 1, sizeof(SC_AppData));

memset(&Expected_SC_OperData, 0, sizeof(SC_OperData_t));
memset(&Expected_SC_AppData, 0, sizeof(SC_AppData_t));
memset(&Expected_SC_OperData, 0, sizeof(Expected_SC_OperData));
memset(&Expected_SC_AppData, 0, sizeof(Expected_SC_AppData));

Expected_SC_AppData.NextProcNumber = SC_NONE;
Expected_SC_AppData.NextCmdTime[SC_ATP] = SC_MAX_TIME;
Expand Down
21 changes: 0 additions & 21 deletions unit-test/sc_cmds_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,6 @@ void SC_ProcessAtpCmd_Test_SwitchCmd(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, true);

/* Execute the function being tested */
Expand Down Expand Up @@ -170,9 +167,6 @@ void SC_ProcessAtpCmd_Test_NonSwitchCmd(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, true);

/* Execute the function being tested */
Expand Down Expand Up @@ -236,9 +230,6 @@ void SC_ProcessAtpCmd_Test_InlineSwitchError(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, false);

/* Execute the function being tested */
Expand Down Expand Up @@ -487,9 +478,6 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsA(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, true);

/* Execute the function being tested */
Expand Down Expand Up @@ -577,9 +565,6 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsB(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, true);

/* Execute the function being tested */
Expand Down Expand Up @@ -667,9 +652,6 @@ void SC_ProcessAtpCmd_Test_ChecksumFailedAtsAContinue(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, true);

/* Execute the function being tested */
Expand Down Expand Up @@ -1070,9 +1052,6 @@ void SC_ProcessAtpCmd_Test_CmdMid(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &TestMsgId, sizeof(TestMsgId), false);
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetFcnCode), &FcnCode, sizeof(FcnCode), false);

/* Same return value as default, but bypasses default hook function to simplify test */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

UT_SetDeferredRetcode(UT_KEY(SC_InlineSwitch), 1, true);

/* Execute the function being tested */
Expand Down
12 changes: 0 additions & 12 deletions unit-test/sc_loads_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -1623,9 +1623,6 @@ void SC_ProcessAppend_Test(void)
uint32 AtsAppendTable[SC_APPEND_BUFF_SIZE32];
size_t MsgSize;

/* Setting memcpy to return success, otherwise the test will cause a seg fault */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

SC_InitTables();

memset(&AtsTable, 0, sizeof(AtsTable));
Expand Down Expand Up @@ -1690,9 +1687,6 @@ void SC_ProcessAppend_Test_CmdLoaded(void)
uint32 AtsAppendTable[SC_APPEND_BUFF_SIZE32];
size_t MsgSize;

/* Setting memcpy to return success, otherwise the test will cause a seg fault */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

SC_InitTables();

memset(&AtsTable, 0, sizeof(AtsTable));
Expand Down Expand Up @@ -1754,9 +1748,6 @@ void SC_ProcessAppend_Test_NotExecuting(void)
uint32 AtsAppendTable[SC_APPEND_BUFF_SIZE32];
size_t MsgSize;

/* Setting memcpy to return success, otherwise the test will cause a seg fault */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

SC_InitTables();

memset(&AtsTable, 0, sizeof(AtsTable));
Expand Down Expand Up @@ -1817,9 +1808,6 @@ void SC_ProcessAppend_Test_AtsNumber(void)
uint32 AtsAppendTable[SC_APPEND_BUFF_SIZE32];
size_t MsgSize;

/* Setting memcpy to return success, otherwise the test will cause a seg fault */
UT_SetDeferredRetcode(UT_KEY(CFE_PSP_MemCpy), 1, CFE_PSP_SUCCESS);

SC_InitTables();

memset(&AtsTable, 0, sizeof(AtsTable));
Expand Down
4 changes: 2 additions & 2 deletions unit-test/utilities/sc_test_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void SC_Test_Setup(void)
/* initialize test environment to default state for every test */
UT_ResetState(0);

memset(&SC_OperData, 0, sizeof(SC_OperData_t));
memset(&SC_AppData, 0, sizeof(SC_AppData_t));
memset(&SC_OperData, 0, sizeof(SC_OperData));
memset(&SC_AppData, 0, sizeof(SC_AppData));
memset(RtsInfoTbl, 0, sizeof(RtsInfoTbl));

memset(context_CFE_EVS_SendEvent, 0, sizeof(context_CFE_EVS_SendEvent));
Expand Down

0 comments on commit 7743c2a

Please sign in to comment.