Skip to content

Commit

Permalink
Merge pull request #200 from thnkslprpt:fix-199-add-test-for-missing-…
Browse files Browse the repository at this point in the history
…branch-in-SAMPLE_APP_Process

Fix #199, Add test for missing branch in SAMPLE_APP_Process()
  • Loading branch information
dzbaker committed Oct 30, 2023
2 parents d5489a9 + 3aebb80 commit f764a7f
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 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,26 @@ 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.
* 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);
}

void Test_SAMPLE_APP_VerifyCmdLength(void)
Expand Down

0 comments on commit f764a7f

Please sign in to comment.