Skip to content

Commit 7465a6a

Browse files
committed
Update #8, Need to control table data for certain test cases
1 parent a029470 commit 7465a6a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

unit-test/coveragetest/coveragetest_sample_app.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ void Test_SAMPLE_ProcessGroundCommand(void)
335335
SAMPLE_ProcessGroundCommand(&TestMsg.Base);
336336

337337
/* test dispatch of PROCESS */
338+
/* note this will end up calling SAMPLE_Process(), and as such it needs to
339+
* avoid dereferencing a table which does not exist. */
340+
UT_SetForceFail(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED);
338341
UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetCmdCode), 1, SAMPLE_APP_PROCESS_CC);
339342
UT_SetDeferredRetcode(UT_KEY(CFE_SB_GetTotalMsgLength), 1, sizeof(TestMsg.Process));
340343

@@ -453,9 +456,16 @@ void Test_SAMPLE_ProcessCC(void)
453456
* void SAMPLE_ProcessCC( const SAMPLE_Process_t *Msg )
454457
*/
455458
SAMPLE_Process_t TestMsg;
459+
SAMPLE_Table_t TestTblData;
460+
void *TblPtr = &TestTblData;
456461

462+
memset(&TestTblData, 0, sizeof(TestTblData));
457463
memset(&TestMsg, 0, sizeof(TestMsg));
458464

465+
/* Provide some table data for the SAMPLE_Process() function to use */
466+
TestTblData.Int1 = 40;
467+
TestTblData.Int2 = 50;
468+
UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TblPtr, sizeof(TblPtr), false);
459469
UT_TEST_FUNCTION_RC(SAMPLE_Process(&TestMsg), CFE_SUCCESS);
460470

461471
/*

0 commit comments

Comments
 (0)