Skip to content

Commit

Permalink
Fix nasa#199, Add test for missing branch in SAMPLE_APP_Process()
Browse files Browse the repository at this point in the history
  • Loading branch information
thnkslprpt committed Mar 7, 2023
1 parent a410436 commit 8100cf8
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions unit-test/coveragetest/coveragetest_sample_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,13 @@ void Test_SAMPLE_APP_ProcessCC(void)
UT_SetDataBuffer(UT_KEY(CFE_TBL_GetAddress), &TblPtr, sizeof(TblPtr), false);
UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_SUCCESS);

/*
* Successful operation results in two calls to CFE_ES_WriteToSysLog() - one
* in this function reporting the table values, and one through
* SAMPLE_APP_GetCrc().
*/
UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 2);

/*
* Confirm that the CFE_TBL_GetAddress() call was done
*/
Expand All @@ -505,11 +512,28 @@ void Test_SAMPLE_APP_ProcessCC(void)
UtAssert_STUB_COUNT(SAMPLE_LIB_Function, 1);

/*
* Configure the CFE_TBL_GetAddress function to return an error
* Exercise the error return path
* Configure the CFE_TBL_GetAddress function to return an error.
* Exercise the error return path.
* Error at this point should add only one additional call to
* CFE_ES_WriteToSysLog() through the CFE_TBL_GetAddress() error path.
*/
UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_TBL_ERR_UNREGISTERED);
UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_UNREGISTERED);
UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 3);

/*
* Configure CFE_TBL_ReleaseAddress() to return an error, exercising the
* error return path and confirm that SAMPLE_LIB_Function() was not called
* again (should still be on a count of 1).
* Also confirm three additional calls to CFE_ES_WriteToSysLog() - one
* reporting the table values, one through SAMPLE_APP_GetCrc() and one
* through the CFE_TBL_ReleaseAddress() error path.
*/
UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_GetAddress), CFE_SUCCESS);
UT_SetDefaultReturnValue(UT_KEY(CFE_TBL_ReleaseAddress), CFE_TBL_ERR_NO_ACCESS);
UtAssert_INT32_EQ(SAMPLE_APP_Process(&TestMsg), CFE_TBL_ERR_NO_ACCESS);
UtAssert_STUB_COUNT(CFE_ES_WriteToSysLog, 6);
UtAssert_STUB_COUNT(SAMPLE_LIB_Function, 1);
}

void Test_SAMPLE_APP_VerifyCmdLength(void)
Expand Down

0 comments on commit 8100cf8

Please sign in to comment.