Skip to content

Commit

Permalink
Fix nasa#467, Add coverage for CFE_ES_CreateObjects and CFE_ES_Main
Browse files Browse the repository at this point in the history
Completed 100% coverage on cfe_es_start.c
  • Loading branch information
pepepr08 committed Jun 23, 2021
1 parent d03e24e commit d593d30
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,15 @@ void TestStartupErrorPaths(void)
PanicStatus == CFE_PSP_PANIC_STARTUP_SEM && UT_GetStubCount(UT_KEY(CFE_PSP_Panic)) == 1, "CFE_ES_Main",
"Mutex create failure");

/* Perform ES main startup with a file open failure */
/* Perform ES main startup with a ES Perf Data mutex creation failure */
ES_ResetUnitTest();
UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 2, OS_ERROR);
UT_SetDataBuffer(UT_KEY(CFE_PSP_Panic), &PanicStatus, sizeof(PanicStatus), false);
CFE_ES_Main(CFE_PSP_RST_TYPE_POWERON, 1, 1, "ut_startup");
UtAssert_UINT32_EQ(PanicStatus, CFE_PSP_PANIC_STARTUP_SEM);
UtAssert_UINT32_EQ(UT_GetStubCount(UT_KEY(CFE_PSP_Panic)), 1);

/* Perform ES main startup with a ES Shared Data mutex creation failure */
ES_ResetUnitTest();
UT_SetDummyFuncRtn(OS_SUCCESS);
UT_SetDefaultReturnValue(UT_KEY(OS_OpenCreate), OS_ERROR);
Expand Down Expand Up @@ -963,6 +971,13 @@ void TestStartupErrorPaths(void)
UT_Report(__FILE__, __LINE__, UT_PrintfIsInHistory(UT_OSP_MESSAGES[UT_OSP_FUNCTION_POINTER]),
"CFE_ES_CreateObjects", "Bad function pointer message");

/* Test reading the object table with a NULL object type */
ES_ResetUnitTest();
UT_SetDefaultReturnValue(UT_KEY(CFE_ResourceId_FindNext), OS_ERROR);
CFE_ES_ObjectTable[CFE_PLATFORM_ES_OBJECT_TABLE_SIZE-1].ObjectType = -1; /* Set last entry to unknown type */
CFE_ES_CreateObjects();
CFE_UtAssert_PrintfIsInHistory((UT_OSP_MESSAGES[UT_OSP_NO_FREE_CORE_APP_SLOTS]));

/* Test response to an invalid startup type */
ES_ResetUnitTest();
CFE_ES_Global.DebugVars.DebugFlag = 1;
Expand Down

0 comments on commit d593d30

Please sign in to comment.