Skip to content

Commit

Permalink
Fix nasa#1009, Alignment pattern - unit tests
Browse files Browse the repository at this point in the history
- Replaced CFE_SB_SendMsg and CFE_SB_PassMsg with CFE_SB_TransmitMsg
- Replaced CFE_SB_ZeroCopySend and CFE_SB_ZeroCopyPass with
  CFE_SB_TransmitBuffer
- Replaced CFE_SB_RcvMsg with CFE_SB_ReceiveBuffer
- Used CFE_SB_Buffer_t and CFE_MSG_Message_t where appropriate
- Added Cmd to all command types
- Changed Syslog to SysLog for consistency
- Removed "see also" blocks in documentation, APIs are already grouped
  and these typically don't add anything useful (simplifies maintenance)
  • Loading branch information
skliper committed Nov 30, 2020
1 parent f2f7054 commit b8c07ea
Show file tree
Hide file tree
Showing 13 changed files with 726 additions and 951 deletions.
2 changes: 1 addition & 1 deletion fsw/cfe-core/unit-test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ foreach(MODULE ${CFE_CORE_MODULES})
${UT_COVERAGE_LINK_FLAGS}
ut_cfe-core_support
ut_cfe-core_stubs
sbr # TODO remove this
sbr # Will be removed when sbr stubs are implemented
ut_assert)

add_test(${UT_TARGET_NAME}_UT ${UT_TARGET_NAME}_UT)
Expand Down
231 changes: 116 additions & 115 deletions fsw/cfe-core/unit-test/es_UT.c

Large diffs are not rendered by default.

77 changes: 0 additions & 77 deletions fsw/cfe-core/unit-test/es_UT.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@
**
** \returns
** This function does not return a value.
**
** \sa #UT_Init, #UT_SetCDSSize, #UT_SetSizeofESResetArea
** \sa #UT_SetStatusBSPResetArea, #UT_SetReadBuffer, #UT_SetRtnCode
** \sa #UT_SetDummyFuncRtn, #UT_SetBSPloadAppFileResult, #CFE_ES_Main
** \sa #UT_Report
**
******************************************************************************/
void TestInit(void);

