Skip to content

Commit

Permalink
Merge pull request #2081 from skliper/fix2076-modsrcvercallback_coverage
Browse files Browse the repository at this point in the history
Fix #2076, Improve ES unit test coverage
  • Loading branch information
astrogeco committed Apr 18, 2022
2 parents db2b466 + dfc5d09 commit 9d087e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ jobs:
- name: Confirm Minimum Coverage
run: |
missed_branches=76
missed_lines=33
missed_branches=52
missed_lines=18
branch_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep branches | grep -oP "[0-9]+[0-9]*")
line_nums=$(grep -A 3 "Overall coverage rate" lcov_out.txt | grep lines | grep -oP "[0-9]+[0-9]*")
Expand Down
15 changes: 14 additions & 1 deletion modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
*/
#include "es_UT.h"
#include "target_config.h"
#include "cfe_config.h"

#define ES_UT_CDS_BLOCK_SIZE 16

Expand Down Expand Up @@ -1123,6 +1124,14 @@ static void ES_UT_ForEachObjectFail(void *UserObj, UT_EntryKey_t FuncKey, const
(*callback_ptr)(id, callback_arg);
}

static void ES_UT_Config_IterateAll(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context)
{
CFE_Config_Callback_t Callback = UT_Hook_GetArgValueByName(Context, "Callback", CFE_Config_Callback_t);

(*Callback)(NULL, CFE_CONFIGID_UNDEFINED, "Test");
(*Callback)(NULL, CFE_CONFIGID_UNDEFINED, "MOD_SRCVER_test");
}

void TestApps(void)
{
int NumBytes;
Expand Down Expand Up @@ -3498,11 +3507,15 @@ void TestTask(void)
UT_CallTaskPipe(CFE_ES_TaskPipe, &CmdBuf.Msg, sizeof(CmdBuf.NoArgsCmd), UT_TPID_CFE_ES_CMD_NOOP_CC);
CFE_UtAssert_PRINTF("Error sending build info event");

/* Test CFE_ES_GenerateVersionEvents error when sending mission event */
/*
* Test CFE_ES_GenerateVersionEvents error when sending mission event and add hook
* to cover CFE_ES_ModSrcVerCallback
*/
ES_ResetUnitTest();
ES_UT_SetupSingleAppId(CFE_ES_AppType_CORE, CFE_ES_AppState_RUNNING, NULL, NULL, NULL);
CFE_ES_Global.ResetDataPtr->ResetVars.ResetType = 1;
UT_SetDeferredRetcode(UT_KEY(CFE_EVS_SendEvent), 3, CFE_EVS_INVALID_PARAMETER);
UT_SetHandlerFunction(UT_KEY(CFE_Config_IterateAll), ES_UT_Config_IterateAll, NULL);
UtAssert_VOIDCALL(CFE_ES_TaskInit());
CFE_UtAssert_PRINTF("Error sending mission version event");

Expand Down

0 comments on commit 9d087e1

Please sign in to comment.