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 #467, #1636 Complete coverage for cfe_es_start.c and cfe_es_syslog.c #1637

Merged
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
17 changes: 0 additions & 17 deletions modules/es/fsw/src/cfe_es_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,23 +263,6 @@ int32 CFE_ES_SysLogSetMode(CFE_ES_LogMode_Enum_t Mode);
*/
void CFE_ES_SysLog_vsnprintf(char *Buffer, size_t BufferSize, const char *SpecStringPtr, va_list ArgPtr);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Format a message intended for output to the system log
*
* Identical to the CFE_ES_SysLog_vsnprintf() call but with a variable argument set,
* for use in functions that need to directly handle a log message string.
*
* Similar in definition to the "snprintf()" C library call.
*
* \param Buffer User supplied buffer to output formatted sting into
* \param BufferSize Size of "Buffer" parameter. Should be greater than (CFE_TIME_PRINTED_STRING_SIZE+2)
* \param SpecStringPtr Printf-style format string
*
* \sa CFE_ES_SysLogAppend_Unsync()
*/
void CFE_ES_SysLog_snprintf(char *Buffer, size_t BufferSize, const char *SpecStringPtr, ...) OS_PRINTF(3, 4);

/*---------------------------------------------------------------------------------------*/
/**
* \brief Write the contents of the syslog to a disk file
Expand Down
17 changes: 0 additions & 17 deletions modules/es/fsw/src/cfe_es_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,23 +442,6 @@ void CFE_ES_SysLog_vsnprintf(char *Buffer, size_t BufferSize, const char *SpecSt
}
}

/*----------------------------------------------------------------
*
* Function: CFE_ES_SysLog_snprintf
*
* Application-scope internal function
* See description in header file for argument/return detail
*
*-----------------------------------------------------------------*/
void CFE_ES_SysLog_snprintf(char *Buffer, size_t BufferSize, const char *SpecStringPtr, ...)
{
va_list ArgPtr;

va_start(ArgPtr, SpecStringPtr);
CFE_ES_SysLog_vsnprintf(Buffer, BufferSize, SpecStringPtr, ArgPtr);
va_end(ArgPtr);
}

/*----------------------------------------------------------------
*
* Function: CFE_ES_SysLogDump
Expand Down
29 changes: 28 additions & 1 deletion modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,15 @@ void TestStartupErrorPaths(void)
UtAssert_STUB_COUNT(CFE_PSP_Panic, 1);
UtAssert_UINT32_EQ(PanicStatus, CFE_PSP_PANIC_STARTUP_SEM);

/* 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 @@ -926,6 +934,13 @@ void TestStartupErrorPaths(void)
CFE_UtAssert_PRINTF(UT_OSP_MESSAGES[UT_OSP_NO_FREE_CORE_APP_SLOTS]);
CFE_UtAssert_PRINTF(UT_OSP_MESSAGES[UT_OSP_FUNCTION_POINTER]);

/* Test reading the object table with unknown 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;
CFE_ES_CreateObjects();
CFE_UtAssert_PRINTF(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 Expand Up @@ -4829,6 +4844,18 @@ void TestSysLog(void)
CFE_UtAssert_MEMOFFSET_EQ(SysLogBuffer.BlockSize, 1);
UtAssert_ZERO(SysLogBuffer.SizeLeft);

/* Test case where calculated blocksize results in 0 */
ES_ResetUnitTest();
SysLogBuffer.EndIdx = 0;
SysLogBuffer.SizeLeft = 1;

CFE_ES_SysLogReadData(&SysLogBuffer);

UtAssert_UINT32_EQ(SysLogBuffer.EndIdx, 0);
CFE_UtAssert_MEMOFFSET_EQ(SysLogBuffer.LastOffset, 0);
CFE_UtAssert_MEMOFFSET_EQ(SysLogBuffer.BlockSize, 0);
UtAssert_INT32_EQ(SysLogBuffer.SizeLeft, 1);

/* Test nominal flow through CFE_ES_SysLogDump
* with multiple reads and writes */
ES_ResetUnitTest();
Expand Down