Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2076, Improve ES unit test coverage #2081

Merged
merged 1 commit into from
Apr 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,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