diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 45153fd92..479bb03c4 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -83,18 +83,18 @@ jobs: - name: Test run: | lcov --capture --initial --directory build --output-file coverage_base.info - make -C build/native/default_cpu1/config test - make -C build/native/default_cpu1/core_api test - make -C build/native/default_cpu1/core_private test - make -C build/native/default_cpu1/es test - make -C build/native/default_cpu1/evs test - make -C build/native/default_cpu1/fs test - make -C build/native/default_cpu1/msg test - make -C build/native/default_cpu1/resourceid test - make -C build/native/default_cpu1/sb test - make -C build/native/default_cpu1/sbr test - make -C build/native/default_cpu1/tbl test - make -C build/native/default_cpu1/time test + (cd build/native/default_cpu1/config && ctest --output-on-failure) + (cd build/native/default_cpu1/core_api && ctest --output-on-failure) + (cd build/native/default_cpu1/core_private && ctest --output-on-failure) + (cd build/native/default_cpu1/es && ctest --output-on-failure) + (cd build/native/default_cpu1/evs && ctest --output-on-failure) + (cd build/native/default_cpu1/fs && ctest --output-on-failure) + (cd build/native/default_cpu1/msg && ctest --output-on-failure) + (cd build/native/default_cpu1/resourceid && ctest --output-on-failure) + (cd build/native/default_cpu1/sb && ctest --output-on-failure) + (cd build/native/default_cpu1/sbr && ctest --output-on-failure) + (cd build/native/default_cpu1/tbl && ctest --output-on-failure) + (cd build/native/default_cpu1/time && ctest --output-on-failure) - name: Calculate Coverage run: | diff --git a/CHANGELOG.md b/CHANGELOG.md index b2ac3cefa..7c206f34c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## Development Build: v7.0.0-rc4+dev424 +- Add perfid limit info to ES docstring +- TBL UT update for OSAL/CFE path length mismatch +- add multi threaded SB perf tests +- message integrity API +- change workflow to use output on failure option +- See , , , , and + ## Development Build: v7.0.0-rc4+dev411 - rename reference table - Remove nonexist reference for perf tool diff --git a/modules/cfe_testcase/src/sb_performance_test.c b/modules/cfe_testcase/src/sb_performance_test.c index 25f86ef44..c24e9f61d 100644 --- a/modules/cfe_testcase/src/sb_performance_test.c +++ b/modules/cfe_testcase/src/sb_performance_test.c @@ -33,6 +33,9 @@ #include "cfe_msgids.h" #include "cfe_test_msgids.h" +/* Number of messages to send during test */ +uint32_t UT_BulkTestDuration = 1000; + /* A simple command message */ typedef struct { @@ -47,6 +50,26 @@ typedef struct uint32 TlmPayload; } CFE_FT_TestTlmMessage_t; +/* State structure for multicore test - shared between threads */ +typedef struct UT_BulkMultiCoreSharedState +{ + volatile bool XmitFinished; + volatile bool RecvFinished; + + CFE_ES_TaskId_t TaskIdXmit; + CFE_ES_TaskId_t TaskIdRecv; + CFE_SB_PipeId_t PipeId; + osal_id_t SyncSem; + uint32 SendCount; + uint32 RecvCount; + OS_time_t StartTime; + OS_time_t EndTime; + +} UT_BulkMultiCoreSharedState_t; + +UT_BulkMultiCoreSharedState_t BulkCmd; +UT_BulkMultiCoreSharedState_t BulkTlm; + /* * This test procedure should be agnostic to specific MID values, but it should * not overlap/interfere with real MIDs used by other apps. @@ -54,7 +77,7 @@ typedef struct static const CFE_SB_MsgId_t CFE_FT_CMD_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_CMD_MID); static const CFE_SB_MsgId_t CFE_FT_TLM_MSGID = CFE_SB_MSGID_WRAP_VALUE(CFE_TEST_HK_TLM_MID); -void TestBulkTransmitRecv(void) +void TestBulkTransferSingle(void) { CFE_SB_PipeId_t PipeId1 = CFE_SB_INVALID_PIPE; CFE_SB_PipeId_t PipeId2 = CFE_SB_INVALID_PIPE; @@ -66,12 +89,20 @@ void TestBulkTransmitRecv(void) uint32 SendCount; OS_time_t StartTime; OS_time_t ElapsedTime; + int64 AvgRate; + uint32_t PrintMask; memset(&CmdMsg, 0, sizeof(CmdMsg)); memset(&TlmMsg, 0, sizeof(TlmMsg)); - UtPrintf("Testing: Bulk SB Transmit/Receive"); - CFE_PSP_GetTime(&StartTime); + PrintMask = UT_BulkTestDuration >> 4; + PrintMask |= PrintMask >> 1; + PrintMask |= PrintMask >> 2; + PrintMask |= PrintMask >> 4; + PrintMask |= PrintMask >> 8; + PrintMask |= PrintMask >> 16; + + UtPrintf("Testing: Single Threaded Bulk SB Transmit/Receive"); /* Setup, create a pipe and subscribe (one cmd, one tlm) */ UtAssert_INT32_EQ(CFE_SB_CreatePipe(&PipeId1, 5, "TestPipe1"), CFE_SUCCESS); @@ -83,7 +114,9 @@ void TestBulkTransmitRecv(void) UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(CmdMsg.CommandHeader), CFE_FT_CMD_MSGID, sizeof(CmdMsg)), CFE_SUCCESS); UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(TlmMsg.TelemetryHeader), CFE_FT_TLM_MSGID, sizeof(TlmMsg)), CFE_SUCCESS); - for (SendCount = 0; SendCount < 1000000; ++SendCount) + CFE_PSP_GetTime(&StartTime); + + for (SendCount = 0; SendCount < UT_BulkTestDuration; ++SendCount) { CmdMsg.CmdPayload = SendCount; TlmMsg.TlmPayload = ~SendCount; @@ -129,7 +162,7 @@ void TestBulkTransmitRecv(void) } /* report progress periodically */ - if ((SendCount % 50000) == 0) + if ((SendCount & PrintMask) == 0) { UtPrintf("Success after %lu messages", (unsigned long)SendCount); } @@ -140,9 +173,449 @@ void TestBulkTransmitRecv(void) UtAssert_MIR("Elapsed time for SB bulk message test: %lu usec", (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + /* Note that in this test, each iteration sends and recvs TWO messages */ + AvgRate = OS_TimeGetTotalMilliseconds(ElapsedTime); + AvgRate = ((int64)SendCount * 20000) / AvgRate; + + UtAssert_MIR("Message Rate: %ld.%01ld messages/sec", (long)(AvgRate / 10), (long)(AvgRate % 10)); + + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId1), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(PipeId2), CFE_SUCCESS); +} + +void RunSingleCmdSendRecv(void) +{ + CFE_FT_TestCmdMessage_t CmdMsg; + CFE_SB_Buffer_t * MsgBuf; + const CFE_FT_TestCmdMessage_t *CmdPtr; + + UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(CmdMsg.CommandHeader), CFE_FT_CMD_MSGID, sizeof(CmdMsg)), CFE_SUCCESS); + + CFE_PSP_GetTime(&BulkCmd.StartTime); + + while (BulkCmd.SendCount < UT_BulkTestDuration) + { + CmdMsg.CmdPayload = BulkCmd.SendCount; + + /* In order to not "flood" with test results, this should be silent unless a failure occurs */ + CFE_Assert_STATUS_STORE(CFE_SB_TransmitMsg(CFE_MSG_PTR(CmdMsg.CommandHeader), true)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + break; + } + + ++BulkCmd.SendCount; + + CFE_Assert_STATUS_STORE(CFE_SB_ReceiveBuffer(&MsgBuf, BulkCmd.PipeId, CFE_SB_POLL)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + break; + } + + ++BulkCmd.RecvCount; + + /* As above, to avoid flooding of test cases, only report mismatch here */ + CmdPtr = (const void *)MsgBuf; + if (CmdPtr->CmdPayload != CmdMsg.CmdPayload) + { + UtAssert_UINT32_EQ(CmdPtr->CmdPayload, CmdMsg.CmdPayload); + break; + } + } + + CFE_PSP_GetTime(&BulkCmd.EndTime); + + BulkCmd.XmitFinished = true; + BulkCmd.RecvFinished = true; +} + +void RunSingleTlmSendRecv(void) +{ + CFE_FT_TestTlmMessage_t TlmMsg; + CFE_SB_Buffer_t * MsgBuf; + const CFE_FT_TestTlmMessage_t *TlmPtr; + + UtAssert_INT32_EQ(CFE_MSG_Init(CFE_MSG_PTR(TlmMsg.TelemetryHeader), CFE_FT_TLM_MSGID, sizeof(TlmMsg)), CFE_SUCCESS); + + CFE_PSP_GetTime(&BulkTlm.StartTime); + + while (BulkTlm.SendCount < UT_BulkTestDuration) + { + TlmMsg.TlmPayload = BulkTlm.SendCount; + + /* In order to not "flood" with test results, this should be silent unless a failure occurs */ + CFE_Assert_STATUS_STORE(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmMsg.TelemetryHeader), true)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + break; + } + + ++BulkTlm.SendCount; + + CFE_Assert_STATUS_STORE(CFE_SB_ReceiveBuffer(&MsgBuf, BulkTlm.PipeId, CFE_SB_POLL)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + break; + } + + ++BulkTlm.RecvCount; + + /* As above, to avoid flooding of test cases, only report mismatch here */ + TlmPtr = (const void *)MsgBuf; + if (TlmPtr->TlmPayload != TlmMsg.TlmPayload) + { + UtAssert_UINT32_EQ(TlmPtr->TlmPayload, TlmMsg.TlmPayload); + break; + } + } + + CFE_PSP_GetTime(&BulkTlm.EndTime); + + BulkTlm.XmitFinished = true; + BulkTlm.RecvFinished = true; +} + +OS_time_t UT_GetTotalElapsedTime(void) +{ + OS_time_t StartTime; + OS_time_t EndTime; + + /* + * Computing the average message rate is the total number of messages passed in ALL threads, + * divided by the time elapsed by ALL threads, which is the difference between the first + * thread to start and the last thread to finish. + * + * Note that the two threads have equal priority and no blocking/yielding in either, so it is + * possible based on OS scheduler that one thread runs entirely to completion before the second + * thread even starts running. + */ + if (OS_TimeGetTotalNanoseconds(OS_TimeSubtract(BulkCmd.StartTime, BulkTlm.StartTime)) < 0) + { + /* This means BulkCmd started first */ + StartTime = BulkCmd.StartTime; + } + else + { + /* This means BulkTlm started first */ + StartTime = BulkTlm.StartTime; + } + + if (OS_TimeGetTotalNanoseconds(OS_TimeSubtract(BulkCmd.EndTime, BulkTlm.EndTime)) < 0) + { + /* This means BulkTlm ended last */ + EndTime = BulkTlm.EndTime; + } + else + { + /* This means BulkCmd ended last */ + EndTime = BulkCmd.EndTime; + } + + return OS_TimeSubtract(EndTime, StartTime); +} + +void TestBulkTransferMulti2(void) +{ + OS_time_t ElapsedTime; + int64 AvgRate; + + UtPrintf("Testing: 2 Thread Bulk SB Transmit/Receive without Sync Sem"); + memset(&BulkCmd, 0, sizeof(BulkCmd)); + memset(&BulkTlm, 0, sizeof(BulkCmd)); + + /* Setup, create a pipe and subscribe (one cmd, one tlm) */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&BulkCmd.PipeId, 5, "CmdPipe"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&BulkTlm.PipeId, 5, "TlmPipe"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, BulkCmd.PipeId, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_TLM_MSGID, BulkTlm.PipeId, CFE_SB_DEFAULT_QOS, 3), CFE_SUCCESS); + + UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&BulkCmd.TaskIdXmit, "CmdXmit", RunSingleCmdSendRecv, NULL, 32768, 150, 0), + CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_ES_CreateChildTask(&BulkTlm.TaskIdXmit, "TlmXmit", RunSingleTlmSendRecv, NULL, 32768, 150, 0), + CFE_SUCCESS); + + do + { + OS_TaskDelay(1000); + UtPrintf("Counts => %lu/%lu CMD, %lu/%lu TLM", (unsigned long)BulkCmd.SendCount, + (unsigned long)BulkCmd.RecvCount, (unsigned long)BulkTlm.SendCount, (unsigned long)BulkTlm.RecvCount); + } while (!BulkCmd.XmitFinished || !BulkCmd.RecvFinished || !BulkTlm.XmitFinished || !BulkTlm.RecvFinished); + + ElapsedTime = OS_TimeSubtract(BulkCmd.EndTime, BulkCmd.StartTime); + UtAssert_MIR("Elapsed time for SB bulk CMD thread: %lu usec", + (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + ElapsedTime = OS_TimeSubtract(BulkTlm.EndTime, BulkTlm.StartTime); + UtAssert_MIR("Elapsed time for SB bulk TLM thread: %lu usec", + (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + ElapsedTime = UT_GetTotalElapsedTime(); + UtAssert_MIR("Elapsed time for all threads: %lu usec", (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + /* The message rate is the total number of messages processed over the total time elapsed */ + AvgRate = OS_TimeGetTotalMilliseconds(ElapsedTime); + if (AvgRate > 0) + { + AvgRate = ((int64)(BulkCmd.RecvCount + BulkTlm.RecvCount) * 10000) / AvgRate; + UtAssert_MIR("Message Rate: %ld.%01ld messages/sec", (long)(AvgRate / 10), (long)(AvgRate % 10)); + } + else + { + /* If the entire test took less than a millisecond, then there is a config error */ + UtAssert_Failed("Test configuration error: Executed too fast, needs more cycles!"); + } + + UtAssert_INT32_EQ(CFE_SB_DeletePipe(BulkCmd.PipeId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(BulkTlm.PipeId), CFE_SUCCESS); +} + +void UT_CommandTransmitterTask(void) +{ + CFE_SB_Buffer_t * BufPtr; + CFE_FT_TestCmdMessage_t *CmdMsgPtr; + + CFE_PSP_GetTime(&BulkCmd.StartTime); + + for (BulkCmd.SendCount = 0; BulkCmd.SendCount < UT_BulkTestDuration; ++BulkCmd.SendCount) + { + CFE_Assert_STATUS_STORE(OS_CountSemTake(BulkCmd.SyncSem)); + if (!CFE_Assert_STATUS_SILENTCHECK(OS_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(OS_SUCCESS); + break; + } + + BufPtr = CFE_SB_AllocateMessageBuffer(sizeof(CFE_FT_TestCmdMessage_t)); + + CmdMsgPtr = (void *)&BufPtr->Msg; + + /* Initialize the message content */ + CFE_MSG_Init(CFE_MSG_PTR(CmdMsgPtr->CommandHeader), CFE_FT_CMD_MSGID, sizeof(*CmdMsgPtr)); + + CmdMsgPtr->CmdPayload = BulkCmd.SendCount; + + CFE_Assert_STATUS_STORE(CFE_SB_TransmitBuffer(BufPtr, true)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); + break; + } + } + + BulkCmd.XmitFinished = true; +} + +void UT_TelemtryTransmitterTask(void) +{ + CFE_SB_Buffer_t * BufPtr; + CFE_FT_TestTlmMessage_t *TlmMsgPtr; + + CFE_PSP_GetTime(&BulkTlm.StartTime); + + for (BulkTlm.SendCount = 0; BulkTlm.SendCount < UT_BulkTestDuration; ++BulkTlm.SendCount) + { + CFE_Assert_STATUS_STORE(OS_CountSemTake(BulkTlm.SyncSem)); + if (!CFE_Assert_STATUS_SILENTCHECK(OS_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(OS_SUCCESS); + break; + } + + BufPtr = CFE_SB_AllocateMessageBuffer(sizeof(CFE_FT_TestTlmMessage_t)); + + TlmMsgPtr = (void *)&BufPtr->Msg; + + /* Initialize the message content */ + CFE_MSG_Init(CFE_MSG_PTR(TlmMsgPtr->TelemetryHeader), CFE_FT_TLM_MSGID, sizeof(*TlmMsgPtr)); + + TlmMsgPtr->TlmPayload = BulkTlm.SendCount; + + CFE_Assert_STATUS_STORE(CFE_SB_TransmitBuffer(BufPtr, true)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); + break; + } + } + + BulkTlm.XmitFinished = true; +} + +void UT_CommandReceiverTask(void) +{ + CFE_SB_Buffer_t * MsgBuf; + const CFE_FT_TestCmdMessage_t *CmdPtr; + + for (BulkCmd.RecvCount = 0; BulkCmd.RecvCount < UT_BulkTestDuration; ++BulkCmd.RecvCount) + { + CFE_Assert_STATUS_STORE(CFE_SB_ReceiveBuffer(&MsgBuf, BulkCmd.PipeId, 5000)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); + break; + } + + /* As above, to avoid flooding of test cases, only report mismatch here */ + CmdPtr = (const void *)MsgBuf; + if (CmdPtr->CmdPayload != BulkCmd.RecvCount) + { + UtAssert_UINT32_EQ(CmdPtr->CmdPayload, BulkCmd.RecvCount); + break; + } + + CFE_Assert_STATUS_STORE(OS_CountSemGive(BulkCmd.SyncSem)); + if (!CFE_Assert_STATUS_SILENTCHECK(OS_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(OS_SUCCESS); + break; + } + } + + CFE_PSP_GetTime(&BulkCmd.EndTime); + BulkCmd.RecvFinished = true; +} + +void UT_TelemetryReceiverTask(void) +{ + CFE_SB_Buffer_t * MsgBuf; + const CFE_FT_TestTlmMessage_t *TlmPtr; + + for (BulkTlm.RecvCount = 0; BulkTlm.RecvCount < UT_BulkTestDuration; ++BulkTlm.RecvCount) + { + CFE_Assert_STATUS_STORE(CFE_SB_ReceiveBuffer(&MsgBuf, BulkTlm.PipeId, 5000)); + if (!CFE_Assert_STATUS_SILENTCHECK(CFE_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(CFE_SUCCESS); + break; + } + + /* As above, to avoid flooding of test cases, only report mismatch here */ + TlmPtr = (const void *)MsgBuf; + if (TlmPtr->TlmPayload != BulkTlm.RecvCount) + { + UtAssert_UINT32_EQ(TlmPtr->TlmPayload, BulkTlm.RecvCount); + break; + } + + CFE_Assert_STATUS_STORE(OS_CountSemGive(BulkTlm.SyncSem)); + if (!CFE_Assert_STATUS_SILENTCHECK(OS_SUCCESS)) + { + CFE_Assert_STATUS_MUST_BE(OS_SUCCESS); + break; + } + } + + CFE_PSP_GetTime(&BulkTlm.EndTime); + BulkTlm.RecvFinished = true; +} + +void TestBulkTransferMulti4(void) +{ + uint32 i; + OS_time_t ElapsedTime; + int64 AvgRate; + + UtPrintf("Testing: 4 Thread Bulk SB Transmit/Receive with Sync Sem"); + memset(&BulkCmd, 0, sizeof(BulkCmd)); + memset(&BulkTlm, 0, sizeof(BulkCmd)); + + /* Setup, create a pipe and subscribe (one cmd, one tlm) */ + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&BulkCmd.PipeId, 10, "TestPipe1"), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_CreatePipe(&BulkTlm.PipeId, 10, "TestPipe2"), CFE_SUCCESS); + + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_CMD_MSGID, BulkCmd.PipeId, CFE_SB_DEFAULT_QOS, 8), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_SubscribeEx(CFE_FT_TLM_MSGID, BulkTlm.PipeId, CFE_SB_DEFAULT_QOS, 8), CFE_SUCCESS); + + UtAssert_INT32_EQ(OS_CountSemCreate(&BulkCmd.SyncSem, "CmdSem", 0, 0), OS_SUCCESS); + UtAssert_INT32_EQ(OS_CountSemCreate(&BulkTlm.SyncSem, "TlmSem", 0, 0), OS_SUCCESS); + + UtAssert_INT32_EQ( + CFE_ES_CreateChildTask(&BulkCmd.TaskIdXmit, "CmdXmit", UT_CommandTransmitterTask, NULL, 32768, 150, 0), + CFE_SUCCESS); + UtAssert_INT32_EQ( + CFE_ES_CreateChildTask(&BulkTlm.TaskIdXmit, "TlmXmit", UT_TelemtryTransmitterTask, NULL, 32768, 150, 0), + CFE_SUCCESS); + UtAssert_INT32_EQ( + CFE_ES_CreateChildTask(&BulkCmd.TaskIdRecv, "CmdRecv", UT_CommandReceiverTask, NULL, 32768, 100, 0), + CFE_SUCCESS); + UtAssert_INT32_EQ( + CFE_ES_CreateChildTask(&BulkTlm.TaskIdRecv, "TlmRecv", UT_TelemetryReceiverTask, NULL, 32768, 100, 0), + CFE_SUCCESS); + + /* Let all tasks start and pend on sem */ + OS_TaskDelay(500); + + /* Give sem several times each to get a pipeline going, but do not exceed msglim of 8 */ + for (i = 0; i < 8; ++i) + { + UtAssert_INT32_EQ(OS_CountSemGive(BulkCmd.SyncSem), OS_SUCCESS); + UtAssert_INT32_EQ(OS_CountSemGive(BulkTlm.SyncSem), OS_SUCCESS); + } + + do + { + OS_TaskDelay(1000); + UtPrintf("Counts => %lu/%lu CMD, %lu/%lu TLM", (unsigned long)BulkCmd.SendCount, + (unsigned long)BulkCmd.RecvCount, (unsigned long)BulkTlm.SendCount, (unsigned long)BulkTlm.RecvCount); + } while (!BulkCmd.XmitFinished || !BulkCmd.RecvFinished || !BulkTlm.XmitFinished || !BulkTlm.RecvFinished); + + ElapsedTime = OS_TimeSubtract(BulkCmd.EndTime, BulkCmd.StartTime); + UtAssert_MIR("Elapsed time for SB bulk CMD thread: %lu usec", + (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + ElapsedTime = OS_TimeSubtract(BulkTlm.EndTime, BulkCmd.StartTime); + UtAssert_MIR("Elapsed time for SB bulk TLM thread: %lu usec", + (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + ElapsedTime = UT_GetTotalElapsedTime(); + UtAssert_MIR("Elapsed time for all threads: %lu usec", (unsigned long)OS_TimeGetTotalMicroseconds(ElapsedTime)); + + /* The message rate is the total number of messages processed over the total time elapsed */ + AvgRate = OS_TimeGetTotalMilliseconds(ElapsedTime); + if (AvgRate > 0) + { + AvgRate = ((int64)(BulkCmd.RecvCount + BulkTlm.RecvCount) * 10000) / AvgRate; + UtAssert_MIR("Message Rate: %ld.%01ld messages/sec", (long)(AvgRate / 10), (long)(AvgRate % 10)); + } + else + { + /* If the entire test took less than a millisecond, then there is a config error */ + UtAssert_Failed("Test configuration error: Executed too fast, needs more cycles!"); + } + + /* Child tasks should have self-exited... */ + UtAssert_INT32_EQ(CFE_SB_DeletePipe(BulkCmd.PipeId), CFE_SUCCESS); + UtAssert_INT32_EQ(CFE_SB_DeletePipe(BulkTlm.PipeId), CFE_SUCCESS); + UtAssert_INT32_EQ(OS_CountSemDelete(BulkCmd.SyncSem), OS_SUCCESS); + UtAssert_INT32_EQ(OS_CountSemDelete(BulkTlm.SyncSem), OS_SUCCESS); } void SBPerformanceTestSetup(void) { - UtTest_Add(TestBulkTransmitRecv, NULL, NULL, "Test Bulk SB Transmit/Receive"); + long i; + OS_time_t clock_start; + OS_time_t clock_now; + + i = 0; + CFE_PSP_GetTime(&clock_start); + do + { + ++i; + CFE_PSP_GetTime(&clock_now); + } while (OS_TimeGetTotalMilliseconds(OS_TimeSubtract(clock_now, clock_start)) < 100); + + UtAssert_MIR("Local CPU speed loop count=%ld", i); + + while (i > 0) + { + i /= 5; + UT_BulkTestDuration *= 2; + } + + UtAssert_MIR("Configured to execute %lu message transfers", (unsigned long)UT_BulkTestDuration); + + UtTest_Add(TestBulkTransferSingle, NULL, NULL, "Single Thread Bulk Transfer"); + UtTest_Add(TestBulkTransferMulti2, NULL, NULL, "2 Thread Bulk Transfer"); + UtTest_Add(TestBulkTransferMulti4, NULL, NULL, "4 Thread Bulk Transfer"); } diff --git a/modules/cfe_testcase/src/sb_sendrecv_test.c b/modules/cfe_testcase/src/sb_sendrecv_test.c index 4f8be7ac2..3ba2cf747 100644 --- a/modules/cfe_testcase/src/sb_sendrecv_test.c +++ b/modules/cfe_testcase/src/sb_sendrecv_test.c @@ -145,7 +145,7 @@ void TestBasicTransmitRecv(void) UtAssert_INT32_EQ(CFE_SB_ReceiveBuffer(&MsgBuf, PipeId1, -100), CFE_SB_BAD_ARGUMENT); /* - * Note, the CFE_SB_TransmitMsg now adheres to the "UpdateHeader" flag. + * Note, the CFE_SB_TransmitMsg now adheres to the "IsOrigination" flag. * Thus, the sequence numbers should come back with the value from the Route (1-2) * rather than the value the message was filled with initially. * diff --git a/modules/core_api/fsw/inc/cfe_es.h b/modules/core_api/fsw/inc/cfe_es.h index 5f4cee5de..ea87cf31b 100644 --- a/modules/core_api/fsw/inc/cfe_es.h +++ b/modules/core_api/fsw/inc/cfe_es.h @@ -1494,7 +1494,11 @@ CFE_Status_t CFE_ES_GetMemPoolStats(CFE_ES_MemPoolStats_t *BufPtr, CFE_ES_MemHan ** tool. ** ** \par Assumptions, External Events, and Notes: - +** +** \c Marker limited to the range of 0 to +** #CFE_MISSION_ES_PERF_MAX_IDS - 1. Any performance ids outside of this +** range will be ignored and will be flagged as an error. +** ** This function implements a circular buffer using an array. ** DataStart points to first stored entry ** DataEnd points to next available entry diff --git a/modules/core_api/fsw/inc/cfe_msg.h b/modules/core_api/fsw/inc/cfe_msg.h index ccd43bdb7..7a25771f2 100644 --- a/modules/core_api/fsw/inc/cfe_msg.h +++ b/modules/core_api/fsw/inc/cfe_msg.h @@ -60,30 +60,6 @@ */ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_MSG_Size_t Size); -/*****************************************************************************/ -/** - * \brief Set/compute all dynamically-updated headers on a message - * - * \par Description - * This routine updates all dynamic header fields on a message, and is typically - * invoked via SB just prior to broadcasting the message. Dynamic headers include - * are values that should be computed/updated per message, including: - * - the sequence number - * - the timestamp, if present - * - any error control or checksum fields, if present - * - * The MSG module implementation determines which header fields meet this criteria - * and how they should be computed. - * - * \param[inout] MsgPtr A pointer to the buffer that contains the message @nonnull. - * \param[in] SeqCnt The current sequence number from the message route - * - * \return Execution status, see \ref CFEReturnCodes - * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS - * \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT - */ -CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt); - /**\}*/ /** \defgroup CFEAPIMSGHeaderPri cFE Message Primary Header APIs @@ -725,12 +701,44 @@ CFE_Status_t CFE_MSG_GetTypeFromMsgId(CFE_SB_MsgId_t MsgId, CFE_MSG_Type_t *Type /**\}*/ -/** \defgroup CFEAPIMSGMsgVerify cFE Message Checking APIs +/** \defgroup CFEAPIMSGMsgIntegrity cFE Message Integrity APIs * \{ */ + /*****************************************************************************/ /** - * \brief Checks message headers against expected values + * \brief Perform any necessary actions on a newly-created message, prior to sending + * + * \par Description + * This routine updates and/or appends any necessary fields on a message, is + * invoked via SB just prior to broadcasting the message. The actions include + * updating any values that should be computed/updated per message, including: + * - setting the sequence number + * - updating the timestamp, if present + * - computing any error control or checksum fields, if present + * + * The MSG module implementation determines which header fields meet this criteria + * and how they should be computed. + * + * The BufferSize parameter indicates the allocation size message of the buffer that + * holds the message (i.e. the message envelope size). In some implementations, the + * allocated buffer may include extra space in order to append a CRC or digital signature. + * + * \sa CFE_MSG_VerificationAction + * + * \param[inout] MsgPtr A pointer to the buffer that contains the message @nonnull. + * \param[in] BufferSize The size of the buffer encapsulating the message + * \param[out] IsAcceptable Output variable to be set, indicates message acceptability @nonnull + * + * \return Execution status, see \ref CFEReturnCodes + * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS + * \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT + */ +CFE_Status_t CFE_MSG_OriginationAction(CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable); + +/*****************************************************************************/ +/** + * \brief Checks message integrity/acceptability * * \par Description * This routine validates that any error-control field(s) in the message header @@ -740,14 +748,23 @@ CFE_Status_t CFE_MSG_GetTypeFromMsgId(CFE_SB_MsgId_t MsgId, CFE_MSG_Type_t *Type * and may be a no-op if no error checking is implemented. In that case, it * will always output "true". * + * \note Due to the fact that software bus uses a multicast architecture, this function + * must not modify the message, as the buffer may be shared among multiple receivers. + * This should generally be the inverse of CFE_MSG_OriginationAction(), but on the + * origination side it may update header fields and/or modify the message, on + * the verification/receive side it must only check those fields, not modify them. + * + * \sa CFE_MSG_OriginationAction + * * \param[in] MsgPtr Message Pointer @nonnull - * \param[out] VerifyStatus Output variable to be set to verification result @nonnull + * \param[in] BufferSize The size of the buffer encapsulating the message + * \param[out] IsAcceptable Output variable to be set, indicates message acceptability @nonnull * * \return Execution status, see \ref CFEReturnCodes * \retval #CFE_SUCCESS \copybrief CFE_SUCCESS * \retval #CFE_MSG_BAD_ARGUMENT \copybrief CFE_MSG_BAD_ARGUMENT */ -CFE_Status_t CFE_MSG_Verify(const CFE_MSG_Message_t *MsgPtr, bool *VerifyStatus); +CFE_Status_t CFE_MSG_VerificationAction(const CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable); /**\}*/ diff --git a/modules/core_api/fsw/inc/cfe_sb.h b/modules/core_api/fsw/inc/cfe_sb.h index a670d0120..d08b5aca5 100644 --- a/modules/core_api/fsw/inc/cfe_sb.h +++ b/modules/core_api/fsw/inc/cfe_sb.h @@ -402,9 +402,15 @@ CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI ** software bus will read the message ID from the message header to ** determine which pipes should receive the message. ** -** In general, the "UpdateHeader" parameter should be passed as "true" -** if the message was newly constructed by the sender and is being sent -** for the first time. When forwarding a message that originated from +** The IsOrigination parameter should be passed as "true" if the message was +** newly constructed by the sender and is being sent for the first time. This +** enables the message origination actions as determined by the CFE MSG module, +** which may include (but not limited to): +** - Updating sequence number +** - Updating timestamp +** - Calcualating a CRC, checksum, or other message error control field +** +** Conversely, when forwarding a message that originated from ** an external entity (e.g. messages passing through CI or SBN), the ** parameter should be passed as "false" to not overwrite existing data. ** @@ -421,7 +427,7 @@ CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI ** ** \param[in] MsgPtr A pointer to the message to be sent @nonnull. This must point ** to the first byte of the message header. -** \param[in] UpdateHeader Update the headers of the message +** \param[in] IsOrigination Update the headers of the message ** ** \return Execution status, see \ref CFEReturnCodes ** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS @@ -429,7 +435,7 @@ CFE_Status_t CFE_SB_UnsubscribeLocal(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeI ** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG ** \retval #CFE_SB_BUF_ALOC_ERR \covtest \copybrief CFE_SB_BUF_ALOC_ERR **/ -CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader); +CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool IsOrigination); /*****************************************************************************/ /** @@ -471,6 +477,7 @@ CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHead ** \retval #CFE_SB_NO_MESSAGE \copybrief CFE_SB_NO_MESSAGE **/ CFE_Status_t CFE_SB_ReceiveBuffer(CFE_SB_Buffer_t **BufPtr, CFE_SB_PipeId_t PipeId, int32 TimeOut); + /** @} */ /** @defgroup CFEAPISBZeroCopy cFE Zero Copy APIs @@ -544,9 +551,15 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr); ** internal buffer. The "zero copy" interface can be used to improve ** performance in high-rate, high-volume software bus traffic. ** -** In general, the "UpdateHeader" parameter should be passed as "true" -** if the message was newly constructed by the sender and is being sent -** for the first time. When forwarding a message that originated from +** The IsOrigination parameter should be passed as "true" if the message was +** newly constructed by the sender and is being sent for the first time. This +** enables the message origination actions as determined by the CFE MSG module, +** which may include (but not limited to): +** - Updating sequence number +** - Updating timestamp +** - Calcualating a CRC, checksum, or other message error control field +** +** Conversely, when forwarding a message that originated from ** an external entity (e.g. messages passing through CI or SBN), the ** parameter should be passed as "false" to not overwrite existing data. ** @@ -567,15 +580,15 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr); ** -# This function will increment and apply the internally tracked ** sequence counter if set to do so. ** -** \param[in] BufPtr A pointer to the buffer to be sent @nonnull. -** \param[in] UpdateHeader Update the headers of the message +** \param[in] BufPtr A pointer to the buffer to be sent @nonnull. +** \param[in] IsOrigination Update applicable header field(s) of a newly constructed message ** ** \return Execution status, see \ref CFEReturnCodes ** \retval #CFE_SUCCESS \copybrief CFE_SUCCESS ** \retval #CFE_SB_BAD_ARGUMENT \copybrief CFE_SB_BAD_ARGUMENT ** \retval #CFE_SB_MSG_TOO_BIG \copybrief CFE_SB_MSG_TOO_BIG **/ -CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader); +CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IsOrigination); /** @} */ diff --git a/modules/core_api/fsw/inc/cfe_version.h b/modules/core_api/fsw/inc/cfe_version.h index 39a53331e..f8fafa244 100644 --- a/modules/core_api/fsw/inc/cfe_version.h +++ b/modules/core_api/fsw/inc/cfe_version.h @@ -26,7 +26,7 @@ #define CFE_VERSION_H /* Development Build Macro Definitions */ -#define CFE_BUILD_NUMBER 411 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */ +#define CFE_BUILD_NUMBER 424 /**< @brief Development: Number of development git commits since CFE_BUILD_BASELINE */ #define CFE_BUILD_BASELINE "v7.0.0-rc4" /**< @brief Development: Reference git tag for build number */ /* See \ref cfsversions for definitions */ diff --git a/modules/core_api/ut-stubs/src/cfe_msg_handlers.c b/modules/core_api/ut-stubs/src/cfe_msg_handlers.c index fee87345c..e9228a998 100644 --- a/modules/core_api/ut-stubs/src/cfe_msg_handlers.c +++ b/modules/core_api/ut-stubs/src/cfe_msg_handlers.c @@ -376,3 +376,35 @@ void UT_DefaultHandler_CFE_MSG_GetNextSequenceCount(void *UserObj, UT_EntryKey_t UT_Stub_SetReturnValue(FuncKey, return_value); } + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_OriginationAction coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_OriginationAction(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + bool *IsAcceptable = UT_Hook_GetArgValueByName(Context, "IsAcceptable", bool *); + + /* by default just always return true -- a UT case that needs something else can override this handler */ + if (IsAcceptable != NULL) + { + *IsAcceptable = true; + } +} + +/*------------------------------------------------------------ + * + * Default handler for CFE_MSG_VerificationAction coverage stub function + * + *------------------------------------------------------------*/ +void UT_DefaultHandler_CFE_MSG_VerificationAction(void *UserObj, UT_EntryKey_t FuncKey, const UT_StubContext_t *Context) +{ + bool *IsAcceptable = UT_Hook_GetArgValueByName(Context, "IsAcceptable", bool *); + + /* by default just always return true -- a UT case that needs something else can override this handler */ + if (IsAcceptable != NULL) + { + *IsAcceptable = true; + } +} diff --git a/modules/core_api/ut-stubs/src/cfe_msg_stubs.c b/modules/core_api/ut-stubs/src/cfe_msg_stubs.c index 066f8e8d1..ea39c87b3 100644 --- a/modules/core_api/ut-stubs/src/cfe_msg_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_msg_stubs.c @@ -42,7 +42,9 @@ void UT_DefaultHandler_CFE_MSG_GetSubsystem(void *, UT_EntryKey_t, const UT_Stub void UT_DefaultHandler_CFE_MSG_GetSystem(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CFE_MSG_GetType(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CFE_MSG_GetTypeFromMsgId(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_MSG_OriginationAction(void *, UT_EntryKey_t, const UT_StubContext_t *); void UT_DefaultHandler_CFE_MSG_ValidateChecksum(void *, UT_EntryKey_t, const UT_StubContext_t *); +void UT_DefaultHandler_CFE_MSG_VerificationAction(void *, UT_EntryKey_t, const UT_StubContext_t *); /* * ---------------------------------------------------- @@ -366,6 +368,24 @@ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_M return UT_GenStub_GetReturnValue(CFE_MSG_Init, CFE_Status_t); } +/* + * ---------------------------------------------------- + * Generated stub function for CFE_MSG_OriginationAction() + * ---------------------------------------------------- + */ +CFE_Status_t CFE_MSG_OriginationAction(CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) +{ + UT_GenStub_SetupReturnBuffer(CFE_MSG_OriginationAction, CFE_Status_t); + + UT_GenStub_AddParam(CFE_MSG_OriginationAction, CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_OriginationAction, size_t, BufferSize); + UT_GenStub_AddParam(CFE_MSG_OriginationAction, bool *, IsAcceptable); + + UT_GenStub_Execute(CFE_MSG_OriginationAction, Basic, UT_DefaultHandler_CFE_MSG_OriginationAction); + + return UT_GenStub_GetReturnValue(CFE_MSG_OriginationAction, CFE_Status_t); +} + /* * ---------------------------------------------------- * Generated stub function for CFE_MSG_SetApId() @@ -623,34 +643,35 @@ CFE_Status_t CFE_MSG_SetType(CFE_MSG_Message_t *MsgPtr, CFE_MSG_Type_t Type) /* * ---------------------------------------------------- - * Generated stub function for CFE_MSG_UpdateHeader() + * Generated stub function for CFE_MSG_ValidateChecksum() * ---------------------------------------------------- */ -CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt) +CFE_Status_t CFE_MSG_ValidateChecksum(const CFE_MSG_Message_t *MsgPtr, bool *IsValid) { - UT_GenStub_SetupReturnBuffer(CFE_MSG_UpdateHeader, CFE_Status_t); + UT_GenStub_SetupReturnBuffer(CFE_MSG_ValidateChecksum, CFE_Status_t); - UT_GenStub_AddParam(CFE_MSG_UpdateHeader, CFE_MSG_Message_t *, MsgPtr); - UT_GenStub_AddParam(CFE_MSG_UpdateHeader, CFE_MSG_SequenceCount_t, SeqCnt); + UT_GenStub_AddParam(CFE_MSG_ValidateChecksum, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_ValidateChecksum, bool *, IsValid); - UT_GenStub_Execute(CFE_MSG_UpdateHeader, Basic, NULL); + UT_GenStub_Execute(CFE_MSG_ValidateChecksum, Basic, UT_DefaultHandler_CFE_MSG_ValidateChecksum); - return UT_GenStub_GetReturnValue(CFE_MSG_UpdateHeader, CFE_Status_t); + return UT_GenStub_GetReturnValue(CFE_MSG_ValidateChecksum, CFE_Status_t); } /* * ---------------------------------------------------- - * Generated stub function for CFE_MSG_ValidateChecksum() + * Generated stub function for CFE_MSG_VerificationAction() * ---------------------------------------------------- */ -CFE_Status_t CFE_MSG_ValidateChecksum(const CFE_MSG_Message_t *MsgPtr, bool *IsValid) +CFE_Status_t CFE_MSG_VerificationAction(const CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) { - UT_GenStub_SetupReturnBuffer(CFE_MSG_ValidateChecksum, CFE_Status_t); + UT_GenStub_SetupReturnBuffer(CFE_MSG_VerificationAction, CFE_Status_t); - UT_GenStub_AddParam(CFE_MSG_ValidateChecksum, const CFE_MSG_Message_t *, MsgPtr); - UT_GenStub_AddParam(CFE_MSG_ValidateChecksum, bool *, IsValid); + UT_GenStub_AddParam(CFE_MSG_VerificationAction, const CFE_MSG_Message_t *, MsgPtr); + UT_GenStub_AddParam(CFE_MSG_VerificationAction, size_t, BufferSize); + UT_GenStub_AddParam(CFE_MSG_VerificationAction, bool *, IsAcceptable); - UT_GenStub_Execute(CFE_MSG_ValidateChecksum, Basic, UT_DefaultHandler_CFE_MSG_ValidateChecksum); + UT_GenStub_Execute(CFE_MSG_VerificationAction, Basic, UT_DefaultHandler_CFE_MSG_VerificationAction); - return UT_GenStub_GetReturnValue(CFE_MSG_ValidateChecksum, CFE_Status_t); + return UT_GenStub_GetReturnValue(CFE_MSG_VerificationAction, CFE_Status_t); } diff --git a/modules/core_api/ut-stubs/src/cfe_sb_stubs.c b/modules/core_api/ut-stubs/src/cfe_sb_stubs.c index 3f541d54c..369394492 100644 --- a/modules/core_api/ut-stubs/src/cfe_sb_stubs.c +++ b/modules/core_api/ut-stubs/src/cfe_sb_stubs.c @@ -384,12 +384,12 @@ void CFE_SB_TimeStampMsg(CFE_MSG_Message_t *MsgPtr) * Generated stub function for CFE_SB_TransmitBuffer() * ---------------------------------------------------- */ -CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader) +CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IsOrigination) { UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitBuffer, CFE_Status_t); UT_GenStub_AddParam(CFE_SB_TransmitBuffer, CFE_SB_Buffer_t *, BufPtr); - UT_GenStub_AddParam(CFE_SB_TransmitBuffer, bool, UpdateHeader); + UT_GenStub_AddParam(CFE_SB_TransmitBuffer, bool, IsOrigination); UT_GenStub_Execute(CFE_SB_TransmitBuffer, Basic, UT_DefaultHandler_CFE_SB_TransmitBuffer); @@ -401,12 +401,12 @@ CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader) * Generated stub function for CFE_SB_TransmitMsg() * ---------------------------------------------------- */ -CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader) +CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool IsOrigination) { UT_GenStub_SetupReturnBuffer(CFE_SB_TransmitMsg, CFE_Status_t); UT_GenStub_AddParam(CFE_SB_TransmitMsg, const CFE_MSG_Message_t *, MsgPtr); - UT_GenStub_AddParam(CFE_SB_TransmitMsg, bool, UpdateHeader); + UT_GenStub_AddParam(CFE_SB_TransmitMsg, bool, IsOrigination); UT_GenStub_Execute(CFE_SB_TransmitMsg, Basic, UT_DefaultHandler_CFE_SB_TransmitMsg); diff --git a/modules/es/config/default_cfe_es_interface_cfg.h b/modules/es/config/default_cfe_es_interface_cfg.h index 8189075d4..5fa4c574a 100644 --- a/modules/es/config/default_cfe_es_interface_cfg.h +++ b/modules/es/config/default_cfe_es_interface_cfg.h @@ -52,9 +52,14 @@ ** \cfeescfg Define Max Number of Performance IDs for messages ** ** \par Description: -** Defines the maximum number of perf ids allowed in command/telemetry messages +** Defines the maximum number of perf ids allowed. ** -** This affects the layout of command/telemetry messages but does not affect run +** Each performance id is used to identify something that needs to be +** measured. Performance ids are limited to the range of 0 to +** #CFE_MISSION_ES_PERF_MAX_IDS - 1. Any performance ids outside of this +** range will be ignored and will be flagged as an error. +** +** This affects the layout of telemetry messages but does not affect run ** time behavior or internal allocation. ** ** \par Limits diff --git a/modules/msg/CMakeLists.txt b/modules/msg/CMakeLists.txt index 4cc69762c..c4af293b0 100644 --- a/modules/msg/CMakeLists.txt +++ b/modules/msg/CMakeLists.txt @@ -18,7 +18,7 @@ set(${DEP}_SRC fsw/src/cfe_msg_ccsdspri.c fsw/src/cfe_msg_init.c - fsw/src/cfe_msg_verify.c + fsw/src/cfe_msg_integrity.c fsw/src/cfe_msg_msgid_shared.c fsw/src/cfe_msg_sechdr_checksum.c fsw/src/cfe_msg_sechdr_fc.c diff --git a/modules/msg/fsw/src/cfe_msg_init.c b/modules/msg/fsw/src/cfe_msg_init.c index ab988f4bb..d67fc643d 100644 --- a/modules/msg/fsw/src/cfe_msg_init.c +++ b/modules/msg/fsw/src/cfe_msg_init.c @@ -53,34 +53,3 @@ CFE_Status_t CFE_MSG_Init(CFE_MSG_Message_t *MsgPtr, CFE_SB_MsgId_t MsgId, CFE_M return status; } - -/*---------------------------------------------------------------- - * - * Implemented per public API - * See description in header file for argument/return detail - * - *-----------------------------------------------------------------*/ -CFE_Status_t CFE_MSG_UpdateHeader(CFE_MSG_Message_t *MsgPtr, CFE_MSG_SequenceCount_t SeqCnt) -{ - if (MsgPtr == NULL) - { - return CFE_MSG_BAD_ARGUMENT; - } - - /* Sequence count is in the basic CCSDS Primary Hdr, so all msgs have it */ - CFE_MSG_SetSequenceCount(MsgPtr, SeqCnt); - - /* - * TLM packets have a timestamp in the secondary header. - * This may fail if this is not a TLM packet (that is OK) - */ - CFE_MSG_SetMsgTime(MsgPtr, CFE_TIME_GetTime()); - - /* - * CMD packets have a checksum in the secondary header. - * This may fail if this is not a CMD packet (that is OK) - */ - CFE_MSG_GenerateChecksum(MsgPtr); - - return CFE_SUCCESS; -} \ No newline at end of file diff --git a/modules/msg/fsw/src/cfe_msg_verify.c b/modules/msg/fsw/src/cfe_msg_integrity.c similarity index 58% rename from modules/msg/fsw/src/cfe_msg_verify.c rename to modules/msg/fsw/src/cfe_msg_integrity.c index b712ff3f6..bf1c61bd0 100644 --- a/modules/msg/fsw/src/cfe_msg_verify.c +++ b/modules/msg/fsw/src/cfe_msg_integrity.c @@ -27,22 +27,50 @@ * See description in header file for argument/return detail * *-----------------------------------------------------------------*/ -CFE_Status_t CFE_MSG_Verify(const CFE_MSG_Message_t *MsgPtr, bool *VerifyStatus) +CFE_Status_t CFE_MSG_OriginationAction(CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) { - if (MsgPtr == NULL || VerifyStatus == NULL) + if (MsgPtr == NULL || IsAcceptable == NULL) + { + return CFE_MSG_BAD_ARGUMENT; + } + + /* + * TLM packets have a timestamp in the secondary header. + * This may fail if this is not a TLM packet (that is OK) + */ + CFE_MSG_SetMsgTime(MsgPtr, CFE_TIME_GetTime()); + + /* + * CMD packets have a checksum in the secondary header. + * This may fail if this is not a CMD packet (that is OK) + */ + CFE_MSG_GenerateChecksum(MsgPtr); + + /* This implementation permits all outgoing messages */ + *IsAcceptable = true; + + return CFE_SUCCESS; +} +/*---------------------------------------------------------------- + * + * Implemented per public API + * See description in header file for argument/return detail + * + *-----------------------------------------------------------------*/ +CFE_Status_t CFE_MSG_VerificationAction(const CFE_MSG_Message_t *MsgPtr, size_t BufferSize, bool *IsAcceptable) +{ + if (MsgPtr == NULL || IsAcceptable == NULL) { return CFE_MSG_BAD_ARGUMENT; } /* * In the default implementation, there is not anything to check here. - * Only commands have a checksum, but the value of that checksum was historically - * not enforced by CFE. * * This is mainly a hook for user expansion, in case a custom implementation * has message verification capability. */ - *VerifyStatus = true; + *IsAcceptable = true; return CFE_SUCCESS; } \ No newline at end of file diff --git a/modules/msg/ut-coverage/CMakeLists.txt b/modules/msg/ut-coverage/CMakeLists.txt index dd2c3bad1..a2c5eed17 100644 --- a/modules/msg/ut-coverage/CMakeLists.txt +++ b/modules/msg/ut-coverage/CMakeLists.txt @@ -18,7 +18,7 @@ set (ut_${DEP}_tests test_msg_not.c test_msg_pri_not.c test_cfe_msg_init.c - test_cfe_msg_verify.c + test_cfe_msg_integrity.c test_cfe_msg_ccsdspri.c test_cfe_msg_msgid_shared.c test_cfe_msg_checksum.c diff --git a/modules/msg/ut-coverage/msg_UT.c b/modules/msg/ut-coverage/msg_UT.c index 0ad1b30bb..48d8f9259 100644 --- a/modules/msg/ut-coverage/msg_UT.c +++ b/modules/msg/ut-coverage/msg_UT.c @@ -44,11 +44,11 @@ void UtTest_Setup(void) UtPrintf("Message header coverage test..."); UT_ADD_TEST(Test_MSG_Init); - UT_ADD_TEST(Test_MSG_UpdateHeader); + UT_ADD_TEST(Test_MSG_OriginationAction); Test_MSG_CCSDSPri(); Test_MSG_CCSDSExt(); Test_MSG_MsgId_Shared(); - UT_ADD_TEST(Test_MSG_Verify); + UT_ADD_TEST(Test_MSG_VerificationAction); UT_ADD_TEST(Test_MSG_MsgId); UT_ADD_TEST(Test_MSG_Checksum); UT_ADD_TEST(Test_MSG_FcnCode); diff --git a/modules/msg/ut-coverage/test_cfe_msg_init.c b/modules/msg/ut-coverage/test_cfe_msg_init.c index a707c3618..a072566ae 100644 --- a/modules/msg/ut-coverage/test_cfe_msg_init.c +++ b/modules/msg/ut-coverage/test_cfe_msg_init.c @@ -124,40 +124,3 @@ void Test_MSG_Init(void) UtAssert_UINT32_EQ(Test_MSG_Pri_NotZero(CFE_MSG_PTR(cmd)) & ~MSG_HDRVER_FLAG, MSG_APID_FLAG | MSG_HASSEC_FLAG | MSG_TYPE_FLAG | MSG_LENGTH_FLAG | MSG_SEGMENT_FLAG); } - -/* - * Test MSG Update Header - */ -void Test_MSG_UpdateHeader(void) -{ - union - { - CFE_MSG_Message_t msg; - CFE_MSG_CommandHeader_t cmd; - CFE_MSG_TelemetryHeader_t tlm; - - } LocalBuf; - CFE_MSG_SequenceCount_t SeqCnt; - CFE_MSG_SequenceCount_t CheckCnt; - - memset(&LocalBuf, 0, sizeof(LocalBuf)); - SeqCnt = 1; - CheckCnt = 0; - - /* bad buffer */ - UtAssert_INT32_EQ(CFE_MSG_UpdateHeader(NULL, SeqCnt), CFE_MSG_BAD_ARGUMENT); - - /* nominal, cmd */ - CFE_MSG_SetType(&LocalBuf.msg, CFE_MSG_Type_Cmd); - CFE_UtAssert_SUCCESS(CFE_MSG_UpdateHeader(&LocalBuf.msg, SeqCnt)); - CFE_MSG_GetSequenceCount(&LocalBuf.msg, &CheckCnt); - UtAssert_UINT32_EQ(CheckCnt, SeqCnt); - ++SeqCnt; - - /* nominal, tlm */ - CFE_MSG_SetType(&LocalBuf.msg, CFE_MSG_Type_Tlm); - CFE_UtAssert_SUCCESS(CFE_MSG_UpdateHeader(&LocalBuf.msg, SeqCnt)); - CFE_MSG_GetSequenceCount(&LocalBuf.msg, &CheckCnt); - UtAssert_UINT32_EQ(CheckCnt, SeqCnt); - ++SeqCnt; -} diff --git a/modules/msg/ut-coverage/test_cfe_msg_init.h b/modules/msg/ut-coverage/test_cfe_msg_init.h index 3c5b25f62..6e465b03d 100644 --- a/modules/msg/ut-coverage/test_cfe_msg_init.h +++ b/modules/msg/ut-coverage/test_cfe_msg_init.h @@ -33,6 +33,6 @@ */ /* Test extended header mission functionality */ void Test_MSG_Init(void); -void Test_MSG_UpdateHeader(void); +void Test_MSG_OriginationAction(void); #endif /* TEST_CFE_MSG_INIT_H */ diff --git a/modules/msg/ut-coverage/test_cfe_msg_integrity.c b/modules/msg/ut-coverage/test_cfe_msg_integrity.c new file mode 100644 index 000000000..bc3aa7311 --- /dev/null +++ b/modules/msg/ut-coverage/test_cfe_msg_integrity.c @@ -0,0 +1,91 @@ +/************************************************************************ + * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” + * + * Copyright (c) 2020 United States Government as represented by the + * Administrator of the National Aeronautics and Space Administration. + * All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. You may obtain + * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + ************************************************************************/ + +/* + * Test message verify + */ + +/* + * Includes + */ +#include "utassert.h" +#include "ut_support.h" +#include "cfe_msg.h" +#include "test_cfe_msg_verify.h" +#include "cfe_error.h" +#include "cfe_msg_defaults.h" + +#include + +/* + * Test MSG integrity origination action(s) + */ +void Test_MSG_OriginationAction(void) +{ + union + { + CFE_MSG_Message_t msg; + CFE_MSG_CommandHeader_t cmd; + CFE_MSG_TelemetryHeader_t tlm; + + } LocalBuf; + bool IsAcceptable; + + memset(&LocalBuf, 0, sizeof(LocalBuf)); + + /* bad buffer */ + UtAssert_INT32_EQ(CFE_MSG_OriginationAction(NULL, sizeof(LocalBuf), &IsAcceptable), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_OriginationAction(&LocalBuf.msg, sizeof(LocalBuf), NULL), CFE_MSG_BAD_ARGUMENT); + + /* nominal, cmd */ + IsAcceptable = false; + CFE_MSG_SetType(&LocalBuf.msg, CFE_MSG_Type_Cmd); + CFE_UtAssert_SUCCESS(CFE_MSG_OriginationAction(&LocalBuf.msg, sizeof(LocalBuf), &IsAcceptable)); + UtAssert_BOOL_TRUE(IsAcceptable); + + /* nominal, tlm */ + IsAcceptable = false; + CFE_MSG_SetType(&LocalBuf.msg, CFE_MSG_Type_Tlm); + CFE_UtAssert_SUCCESS(CFE_MSG_OriginationAction(&LocalBuf.msg, sizeof(LocalBuf), &IsAcceptable)); + UtAssert_BOOL_TRUE(IsAcceptable); +} + +/* + * Test MSG integrity verification action(s) + */ +void Test_MSG_VerificationAction(void) +{ + union + { + CFE_MSG_Message_t msg; + CFE_MSG_CommandHeader_t cmd; + CFE_MSG_TelemetryHeader_t tlm; + } LocalBuf; + bool IsAcceptable; + + memset(&LocalBuf, 0, sizeof(LocalBuf)); + + /* bad buffer */ + UtAssert_INT32_EQ(CFE_MSG_VerificationAction(NULL, sizeof(LocalBuf), &IsAcceptable), CFE_MSG_BAD_ARGUMENT); + UtAssert_INT32_EQ(CFE_MSG_VerificationAction(&LocalBuf.msg, sizeof(LocalBuf), NULL), CFE_MSG_BAD_ARGUMENT); + + /* nominal */ + IsAcceptable = false; + CFE_UtAssert_SUCCESS(CFE_MSG_VerificationAction(&LocalBuf.msg, sizeof(LocalBuf), &IsAcceptable)); + UtAssert_BOOL_TRUE(IsAcceptable); +} diff --git a/modules/msg/ut-coverage/test_cfe_msg_verify.c b/modules/msg/ut-coverage/test_cfe_msg_verify.c deleted file mode 100644 index 87c5faa73..000000000 --- a/modules/msg/ut-coverage/test_cfe_msg_verify.c +++ /dev/null @@ -1,59 +0,0 @@ -/************************************************************************ - * NASA Docket No. GSC-18,719-1, and identified as “core Flight System: Bootes” - * - * Copyright (c) 2020 United States Government as represented by the - * Administrator of the National Aeronautics and Space Administration. - * All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. You may obtain - * a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - ************************************************************************/ - -/* - * Test message verify - */ - -/* - * Includes - */ -#include "utassert.h" -#include "ut_support.h" -#include "cfe_msg.h" -#include "test_cfe_msg_verify.h" -#include "cfe_error.h" -#include "cfe_msg_defaults.h" - -#include - -/* - * Test MSG Verify - */ -void Test_MSG_Verify(void) -{ - union - { - CFE_MSG_Message_t msg; - CFE_MSG_CommandHeader_t cmd; - CFE_MSG_TelemetryHeader_t tlm; - } LocalBuf; - bool Result; - - memset(&LocalBuf, 0, sizeof(LocalBuf)); - Result = false; - - /* bad buffer */ - UtAssert_INT32_EQ(CFE_MSG_Verify(NULL, &Result), CFE_MSG_BAD_ARGUMENT); - UtAssert_INT32_EQ(CFE_MSG_Verify(&LocalBuf.msg, NULL), CFE_MSG_BAD_ARGUMENT); - - /* nominal */ - Result = false; - CFE_UtAssert_SUCCESS(CFE_MSG_Verify(&LocalBuf.msg, &Result)); - UtAssert_BOOL_TRUE(Result); -} diff --git a/modules/msg/ut-coverage/test_cfe_msg_verify.h b/modules/msg/ut-coverage/test_cfe_msg_verify.h index f017560e2..024412ea4 100644 --- a/modules/msg/ut-coverage/test_cfe_msg_verify.h +++ b/modules/msg/ut-coverage/test_cfe_msg_verify.h @@ -31,6 +31,6 @@ /* * Functions */ -void Test_MSG_Verify(void); +void Test_MSG_VerificationAction(void); #endif /* TEST_CFE_MSG_VERIFY_H */ diff --git a/modules/sb/fsw/inc/cfe_sb_eventids.h b/modules/sb/fsw/inc/cfe_sb_eventids.h index 326542f9c..0f59304a2 100644 --- a/modules/sb/fsw/inc/cfe_sb_eventids.h +++ b/modules/sb/fsw/inc/cfe_sb_eventids.h @@ -759,6 +759,31 @@ * #CFE_SB_CreatePipe API failure due to no free queues. */ #define CFE_SB_CR_PIPE_NO_FREE_EID 70 + +/** + * \brief SB integrity actions on transmit message failure event + * + * \par Type: ERROR + * + * \par Cause: + * + * A CFE SB transmit transaction has rejected a message due + * to failure of the associated message integrity action(s). + */ +#define CFE_SB_SEND_MESSAGE_INTEGRITY_FAIL_EID 71 + +/** + * \brief SB validation of received message failure event + * + * \par Type: ERROR + * + * \par Cause: + * + * A CFE SB receive transaction has rejected a message due + * to failure of the associated message integrity action(s). + */ +#define CFE_SB_RCV_MESSAGE_INTEGRITY_FAIL_EID 72 + /**\}*/ #endif /* CFE_SB_EVENTS_H */ diff --git a/modules/sb/fsw/src/cfe_sb_api.c b/modules/sb/fsw/src/cfe_sb_api.c index b4747f452..bc4280ece 100644 --- a/modules/sb/fsw/src/cfe_sb_api.c +++ b/modules/sb/fsw/src/cfe_sb_api.c @@ -123,7 +123,8 @@ CFE_Status_t CFE_SB_CreatePipe(CFE_SB_PipeId_t *PipeIdPtr, uint16 Depth, const c CFE_ES_GetTaskID(&TskId); /* check input parameters */ - if ((PipeIdPtr == NULL) || (Depth > OS_QUEUE_MAX_DEPTH) || (Depth == 0) || (PipeName != NULL && PipeName[0] == '\0')) + if ((PipeIdPtr == NULL) || (Depth > OS_QUEUE_MAX_DEPTH) || (Depth == 0) || + (PipeName != NULL && PipeName[0] == '\0')) { PendingEventId = CFE_SB_CR_PIPE_BAD_ARG_EID; Status = CFE_SB_BAD_ARGUMENT; @@ -1287,7 +1288,7 @@ int32 CFE_SB_UnsubscribeFull(CFE_SB_MsgId_t MsgId, CFE_SB_PipeId_t PipeId, uint8 * See description in header file for argument/return detail * *-----------------------------------------------------------------*/ -CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHeader) +CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool IsOrigination) { int32 Status; CFE_MSG_Size_t Size = 0; @@ -1349,7 +1350,7 @@ CFE_Status_t CFE_SB_TransmitMsg(const CFE_MSG_Message_t *MsgPtr, bool UpdateHead memcpy(&BufDscPtr->Content, MsgPtr, Size); BufDscPtr->MsgId = MsgId; BufDscPtr->ContentSize = Size; - BufDscPtr->NeedsUpdate = UpdateHeader; + BufDscPtr->NeedsUpdate = IsOrigination; CFE_MSG_GetType(MsgPtr, &BufDscPtr->ContentType); /* @@ -1535,8 +1536,10 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ uint32 i; char FullName[(OS_MAX_API_NAME * 2)]; char PipeName[OS_MAX_API_NAME]; + bool IsAcceptable; SBSndErr.EvtsToSnd = 0; + IsAcceptable = true; /* get app id for loopback testing */ CFE_ES_GetAppID(&AppId); @@ -1555,8 +1558,10 @@ void CFE_SB_BroadcastBufferToRoute(CFE_SB_BufferD_t *BufDscPtr, CFE_SBR_RouteId_ { CFE_SBR_IncrementSequenceCounter(RouteId); + CFE_MSG_SetSequenceCount(&BufDscPtr->Content.Msg, CFE_SBR_GetSequenceCounter(RouteId)); + /* Update all MSG headers based on the current sequence */ - CFE_MSG_UpdateHeader(&BufDscPtr->Content.Msg, CFE_SBR_GetSequenceCounter(RouteId)); + CFE_MSG_OriginationAction(&BufDscPtr->Content.Msg, BufDscPtr->ContentSize, &IsAcceptable); /* Clear the flag, just in case */ BufDscPtr->NeedsUpdate = false; @@ -2118,7 +2123,7 @@ CFE_Status_t CFE_SB_ReleaseMessageBuffer(CFE_SB_Buffer_t *BufPtr) * See description in header file for argument/return detail * *-----------------------------------------------------------------*/ -CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader) +CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool IsOrigination) { int32 Status; CFE_SB_BufferD_t *BufDscPtr; @@ -2143,7 +2148,7 @@ CFE_Status_t CFE_SB_TransmitBuffer(CFE_SB_Buffer_t *BufPtr, bool UpdateHeader) */ if (Status == CFE_SUCCESS) { - BufDscPtr->NeedsUpdate = UpdateHeader; + BufDscPtr->NeedsUpdate = IsOrigination; CFE_MSG_GetType(&BufPtr->Msg, &BufDscPtr->ContentType); /* Now broadcast the message, which consumes the buffer */ diff --git a/modules/sb/ut-coverage/sb_UT.c b/modules/sb/ut-coverage/sb_UT.c index b31faa4e5..72df5a6b3 100644 --- a/modules/sb/ut-coverage/sb_UT.c +++ b/modules/sb/ut-coverage/sb_UT.c @@ -3015,8 +3015,8 @@ void Test_TransmitMsg_UpdateHeader(void) memset(&TlmPkt, 0, sizeof(TlmPkt)); - /* Set up hook for checking CFE_MSG_UpdateHeader calls */ - UT_SetHookFunction(UT_KEY(CFE_MSG_UpdateHeader), UT_CheckSetSequenceCount, &SeqCnt); + /* Set up hook for checking CFE_MSG_SetSequenceCount calls */ + UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe")); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3029,7 +3029,8 @@ void Test_TransmitMsg_UpdateHeader(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SETUP(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); - UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 1); + UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 1); + UtAssert_STUB_COUNT(CFE_MSG_OriginationAction, 1); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 1); UtAssert_INT32_EQ(SeqCnt, SeqCntExpected); @@ -3039,8 +3040,9 @@ void Test_TransmitMsg_UpdateHeader(void) CFE_UtAssert_SUCCESS(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), false)); /* Assert sequence count wasn't set */ + UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 1); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 1); - UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 1); + UtAssert_STUB_COUNT(CFE_MSG_OriginationAction, 1); SeqCntExpected = 2; UT_SetDefaultReturnValue(UT_KEY(CFE_MSG_GetNextSequenceCount), SeqCntExpected); @@ -3049,7 +3051,8 @@ void Test_TransmitMsg_UpdateHeader(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SUCCESS(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); UtAssert_INT32_EQ(SeqCnt, SeqCntExpected); - UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 2); + UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 2); + UtAssert_STUB_COUNT(CFE_MSG_OriginationAction, 2); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 2); CFE_UtAssert_EVENTCOUNT(2); @@ -3063,7 +3066,8 @@ void Test_TransmitMsg_UpdateHeader(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetSize), &Size, sizeof(Size), false); UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SETUP(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); /* increment to 3 */ - UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 3); + UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 3); + UtAssert_STUB_COUNT(CFE_MSG_OriginationAction, 3); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 3); CFE_UtAssert_SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* resubscribe so we can receive a msg */ @@ -3075,7 +3079,8 @@ void Test_TransmitMsg_UpdateHeader(void) UT_SetDataBuffer(UT_KEY(CFE_MSG_GetType), &Type, sizeof(Type), false); CFE_UtAssert_SETUP(CFE_SB_TransmitMsg(CFE_MSG_PTR(TlmPkt.TelemetryHeader), true)); /* increment to 4 */ UtAssert_INT32_EQ(SeqCnt, SeqCntExpected); - UtAssert_STUB_COUNT(CFE_MSG_UpdateHeader, 4); + UtAssert_STUB_COUNT(CFE_MSG_SetSequenceCount, 4); + UtAssert_STUB_COUNT(CFE_MSG_OriginationAction, 4); UtAssert_STUB_COUNT(CFE_MSG_GetNextSequenceCount, 4); CFE_UtAssert_TEARDOWN(CFE_SB_DeletePipe(PipeId)); @@ -3326,8 +3331,8 @@ void Test_TransmitBuffer_IncrementSeqCnt(void) CFE_MSG_Size_t Size = sizeof(SB_UT_Test_Tlm_t); CFE_MSG_Type_t Type = CFE_MSG_Type_Tlm; - /* Set up hook for checking CFE_MSG_UpdateHeader calls */ - UT_SetHookFunction(UT_KEY(CFE_MSG_UpdateHeader), UT_CheckSetSequenceCount, &SeqCnt); + /* Set up hook for checking CFE_MSG_SetSequenceCount calls */ + UT_SetHookFunction(UT_KEY(CFE_MSG_SetSequenceCount), UT_CheckSetSequenceCount, &SeqCnt); CFE_UtAssert_SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyTestPipe")); diff --git a/modules/tbl/ut-coverage/tbl_UT.c b/modules/tbl/ut-coverage/tbl_UT.c index 77db831f9..113216dea 100644 --- a/modules/tbl/ut-coverage/tbl_UT.c +++ b/modules/tbl/ut-coverage/tbl_UT.c @@ -3037,6 +3037,7 @@ void Test_CFE_TBL_TblMod(void) CFE_TBL_Handle_t AccessIterator; uint8 CDS_Data[sizeof(UT_Table1_t)]; uint32 ExpectedCrc; + int maxPathLenDiff = (int) CFE_MISSION_MAX_PATH_LEN - (int) OS_MAX_PATH_LEN; memset(&TblInfo1, 0, sizeof(TblInfo1)); @@ -3177,13 +3178,22 @@ void Test_CFE_TBL_TblMod(void) UtAssert_INT32_EQ(CFE_TBL_GetAddress(&TblDataAddr, App1TblHandle1), CFE_TBL_INFO_UPDATED); /* - * LastFileLoaded (limited by mission) can be bigger than MyFilename (limited by osal), - * need to adjust length of check to account for difference and modified marking + * LastFileLoaded (limited by mission) can be bigger than MyFilename (limited by osal) */ - UtAssert_StrnCmp(TblInfo1.LastFileLoaded, MyFilename, sizeof(MyFilename) - 4, "%s == %s, %ld", - TblInfo1.LastFileLoaded, MyFilename, (long)sizeof(MyFilename) - 4); - UtAssert_StrCmp(&TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4], "(*)", "%s == (*)", - &TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4]); + UtAssert_StrnCmp(TblInfo1.LastFileLoaded, MyFilename, sizeof(TblInfo1.LastFileLoaded) - 4, "%s == %s, %ld", + TblInfo1.LastFileLoaded, MyFilename, (long)sizeof(TblInfo1.LastFileLoaded) - 4); + + if(maxPathLenDiff >= 0) + { + UtAssert_StrCmp(&TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4], "(*)", "%s == (*)", + &TblInfo1.LastFileLoaded[sizeof(MyFilename) - 4]); + } + else if(maxPathLenDiff > -3) + { + int modIndicatorStart = (int) CFE_MISSION_MAX_PATH_LEN -4 - maxPathLenDiff; + UtAssert_StrCmp(&TblInfo1.LastFileLoaded[modIndicatorStart], "(*)", "%s == (*)", + &TblInfo1.LastFileLoaded[modIndicatorStart]); + } /* Test response to an invalid handle */ UtAssert_INT32_EQ(CFE_TBL_Modified(CFE_TBL_BAD_TABLE_HANDLE), CFE_TBL_ERR_INVALID_HANDLE);