Expand All @@ -108,12 +102,6 @@ void TestInit(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_SetRtnCode, #UT_SetOSFail, #CFE_ES_Main, #UT_Report
** \sa #CFE_ES_SetupResetVariables, #UT_SetStatusBSPResetArea
** \sa #UT_SetSizeofESResetArea, #CFE_ES_InitializeFileSystems, #UT_SetBSPFail
** \sa #CFE_ES_CreateObjects
**
******************************************************************************/
void TestStartupErrorPaths(void);

Expand All @@ -132,14 +120,6 @@ void TestStartupErrorPaths(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_SetReadBuffer, #UT_SetRtnCode, #CFE_ES_StartApplications
** \sa #UT_Report, #UT_SetOSFail, #CFE_ES_ParseFileEntry
** \sa #UT_SetBSPloadAppFileResult, #CFE_ES_AppCreate, #UT_SetDummyFuncRtn
** \sa #CFE_ES_LoadLibrary, #CFE_ES_ScanAppTable, #CFE_ES_ProcessControlRequest
** \sa #CFE_ES_GetAppInfo, #CFE_ES_CleanUpApp
** \sa #CFE_ES_CleanupTaskResources
**
******************************************************************************/
void TestApps(void);

Expand All @@ -158,9 +138,6 @@ void TestApps(void);
**
** \returns
** This function does not return a value.
**
** \sa #CFE_ES_WriteToERLog, #UT_Report
**
******************************************************************************/
void TestERLog(void);

Expand All @@ -178,19 +155,6 @@ void TestERLog(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_SetRtnCode, #CFE_ES_TaskMain, #UT_Report, #UT_SetOSFail
** \sa #CFE_ES_TaskInit, #UT_SetSBTotalMsgLen, #UT_SendMsg
** \sa #UT_SetBSPloadAppFileResult, #UT_SetStatusBSPResetArea
** \sa #CFE_ES_HousekeepingCmd, #CFE_ES_NoopCmd, #CFE_ES_ResetCountersCmd
** \sa #CFE_ES_RestartCmd, #CFE_ES_StartAppCmd
** \sa #CFE_ES_StopAppCmd, #CFE_ES_RestartAppCmd, #CFE_ES_ReloadAppCmd
** \sa #CFE_ES_QueryOneCmd, #CFE_ES_QueryAllCmd, #CFE_ES_QueryAllTasksCmd
** \sa #CFE_ES_ClearSyslogCmd, #CFE_ES_OverWriteSyslogCmd
** \sa #CFE_ES_WriteSyslogCmd, #CFE_ES_ClearERLogCmd, #CFE_ES_WriteERLogCmd
** \sa #CFE_ES_ResetPRCountCmd, #CFE_ES_SetMaxPRCountCmd, #CFE_ES_DeleteCDSCmd
** \sa #CFE_ES_DumpCDSRegistryCmd, #CFE_ES_SendMemPoolStatsCmd, #CFE_ES_TaskPipe
**
******************************************************************************/
void TestTask(void);

Expand All @@ -207,7 +171,6 @@ void TestTask(void);
**
** \returns
** This function does not return a value.
**
******************************************************************************/
void TestBackground(void);

Expand All @@ -224,13 +187,6 @@ void TestBackground(void);
**
** \returns
** This function does not return a value.
**
** \sa #CFE_ES_SetupPerfVariables, #UT_Report, #UT_SetRtnCode
** \sa #UT_SetSBTotalMsgLen, #UT_SendMsg, #UT_SetBSPloadAppFileResult
** \sa #CFE_ES_PerfLogDump, #CFE_ES_PerfLogAdd, #CFE_ES_StartPerfDataCmd
** \sa #CFE_ES_StopPerfDataCmd, #CFE_ES_SetPerfFilterMaskCmd
** \sa #CFE_ES_SetPerfTriggerMaskCmd, #CFE_ES_PerfLogDump, #CFE_ES_PerfLogAdd
**
******************************************************************************/
void TestPerf(void);

Expand All @@ -246,20 +202,6 @@ void TestPerf(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_SetRtnCode, #CFE_ES_ResetCFE, #UT_Report
** \sa #CFE_ES_GetResetType, #CFE_ES_RestartApp, #CFE_ES_ReloadApp
** \sa #CFE_ES_DeleteApp, #CFE_ES_ExitApp, #CFE_ES_RunLoop
** \sa #CFE_ES_RegisterApp, #CFE_ES_GetAppID, #CFE_ES_GetAppName
** \sa #CFE_ES_GetTaskInfo, #CFE_ES_CreateChildTask, #CFE_ES_DeleteChildTask
** \sa #CFE_ES_ExitChildTask, #CFE_ES_RegisterChildTask, #CFE_ES_WriteToSysLog
** \sa #CFE_ES_CalculateCRC, #CFE_ES_WaitForStartupSync, #CFE_ES_ProcessCoreException
** \sa #UT_SetBSPFail, #CFE_ES_RegisterCDS, #CFE_ES_CopyToCDS
** \sa #CFE_ES_RestoreFromCDS, #CFE_ES_LockSharedData, #CFE_ES_UnlockSharedData
** \sa #CFE_ES_RegisterGenCounter, #CFE_ES_GetGenCounterIDByName
** \sa #CFE_ES_DeleteGenCounter, #CFE_ES_IncrementGenCounter
** \sa #CFE_ES_GetGenCount, #CFE_ES_SetGenCount
**
******************************************************************************/
void TestAPI(void);

Expand All @@ -276,13 +218,6 @@ void TestAPI(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_InitData, #UT_Report, #CFE_ES_CDS_ValidateAppID
** \sa #UT_SetBSPFail, #CFE_ES_RebuildCDS, #UT_SetRtnCode
** \sa #CFE_ES_InitCDSRegistry, #UT_SetCDSSize, #CFE_ES_CDS_EarlyInit
** \sa #UT_SetCDSBSPCheckValidity, #CFE_ES_ValidateCDS, #UT_SetCDSReadGoodEnd
** \sa #CFE_ES_InitCDSSignatures, #CFE_ES_RebuildCDS, #CFE_ES_DeleteCDS
**
******************************************************************************/
void TestCDS(void);

Expand All @@ -300,12 +235,6 @@ void TestCDS(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_InitData, #UT_Report, #CFE_ES_CreateCDSPool
** \sa #CFE_ES_RebuildCDSPool, #UT_SetRtnCode, #UT_SetBSPFail
** \sa #CFE_ES_GetCDSBlock, #CFE_ES_PutCDSBlock, #CFE_ES_CDSBlockWrite
** \sa #CFE_ES_CDSBlockRead
**
******************************************************************************/
void TestCDSMempool(void);

Expand All @@ -323,12 +252,6 @@ void TestCDSMempool(void);
**
** \returns
** This function does not return a value.
**
** \sa #UT_InitData, #UT_Report, #CFE_ES_PoolCreateNoSem
** \sa #CFE_ES_PoolCreate, #CFE_ES_GetPoolBuf, #CFE_ES_GetPoolBufInfo
** \sa #CFE_ES_PutPoolBuf, #CFE_ES_ValidateHandle, #UT_SetRtnCode
** \sa #CFE_ES_GetMemPoolStats, #CFE_ES_PoolCreateEx, #CFE_ES_PoolCreateNoSem
**
******************************************************************************/
void TestESMempool(void);

Expand Down
42 changes: 21 additions & 21 deletions fsw/cfe-core/unit-test/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,12 +231,12 @@ static void UT_EVS_DoDispatchCheckEvents_Impl(void *MsgPtr, uint32 MsgSize,
EventCapture->EventID = 0xFFFF;
SnapshotData.SnapshotBuffer = &EventCapture->EventID;

UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &SnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &SnapshotData);
UT_CallTaskPipe(CFE_EVS_ProcessCommandPacket, (CFE_MSG_Message_t *)MsgPtr, MsgSize, DispatchId);
EventCapture->Count += SnapshotData.Count;

/* be sure to clear the hook function since the SnapshotData is going out of scope */
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), NULL, NULL);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), NULL, NULL);
}

static void UT_EVS_DoDispatchCheckEvents(void *MsgPtr, uint32 MsgSize,
Expand All @@ -258,12 +258,12 @@ static void UT_EVS_DoGenericCheckEvents(void (*Func)(void), UT_EVS_EventCapture_
EventCapture->EventID = -1;
SnapshotData.SnapshotBuffer = &EventCapture->EventID;

UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &SnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &SnapshotData);
Func();
EventCapture->Count += SnapshotData.Count;

/* be sure to clear the hook function since the SnapshotData is going out of scope */
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), NULL, NULL);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), NULL, NULL);
}

/*
Expand Down Expand Up @@ -910,7 +910,7 @@ void Test_Format(void)
int16 EventID[2];

CFE_TIME_SysTime_t time = {0, 0};
CFE_EVS_SetEventFormatMode_t modecmd;
CFE_EVS_SetEventFormatModeCmd_t modecmd;
CFE_EVS_AppNameBitMaskCmd_t appbitcmd;
CFE_EVS_PacketID_t CapturedMsg;
UT_SoftwareBusSnapshot_Entry_t LongFmtSnapshotData =
Expand Down Expand Up @@ -981,12 +981,12 @@ void Test_Format(void)
UtPrintf("Test for short event sent when configured to do so ");
UT_InitData();
UT_SetHookFunction(UT_KEY(CFE_MSG_Init), UT_EVS_MSGInitHook, &MsgData);
UT_SetDataBuffer(UT_KEY(CFE_SB_SendMsg), &MsgSend, sizeof(MsgSend), false);
UT_SetDataBuffer(UT_KEY(CFE_SB_TransmitMsg), &MsgSend, sizeof(MsgSend), false);
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Short format check 1");

/* Note implementation initializes both short and long message */
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_Init)), 2);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_SB_SendMsg)), 1);
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1);
ASSERT_TRUE(CFE_SB_MsgId_Equal(MsgData.MsgId, ShortFmtSnapshotData.MsgId));
ASSERT_TRUE(!CFE_SB_MsgId_Equal(MsgData.MsgId, LongFmtSnapshotData.MsgId));

Expand All @@ -1011,7 +1011,7 @@ void Test_Format(void)
*/
UT_InitData();
memset(&CapturedMsg, 0xFF, sizeof(CapturedMsg));
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &LongFmtSnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &LongFmtSnapshotData);
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Long format check (SendEvent)");
EventID[0] = CapturedMsg.EventID;
memset(&CapturedMsg, 0xFF, sizeof(CapturedMsg));
Expand Down Expand Up @@ -1098,7 +1098,7 @@ void Test_Ports(void)

/* Test that ports are enabled by sending a message */
UT_InitData();
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Test ports message");
UT_Report(__FILE__, __LINE__,
LocalSnapshotData.Count == 1 &&
Expand Down Expand Up @@ -1216,9 +1216,9 @@ void Test_Logging(void)
char tmpString[100];
union
{
CFE_EVS_NoArgsCmd_t cmd;
CFE_EVS_SetLogMode_t modecmd;
CFE_EVS_WriteLogDataFile_t logfilecmd;
CFE_EVS_NoArgsCmd_t cmd;
CFE_EVS_SetLogModeCmd_t modecmd;
CFE_EVS_WriteLogDataFileCmd_t logfilecmd;
} CmdBuf;
cpuaddr TempAddr;
CFE_ES_ResetData_t *CFE_EVS_ResetDataPtr;
Expand Down Expand Up @@ -1432,9 +1432,9 @@ void Test_WriteApp(void)
{
union
{
CFE_EVS_NoArgsCmd_t cmd;
CFE_EVS_WriteAppDataFile_t AppDataCmd;
CFE_EVS_AppNameBitMaskCmd_t appbitcmd;
CFE_EVS_NoArgsCmd_t cmd;
CFE_EVS_WriteAppDataFileCmd_t AppDataCmd;
CFE_EVS_AppNameBitMaskCmd_t appbitcmd;
} CmdBuf;

UtPrintf("Begin Test Write App");
Expand Down Expand Up @@ -1964,7 +1964,7 @@ void Test_EventCmd(void)
&UT_EVS_EventBuf);

LocalSnapshotData.Count = 0;
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
CFE_EVS_SendEvent(0, CFE_EVS_EventType_DEBUG, "FAIL : Debug message disabled");
EventCount[0] = LocalSnapshotData.Count;
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "FAIL : Info message disabled");
Expand All @@ -1986,7 +1986,7 @@ void Test_EventCmd(void)
UT_EVS_DoDispatchCheckEvents(&appbitcmd, sizeof(appbitcmd),
UT_TPID_CFE_EVS_CMD_ENABLE_APP_EVENT_TYPE_CC,
&UT_EVS_EventBuf);
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &LocalSnapshotData);
CFE_EVS_SendEvent(0, CFE_EVS_EventType_DEBUG, "Debug message enabled");
EventCount[0] = LocalSnapshotData.Count;
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Info message enabled");
Expand Down Expand Up @@ -2666,8 +2666,8 @@ void Test_Misc(void)
{
CFE_MSG_Message_t msg;
CFE_EVS_NoArgsCmd_t cmd;
CFE_EVS_SetLogMode_t modecmd;
CFE_EVS_WriteLogDataFile_t writelogdatacmd;
CFE_EVS_SetLogModeCmd_t modecmd;
CFE_EVS_WriteLogDataFileCmd_t writelogdatacmd;
} PktBuf;

CFE_ES_ResourceID_t AppID;
Expand Down Expand Up @@ -2711,7 +2711,7 @@ void Test_Misc(void)
UT_InitData();
CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = true;
HK_SnapshotData.Count = 0;
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &HK_SnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &HK_SnapshotData);
UT_CallTaskPipe(CFE_EVS_ProcessCommandPacket, &PktBuf.msg, sizeof(PktBuf.cmd),
UT_TPID_CFE_EVS_SEND_HK);
UT_Report(__FILE__, __LINE__,
Expand All @@ -2737,7 +2737,7 @@ void Test_Misc(void)
UT_InitData();
CFE_EVS_GlobalData.EVS_TlmPkt.Payload.LogEnabled = false;
HK_SnapshotData.Count = 0;
UT_SetHookFunction(UT_KEY(CFE_SB_SendMsg), UT_SoftwareBusSnapshotHook, &HK_SnapshotData);
UT_SetHookFunction(UT_KEY(CFE_SB_TransmitMsg), UT_SoftwareBusSnapshotHook, &HK_SnapshotData);
UT_CallTaskPipe(CFE_EVS_ProcessCommandPacket, &PktBuf.msg, sizeof(PktBuf.cmd),
UT_TPID_CFE_EVS_SEND_HK);
UT_Report(__FILE__, __LINE__,
Expand Down
Loading

0 comments on commit b8c07ea

Please sign in to comment.