From 893c5ae24b6b0019120ddb9317fdb22df10f9a7d Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Fri, 5 Jun 2020 14:24:00 -0400 Subject: [PATCH 1/3] Fix #734, continue cleanup of SB unit test Makes the SB unit test closer to recommended UT assert patterns Do not keep a separate "TestStat" state variable outside UT assert. Do not report separate status messages from the asserts. Use UT assert. Do not "reset" in the middle of a test routine, split into separate test routines where this is done. No need for "START" and "STARTBLOCK" or "ENDBLOCK". UT assert has messages for these test actions. Each block should be a separate test routine and then these are unnecessary. --- fsw/cfe-core/unit-test/sb_UT.c | 2188 ++++++--------------------- fsw/cfe-core/unit-test/sb_UT.h | 79 +- fsw/cfe-core/unit-test/ut_support.c | 181 +-- fsw/cfe-core/unit-test/ut_support.h | 140 +- 4 files changed, 661 insertions(+), 1927 deletions(-) diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index fa045636d..53733a7d3 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -40,6 +40,17 @@ */ #include "sb_UT.h" +/* + * A method to add an SB "Subtest" + * + * As SB has a lot of test cases it is helpful to group them. + * This allows each test routine to reported consistently as "GroupName.TestName" + * + * This also implicitly includes a call to SB_ResetUnitTest() as a setup function, + * so the test routines do _not_ need to do this explictly on every test case. + */ +#define SB_UT_ADD_SUBTEST(Func) UT_AddSubTest(Func, SB_ResetUnitTest, NULL, __func__, #Func) + /* * MSG ID constants for unit testing: * Unit test cases should not directly use integer MsgId values @@ -97,10 +108,9 @@ const CFE_SB_MsgId_t SB_UT_ALTERNATE_INVALID_MID = CFE_SB_MSGID_WRAP_VALUE(CFE_P /* * A MsgId value which is valid per CCSDS but does not have the secondary header bit set */ -const CFE_SB_MsgId_t SB_UT_BARE_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x0003); - +const CFE_SB_MsgId_t SB_UT_BARE_CMD_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x1003); +const CFE_SB_MsgId_t SB_UT_BARE_TLM_MID3 = CFE_SB_MSGID_WRAP_VALUE(0x0003); -static char cMsg[UT_MAX_MESSAGE_LENGTH]; /* ** Functions @@ -110,24 +120,23 @@ void UtTest_Setup(void) UT_Init("sb"); UT_Text("cFE SB Unit Test Output File\n\n"); - UT_ADD_TEST(Test_SB_AppInit); - UT_ADD_TEST(Test_SB_MainRoutine); - UT_ADD_TEST(Test_SB_Cmds); - UT_ADD_TEST(Test_SB_EarlyInit); - UT_ADD_TEST(Test_CreatePipe_API); - UT_ADD_TEST(Test_DeletePipe_API); - UT_ADD_TEST(Test_PipeOpts_API); - UT_ADD_TEST(Test_GetPipeName_API); - UT_ADD_TEST(Test_GetPipeIdByName_API); - UT_ADD_TEST(Test_Subscribe_API); - UT_ADD_TEST(Test_Unsubscribe_API); - UT_ADD_TEST(Test_SendMsg_API); + Test_SB_AppInit(); + Test_SB_MainRoutine(); + Test_SB_Cmds(); + Test_SB_EarlyInit(); + Test_CreatePipe_API(); + Test_DeletePipe_API(); + Test_PipeOpts_API(); + Test_GetPipeName_API(); + Test_GetPipeIdByName_API(); + Test_Subscribe_API(); + Test_Unsubscribe_API(); + Test_SendMsg_API(); UtTest_Add(Test_RcvMsg_API, NULL, Test_CleanupApp_API, "Test_RcvMsg_API"); UT_ADD_TEST(Test_SB_Utils); - UtTest_Add(Test_SB_SpecialCases, NULL, UT_CheckForOpenSockets, - "Test_SB_SpecialCases"); - UT_ADD_TEST(Test_SB_Macros); + Test_SB_SpecialCases(); + Test_SB_Macros(); } /* end main */ @@ -137,12 +146,8 @@ void UtTest_Setup(void) */ void Test_SB_Macros(void) { - STARTBLOCK(); - - Test_SB_CCSDSPriHdr_Macros(); - Test_SB_CCSDSSecHdr_Macros(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SB_CCSDSPriHdr_Macros); + SB_UT_ADD_SUBTEST(Test_SB_CCSDSSecHdr_Macros); } /* end Test_SB_Macros */ /* @@ -152,91 +157,49 @@ void Test_SB_CCSDSSecHdr_Macros(void) { CFE_SB_CmdHdr_t NoParamPkt; - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_CMDSEC_HDR(NoParamPkt.Cmd.Sec); CCSDS_WR_FC(NoParamPkt.Cmd.Sec, 1); ASSERT_TRUE(CCSDS_RD_FC(NoParamPkt.Cmd.Sec) == 0x01); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_CMDSEC_HDR(NoParamPkt.Cmd.Sec); CCSDS_WR_CHECKSUM(NoParamPkt.Cmd.Sec, 0xFF); ASSERT_TRUE(CCSDS_RD_CHECKSUM(NoParamPkt.Cmd.Sec) == 0xFF); - REPORT(); #ifdef MESSAGE_FORMAT_IS_CCSDS_VER_2 - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_SEC_APIDQ(NoParamPkt.Cmd.SpacePacket.ApidQ); CCSDS_WR_EDS_VER(NoParamPkt.Cmd.SpacePacket.ApidQ, 0x01); ASSERT_TRUE(CCSDS_RD_EDS_VER(NoParamPkt.Cmd.SpacePacket.ApidQ) == 0x01); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_SEC_APIDQ(NoParamPkt.Cmd.SpacePacket.ApidQ); CCSDS_WR_ENDIAN(NoParamPkt.Cmd.SpacePacket.ApidQ, 0x01); ASSERT_TRUE(CCSDS_RD_ENDIAN(NoParamPkt.Cmd.SpacePacket.ApidQ) == 0x01); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_SEC_APIDQ(NoParamPkt.Cmd.SpacePacket.ApidQ); CCSDS_WR_PLAYBACK(NoParamPkt.Cmd.SpacePacket.ApidQ, 0x01); ASSERT_TRUE(CCSDS_RD_PLAYBACK(NoParamPkt.Cmd.SpacePacket.ApidQ) == 0x01); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_SEC_APIDQ(NoParamPkt.Cmd.SpacePacket.ApidQ); CCSDS_WR_SUBSYSTEM_ID(NoParamPkt.Cmd.SpacePacket.ApidQ, 0xFF); ASSERT_TRUE(CCSDS_RD_SUBSYSTEM_ID(NoParamPkt.Cmd.SpacePacket.ApidQ) == 0xFF); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_SEC_APIDQ(NoParamPkt.Cmd.SpacePacket.ApidQ); CCSDS_WR_SUBSYSTEM_ID(NoParamPkt.Cmd.SpacePacket.ApidQ, 0xFF); ASSERT_TRUE(CCSDS_RD_SUBSYSTEM_ID(NoParamPkt.Cmd.SpacePacket.ApidQ) == 0xFF); - SB_ResetUnitTest(); - CCSDS_CLR_SEC_APIDQ(NoParamPkt.Cmd.SpacePacket.ApidQ); CCSDS_WR_SYSTEM_ID(NoParamPkt.Cmd.SpacePacket.ApidQ, 0xFFFF); ASSERT_TRUE(CCSDS_RD_SYSTEM_ID(NoParamPkt.Cmd.SpacePacket.ApidQ) == 0xFFFF); - REPORT(); #endif } /* end Test_SB_CCSDSSecHdr_Macros */ @@ -247,93 +210,46 @@ void Test_SB_CCSDSPriHdr_Macros(void) { CFE_SB_Msg_t Msg; - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_SID(Msg.Hdr, 0x1899); ASSERT_TRUE(CCSDS_RD_SID(Msg.Hdr) == 0x1899); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_APID(Msg.Hdr, 0x07FF); ASSERT_TRUE(CCSDS_RD_APID(Msg.Hdr) == 0x07FF); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_SHDR(Msg.Hdr, 1); ASSERT_TRUE(CCSDS_RD_SHDR(Msg.Hdr) == 1); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_TYPE(Msg.Hdr, 1); ASSERT_TRUE(CCSDS_RD_TYPE(Msg.Hdr) == 1); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_VERS(Msg.Hdr, 1); ASSERT_TRUE(CCSDS_RD_VERS(Msg.Hdr) == 1); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_SEQ(Msg.Hdr, 0x3FFF); ASSERT_TRUE(CCSDS_RD_SEQ(Msg.Hdr) == 0x3FFF); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_SEQFLG(Msg.Hdr, 0x03); ASSERT_TRUE(CCSDS_RD_SEQFLG(Msg.Hdr) == 0x03); - REPORT(); - - START(); - - SB_ResetUnitTest(); - CCSDS_CLR_PRI_HDR(Msg.Hdr); CCSDS_WR_LEN(Msg.Hdr, 0xFFFF); ASSERT_TRUE(CCSDS_RD_LEN(Msg.Hdr) == 0xFFFF); - REPORT(); } /* end Test_SB_CCSDSPriHdr_Macros */ /* @@ -353,18 +269,14 @@ void SB_ResetUnitTest(void) */ void Test_SB_AppInit(void) { - STARTBLOCK(); - - Test_SB_AppInit_ESRegFail(); - Test_SB_AppInit_EVSRegFail(); - Test_SB_AppInit_EVSSendEvtFail(); - Test_SB_AppInit_CrPipeFail(); - Test_SB_AppInit_Sub1Fail(); - Test_SB_AppInit_Sub2Fail(); - Test_SB_AppInit_GetPoolFail(); - Test_SB_AppInit_PutPoolFail(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_ESRegFail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_EVSRegFail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_EVSSendEvtFail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_CrPipeFail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_Sub1Fail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_Sub2Fail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_GetPoolFail); + SB_UT_ADD_SUBTEST(Test_SB_AppInit_PutPoolFail); } /* end Test_SB_AppInit */ /* @@ -374,15 +286,11 @@ void Test_SB_AppInit_ESRegFail(void) { int32 ForcedRtnVal = -1; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterApp), 1, ForcedRtnVal); ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); EVTCNT(0); - REPORT(); } /* end Test_SB_AppInit_ESRegFail */ /* @@ -392,15 +300,11 @@ void Test_SB_AppInit_EVSRegFail(void) { int32 ForcedRtnVal = -1; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, ForcedRtnVal); ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); EVTCNT(0); - REPORT(); } /* end Test_SB_AppInit_EVSRegFail */ /* @@ -411,10 +315,6 @@ void Test_SB_AppInit_EVSSendEvtFail(void) int32 ForcedRtnVal = -1; CFE_ES_TaskInfo_t TestTaskInfo; - START(); - - SB_ResetUnitTest(); - /* To get coverage on CFE_SB_GetAppTskName(), this ensures that the * path with different app/task names is followed on at least one event. */ @@ -433,7 +333,6 @@ void Test_SB_AppInit_EVSSendEvtFail(void) TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); - REPORT(); } /* end Test_SB_AppInit_EVSSendEvtFail */ /* @@ -441,10 +340,6 @@ void Test_SB_AppInit_EVSSendEvtFail(void) */ void Test_SB_AppInit_CrPipeFail(void) { - START(); - - SB_ResetUnitTest(); - /* To fail the pipe create, force the OS_QueueCreate call to return some * type of error code. */ @@ -455,7 +350,6 @@ void Test_SB_AppInit_CrPipeFail(void) EVTSENT(CFE_SB_CR_PIPE_ERR_EID); - REPORT(); } /* end Test_SB_AppInit_CrPipeFail */ /* @@ -465,9 +359,6 @@ void Test_SB_AppInit_Sub1Fail(void) { CFE_SB_PipeId_t PipeId = 0; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, -1); ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR); @@ -477,7 +368,6 @@ void Test_SB_AppInit_Sub1Fail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_AppInit_Sub1Fail */ /* @@ -487,9 +377,6 @@ void Test_SB_AppInit_Sub2Fail(void) { CFE_SB_PipeId_t PipeId = 0; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 2, -1); ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR); @@ -499,7 +386,6 @@ void Test_SB_AppInit_Sub2Fail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_AppInit_Sub2Fail */ /* @@ -510,9 +396,6 @@ void Test_SB_AppInit_GetPoolFail(void) CFE_SB_PipeId_t PipeId = 0; int32 ForcedRtnVal = -1; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 4, ForcedRtnVal); ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); @@ -521,7 +404,6 @@ void Test_SB_AppInit_GetPoolFail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_AppInit_GetPoolFail */ /* @@ -532,9 +414,6 @@ void Test_SB_AppInit_PutPoolFail(void) CFE_SB_PipeId_t PipeId = 0; int32 ForcedRtnVal = -1; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, ForcedRtnVal); ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); @@ -543,7 +422,6 @@ void Test_SB_AppInit_PutPoolFail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_AppInit_PutPoolFail */ /* @@ -551,12 +429,8 @@ void Test_SB_AppInit_PutPoolFail(void) */ void Test_SB_MainRoutine(void) { - STARTBLOCK(); - - Test_SB_Main_RcvErr(); - Test_SB_Main_InitErr(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SB_Main_RcvErr); + SB_UT_ADD_SUBTEST(Test_SB_Main_InitErr); } /* end Test_SB_MainRoutine */ /* @@ -566,9 +440,6 @@ void Test_SB_Main_RcvErr(void) { CFE_SB_PipeId_t PipeId = 0; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, -1); CFE_SB_TaskMain(); @@ -580,7 +451,6 @@ void Test_SB_Main_RcvErr(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_Main_RcvErr */ /* @@ -590,16 +460,13 @@ void Test_SB_Main_InitErr(void) { CFE_SB_PipeId_t PipeId = 0; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_TaskMain(); EVTCNT(7); TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); + } /* end Test_SB_Main_InitErr */ /* @@ -607,45 +474,42 @@ void Test_SB_Main_InitErr(void) */ void Test_SB_Cmds(void) { - STARTBLOCK(); - - Test_SB_Cmds_Noop(); - Test_SB_Cmds_RstCtrs(); - Test_SB_Cmds_Stats(); - Test_SB_Cmds_RoutingInfoDef(); - Test_SB_Cmds_RoutingInfoSpec(); - Test_SB_Cmds_RoutingInfoCreateFail(); - Test_SB_Cmds_RoutingInfoHdrFail(); - Test_SB_Cmds_RoutingInfoWriteFail(); - Test_SB_Cmds_PipeInfoDef(); - Test_SB_Cmds_PipeInfoSpec(); - Test_SB_Cmds_PipeInfoCreateFail(); - Test_SB_Cmds_PipeInfoHdrFail(); - Test_SB_Cmds_PipeInfoWriteFail(); - Test_SB_Cmds_MapInfoDef(); - Test_SB_Cmds_MapInfoSpec(); - Test_SB_Cmds_MapInfoCreateFail(); - Test_SB_Cmds_MapInfoHdrFail(); - Test_SB_Cmds_MapInfoWriteFail(); - Test_SB_Cmds_EnRouteValParam(); - Test_SB_Cmds_EnRouteNonExist(); - Test_SB_Cmds_EnRouteInvParam(); - Test_SB_Cmds_EnRouteInvParam2(); - Test_SB_Cmds_EnRouteInvParam3(); - Test_SB_Cmds_DisRouteValParam(); - Test_SB_Cmds_DisRouteNonExist(); - Test_SB_Cmds_DisRouteInvParam(); - Test_SB_Cmds_DisRouteInvParam2(); - Test_SB_Cmds_DisRouteInvParam3(); - Test_SB_Cmds_SendHK(); - Test_SB_Cmds_SendPrevSubs(); - Test_SB_Cmds_SubRptOn(); - Test_SB_Cmds_SubRptOff(); - Test_SB_Cmds_UnexpCmdCode(); - Test_SB_Cmds_BadCmdLength(); - Test_SB_Cmds_UnexpMsgId(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_Noop); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_RstCtrs); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_Stats); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoDef); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoSpec); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoCreateFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoHdrFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_RoutingInfoWriteFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoDef); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoSpec); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoCreateFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoHdrFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_PipeInfoWriteFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoDef); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoSpec); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoCreateFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoHdrFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_MapInfoWriteFail); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteValParam); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteNonExist); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteInvParam); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteInvParam2); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_EnRouteInvParam3); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteValParam); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteNonExist); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteInvParam); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteInvParam2); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_DisRouteInvParam3); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_SendHK); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_SendPrevSubs); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptOn); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptOff); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_CmdUnexpCmdCode); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_SubRptUnexpCmdCode); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_BadCmdLength); + SB_UT_ADD_SUBTEST(Test_SB_Cmds_UnexpMsgId); } /* end Test_SB_Cmds */ /* @@ -655,9 +519,6 @@ void Test_SB_Cmds_Noop(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_NOOP_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; @@ -667,7 +528,6 @@ void Test_SB_Cmds_Noop(void) EVTSENT(CFE_SB_CMD0_RCVD_EID); - REPORT(); } /* end Test_SB_Cmds_Noop */ /* @@ -677,9 +537,6 @@ void Test_SB_Cmds_RstCtrs(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_RESET_COUNTERS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; @@ -689,7 +546,6 @@ void Test_SB_Cmds_RstCtrs(void) EVTSENT(CFE_SB_CMD1_RCVD_EID); - REPORT(); } /* Test_SB_Cmds_RstCtrs */ /* @@ -699,9 +555,6 @@ void Test_SB_Cmds_Stats(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_SEND_SB_STATS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; @@ -713,7 +566,6 @@ void Test_SB_Cmds_Stats(void) EVTSENT(CFE_SB_SND_STATS_EID); - REPORT(); } /* end Test_SB_Cmds_Stats */ /* @@ -724,9 +576,6 @@ void Test_SB_Cmds_RoutingInfoDef(void) CFE_SB_PipeId_t PipeId = 0; CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -752,7 +601,6 @@ void Test_SB_Cmds_RoutingInfoDef(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_Cmds_RoutingInfoDef */ /* @@ -762,9 +610,6 @@ void Test_SB_Cmds_RoutingInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); SETUP(CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -778,7 +623,6 @@ void Test_SB_Cmds_RoutingInfoSpec(void) EVTSENT(CFE_SB_SND_RTG_EID); - REPORT(); } /* end Test_SB_Cmds_RoutingInfoSpec */ /* @@ -788,9 +632,6 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -807,7 +648,6 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) EVTSENT(CFE_SB_SND_RTG_ERR1_EID); - REPORT(); } /* end Test_SB_Cmds_RoutingInfoCreateFail */ /* @@ -815,9 +655,6 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) */ void Test_SB_Cmds_RoutingInfoHdrFail(void) { - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); @@ -826,7 +663,6 @@ void Test_SB_Cmds_RoutingInfoHdrFail(void) EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - REPORT(); } /* end Test_SB_Cmds_RoutingInfoHdrFail */ /* @@ -837,10 +673,6 @@ void Test_SB_Cmds_RoutingInfoWriteFail(void) { CFE_SB_PipeId_t PipeId = 0; - START(); - - SB_ResetUnitTest(); - /* Make some routing info by calling CFE_SB_AppInit */ SETUP(CFE_SB_AppInit()); @@ -860,7 +692,6 @@ void Test_SB_Cmds_RoutingInfoWriteFail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_Cmds_RoutingInfoWriteFail */ /* @@ -874,9 +705,6 @@ void Test_SB_Cmds_PipeInfoDef(void) CFE_SB_PipeId_t PipeId3; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -900,7 +728,6 @@ void Test_SB_Cmds_PipeInfoDef(void) TEARDOWN(CFE_SB_DeletePipe(PipeId2)); TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - REPORT(); } /* end Test_SB_Cmds_PipeInfoDef */ /* @@ -910,9 +737,6 @@ void Test_SB_Cmds_PipeInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -925,7 +749,6 @@ void Test_SB_Cmds_PipeInfoSpec(void) EVTSENT(CFE_SB_SND_RTG_EID); - REPORT(); } /* end Test_SB_Cmds_PipeInfoSpec */ /* @@ -933,9 +756,6 @@ void Test_SB_Cmds_PipeInfoSpec(void) */ void Test_SB_Cmds_PipeInfoCreateFail(void) { - START(); - - SB_ResetUnitTest(); UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR); ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); @@ -943,7 +763,6 @@ void Test_SB_Cmds_PipeInfoCreateFail(void) EVTSENT(CFE_SB_SND_RTG_ERR1_EID); - REPORT(); } /* end Test_SB_Cmds_PipeInfoCreateFail */ /* @@ -951,9 +770,6 @@ void Test_SB_Cmds_PipeInfoCreateFail(void) */ void Test_SB_Cmds_PipeInfoHdrFail(void) { - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); @@ -961,7 +777,6 @@ void Test_SB_Cmds_PipeInfoHdrFail(void) EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - REPORT(); } /* end Test_SB_Cmds_PipeInfoHdrFail */ /* @@ -975,10 +790,6 @@ void Test_SB_Cmds_PipeInfoWriteFail(void) CFE_SB_PipeId_t PipeId3; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); @@ -996,7 +807,6 @@ void Test_SB_Cmds_PipeInfoWriteFail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId2)); TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - REPORT(); } /* end Test_SB_Cmds_PipeInfoWriteFail */ /* @@ -1016,9 +826,6 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -1052,7 +859,6 @@ void Test_SB_Cmds_MapInfoDef(void) TEARDOWN(CFE_SB_DeletePipe(PipeId2)); TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - REPORT(); } /* end Test_SB_Cmds_MapInfoDef */ /* @@ -1062,9 +868,6 @@ void Test_SB_Cmds_MapInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(WriteFileCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, @@ -1077,7 +880,6 @@ void Test_SB_Cmds_MapInfoSpec(void) EVTSENT(CFE_SB_SND_RTG_EID); - REPORT(); } /* end Test_SB_Cmds_MapInfoSpec */ /* @@ -1085,9 +887,6 @@ void Test_SB_Cmds_MapInfoSpec(void) */ void Test_SB_Cmds_MapInfoCreateFail(void) { - START(); - - SB_ResetUnitTest(); UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR); ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); @@ -1095,7 +894,6 @@ void Test_SB_Cmds_MapInfoCreateFail(void) EVTSENT(CFE_SB_SND_RTG_ERR1_EID); - REPORT(); } /* end Test_SB_Cmds_MapInfoCreateFail */ /* @@ -1103,9 +901,6 @@ void Test_SB_Cmds_MapInfoCreateFail(void) */ void Test_SB_Cmds_MapInfoHdrFail(void) { - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); @@ -1113,7 +908,6 @@ void Test_SB_Cmds_MapInfoHdrFail(void) EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - REPORT(); } /* end Test_SB_Cmds_MapInfoHdrFail */ /* @@ -1133,10 +927,6 @@ void Test_SB_Cmds_MapInfoWriteFail(void) CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); - /* Create some map info */ SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); @@ -1164,7 +954,6 @@ void Test_SB_Cmds_MapInfoWriteFail(void) TEARDOWN(CFE_SB_DeletePipe(PipeId2)); TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - REPORT(); } /* end Test_SB_Cmds_MapInfoWriteFail */ /* @@ -1177,9 +966,6 @@ void Test_SB_Cmds_EnRouteValParam(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "EnRouteTestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), @@ -1202,7 +988,6 @@ void Test_SB_Cmds_EnRouteValParam(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_Cmds_EnRouteValParam */ /* @@ -1216,9 +1001,6 @@ void Test_SB_Cmds_EnRouteNonExist(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "EnRouteTestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "EnRouteTestPipe2")); SETUP(CFE_SB_Subscribe(MsgId, PipeId1)); @@ -1241,7 +1023,6 @@ void Test_SB_Cmds_EnRouteNonExist(void) TEARDOWN(CFE_SB_DeletePipe(PipeId1)); TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - REPORT(); } /* end Test_SB_Cmds_EnRouteNonExist */ /* @@ -1251,9 +1032,6 @@ void Test_SB_Cmds_EnRouteInvParam(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -1268,7 +1046,6 @@ void Test_SB_Cmds_EnRouteInvParam(void) EVTSENT(CFE_SB_ENBL_RTE3_EID); - REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam */ /* @@ -1278,9 +1055,6 @@ void Test_SB_Cmds_EnRouteInvParam2(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -1295,7 +1069,6 @@ void Test_SB_Cmds_EnRouteInvParam2(void) EVTSENT(CFE_SB_ENBL_RTE3_EID); - REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam2 */ /* @@ -1306,9 +1079,6 @@ void Test_SB_Cmds_EnRouteInvParam3(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -1323,7 +1093,6 @@ void Test_SB_Cmds_EnRouteInvParam3(void) EVTSENT(CFE_SB_ENBL_RTE3_EID); - REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam3 */ /* @@ -1336,9 +1105,6 @@ void Test_SB_Cmds_DisRouteValParam(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "DisRouteTestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), @@ -1360,7 +1126,6 @@ void Test_SB_Cmds_DisRouteValParam(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_Cmds_DisRouteValParam */ /* @@ -1373,9 +1138,6 @@ void Test_SB_Cmds_DisRouteNonExist(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "DisRouteTestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "DisRouteTestPipe2")); SETUP(CFE_SB_Subscribe(MsgId, PipeId1)); @@ -1398,7 +1160,6 @@ void Test_SB_Cmds_DisRouteNonExist(void) TEARDOWN(CFE_SB_DeletePipe(PipeId1)); TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - REPORT(); } /* end Test_SB_Cmds_DisRouteNonExist */ /* @@ -1408,9 +1169,6 @@ void Test_SB_Cmds_DisRouteInvParam(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -1425,7 +1183,6 @@ void Test_SB_Cmds_DisRouteInvParam(void) EVTSENT(CFE_SB_DSBL_RTE3_EID); - REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam */ /* @@ -1435,9 +1192,6 @@ void Test_SB_Cmds_DisRouteInvParam2(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -1452,7 +1206,6 @@ void Test_SB_Cmds_DisRouteInvParam2(void) EVTSENT(CFE_SB_DSBL_RTE3_EID); - REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam2 */ /* @@ -1463,9 +1216,6 @@ void Test_SB_Cmds_DisRouteInvParam3(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -1480,7 +1230,6 @@ void Test_SB_Cmds_DisRouteInvParam3(void) EVTSENT(CFE_SB_DSBL_RTE3_EID); - REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam3 */ /* @@ -1490,9 +1239,6 @@ void Test_SB_Cmds_SendHK(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_SEND_HK_MID), sizeof(NoParamCmd), true); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; @@ -1503,7 +1249,6 @@ void Test_SB_Cmds_SendHK(void) EVTSENT(CFE_SB_SEND_NO_SUBS_EID); - REPORT(); } /* end Test_SB_Cmds_SendHK */ /* @@ -1515,15 +1260,12 @@ void Test_SB_Cmds_SendPrevSubs(void) CFE_SB_SendPrevSubs_t NoParamCmd; CFE_SB_PipeId_t PipeId1; CFE_SB_PipeId_t PipeId2; - CFE_SB_MsgId_t MsgId = SB_UT_BARE_MID3; + CFE_SB_MsgId_t MsgId = SB_UT_BARE_TLM_MID3; uint16 MsgLim = 4; uint16 PipeDepth = 50; int32 i; int32 NumEvts; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), sizeof(CFE_SB_SendPrevSubs_t), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_SEND_PREV_SUBS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; @@ -1581,7 +1323,6 @@ void Test_SB_Cmds_SendPrevSubs(void) TEARDOWN(CFE_SB_DeletePipe(PipeId1)); TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - REPORT(); } /* end Test_SB_Cmds_SendPrevSubs */ /* @@ -1591,9 +1332,6 @@ void Test_SB_Cmds_SubRptOn(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, @@ -1603,7 +1341,6 @@ void Test_SB_Cmds_SubRptOn(void) EVTCNT(0); - REPORT(); } /* end Test_SB_Cmds_SubRptOn */ /* @@ -1613,9 +1350,6 @@ void Test_SB_Cmds_SubRptOff(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, @@ -1625,19 +1359,15 @@ void Test_SB_Cmds_SubRptOff(void) EVTCNT(0); - REPORT(); } /* end Test_SB_Cmds_SubRptOff */ /* ** Test command handler response to an invalid command code */ -void Test_SB_Cmds_UnexpCmdCode(void) +void Test_SB_Cmds_CmdUnexpCmdCode(void) { CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); /* Use a command code known to be invalid */ @@ -1647,9 +1377,15 @@ void Test_SB_Cmds_UnexpCmdCode(void) EVTCNT(1); EVTSENT(CFE_SB_BAD_CMD_CODE_EID); - /* Same test for subscription reporting control MID */ - START(); - SB_ResetUnitTest(); +} /* end Test_SB_Cmds_UnexpCmdCode */ + +/* +** Test command handler response to an invalid command code +*/ +void Test_SB_Cmds_SubRptUnexpCmdCode(void) +{ + CFE_SB_CmdHdr_t NoParamCmd; + CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), sizeof(NoParamCmd), true); /* Use a command code known to be invalid */ @@ -1661,7 +1397,6 @@ void Test_SB_Cmds_UnexpCmdCode(void) EVTSENT(CFE_SB_BAD_CMD_CODE_EID); - REPORT(); } /* end Test_SB_Cmds_UnexpCmdCode */ /* @@ -1674,7 +1409,6 @@ void Test_SB_Cmds_BadCmdLength(void) */ CFE_SB_EnableRoute_t EnableRouteCmd; - SB_ResetUnitTest(); CFE_SB_InitMsg(&EnableRouteCmd, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnableRouteCmd) - 1, true); /* Use a command code known to be invalid */ @@ -1686,7 +1420,6 @@ void Test_SB_Cmds_BadCmdLength(void) EVTSENT(CFE_SB_LEN_ERR_EID); - REPORT(); } /* end Test_SB_Cmds_BadCmdLength */ /* @@ -1697,9 +1430,6 @@ void Test_SB_Cmds_UnexpMsgId(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_CmdHdr_t NoParamCmd; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, MsgId, sizeof(NoParamCmd), true); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); @@ -1708,7 +1438,6 @@ void Test_SB_Cmds_UnexpMsgId(void) EVTSENT(CFE_SB_BAD_MSGID_EID); - REPORT(); } /* end Test_SB_Cmds_UnexpMsgId */ /* @@ -1716,13 +1445,9 @@ void Test_SB_Cmds_UnexpMsgId(void) */ void Test_SB_EarlyInit(void) { - STARTBLOCK(); - - Test_SB_EarlyInit_SemCreateError(); - Test_SB_EarlyInit_PoolCreateError(); - Test_SB_EarlyInit_NoErrors(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SB_EarlyInit_SemCreateError); + SB_UT_ADD_SUBTEST(Test_SB_EarlyInit_PoolCreateError); + SB_UT_ADD_SUBTEST(Test_SB_EarlyInit_NoErrors); } /* end Test_SB_EarlyInit */ /* @@ -1730,9 +1455,6 @@ void Test_SB_EarlyInit(void) */ void Test_SB_EarlyInit_SemCreateError(void) { - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERR_NO_FREE_IDS); UT_Report(__FILE__, __LINE__, CFE_SB_EarlyInit() == OS_ERR_NO_FREE_IDS, @@ -1744,9 +1466,6 @@ void Test_SB_EarlyInit_SemCreateError(void) */ void Test_SB_EarlyInit_PoolCreateError(void) { - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PoolCreateEx), 1, CFE_ES_BAD_ARGUMENT); UT_Report(__FILE__, __LINE__, CFE_SB_EarlyInit() == CFE_ES_BAD_ARGUMENT, @@ -1758,9 +1477,6 @@ void Test_SB_EarlyInit_PoolCreateError(void) */ void Test_SB_EarlyInit_NoErrors(void) { - START(); - - SB_ResetUnitTest(); CFE_SB_EarlyInit(); UT_Report(__FILE__, __LINE__, CFE_SB_EarlyInit() == CFE_SUCCESS, @@ -1772,15 +1488,11 @@ void Test_SB_EarlyInit_NoErrors(void) */ void Test_CreatePipe_API(void) { - STARTBLOCK(); - - Test_CreatePipe_NullPtr(); - Test_CreatePipe_ValPipeDepth(); - Test_CreatePipe_InvalPipeDepth(); - Test_CreatePipe_MaxPipes(); - Test_CreatePipe_SamePipeName(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_CreatePipe_NullPtr); + SB_UT_ADD_SUBTEST(Test_CreatePipe_ValPipeDepth); + SB_UT_ADD_SUBTEST(Test_CreatePipe_InvalPipeDepth); + SB_UT_ADD_SUBTEST(Test_CreatePipe_MaxPipes); + SB_UT_ADD_SUBTEST(Test_CreatePipe_SamePipeName); } /* end Test_CreatePipe_API */ /* @@ -1790,10 +1502,6 @@ void Test_CreatePipe_NullPtr(void) { uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); - /* This provides completion of code coverage in CFE_SB_GetAppTskName() */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetTaskInfo), 1, CFE_ES_ERR_APPID); @@ -1804,7 +1512,6 @@ void Test_CreatePipe_NullPtr(void) EVTSENT(CFE_SB_CR_PIPE_BAD_ARG_EID); - REPORT(); } /* end Test_CreatePipe_NullPtr */ /* @@ -1814,10 +1521,6 @@ void Test_CreatePipe_ValPipeDepth(void) { CFE_SB_PipeId_t PipeIdReturned[3]; - START(); - - /* Test a few valid pipe depth values */ - SB_ResetUnitTest(); ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[0], 99, "TestPipe99")); ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[1], 255, "TestPipe255")); ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[2], @@ -1831,7 +1534,6 @@ void Test_CreatePipe_ValPipeDepth(void) TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[1])); TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[2])); - REPORT(); } /* end Test_CreatePipe_ValPipeDepth */ /* @@ -1841,10 +1543,6 @@ void Test_CreatePipe_InvalPipeDepth(void) { CFE_SB_PipeId_t PipeIdReturned[3]; - START(); - - /* Test a few invalid pipe depth values */ - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); /* Avoid creating socket */ ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[0], 0, "TestPipe1"), CFE_SB_BAD_ARGUMENT); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); @@ -1857,7 +1555,6 @@ void Test_CreatePipe_InvalPipeDepth(void) EVTSENT(CFE_SB_CR_PIPE_BAD_ARG_EID); - REPORT(); } /* end Test_CreatePipe_InvalPipeDepth */ /* @@ -1870,14 +1567,10 @@ void Test_CreatePipe_MaxPipes(void) int32 i; char PipeName[OS_MAX_API_NAME]; - START(); - - SB_ResetUnitTest(); - /* Create maximum number of pipes + 1. Only one 'create pipe' failure * expected */ - for (i = 0; TestStat == CFE_PASS && i < CFE_PLATFORM_SB_MAX_PIPES + 1; i++) + for (i = 0; i < (CFE_PLATFORM_SB_MAX_PIPES + 1); i++) { snprintf(PipeName, OS_MAX_API_NAME, "TestPipe%ld", (long) i); @@ -1899,7 +1592,6 @@ void Test_CreatePipe_MaxPipes(void) TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[i])); } - REPORT(); } /* end Test_CreatePipe_MaxPipes */ /* @@ -1912,10 +1604,6 @@ void Test_CreatePipe_SamePipeName(void) uint16 PipeDepth = 1; char PipeName[] = "Test_CFE_SB"; - START(); - - SB_ResetUnitTest(); - /* Need to make sure OS_QueueCreate() stub fails on second call */ /* to mimick the failure expected when passing the same pipe name */ UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 2, OS_ERR_NAME_TAKEN); @@ -1937,7 +1625,6 @@ void Test_CreatePipe_SamePipeName(void) /* Call to CFE_SB_DeletePipe with the first pipe id created should work fine */ TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* @@ -1945,15 +1632,11 @@ void Test_CreatePipe_SamePipeName(void) */ void Test_DeletePipe_API(void) { - STARTBLOCK(); - - Test_DeletePipe_NoSubs(); - Test_DeletePipe_WithSubs(); - Test_DeletePipe_InvalidPipeId(); - Test_DeletePipe_InvalidPipeOwner(); - Test_DeletePipe_WithAppid(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_DeletePipe_NoSubs); + SB_UT_ADD_SUBTEST(Test_DeletePipe_WithSubs); + SB_UT_ADD_SUBTEST(Test_DeletePipe_InvalidPipeId); + SB_UT_ADD_SUBTEST(Test_DeletePipe_InvalidPipeOwner); + SB_UT_ADD_SUBTEST(Test_DeletePipe_WithAppid); } /* end Test_DeletePipe_API */ /* @@ -1964,9 +1647,6 @@ void Test_DeletePipe_NoSubs(void) CFE_SB_PipeId_t PipedId; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); ASSERT(CFE_SB_DeletePipe(PipedId)); @@ -1975,7 +1655,6 @@ void Test_DeletePipe_NoSubs(void) EVTSENT(CFE_SB_PIPE_ADDED_EID); EVTSENT(CFE_SB_PIPE_DELETED_EID); - REPORT(); } /* end Test_DeletePipe_NoSubs */ /* @@ -1990,9 +1669,6 @@ void Test_DeletePipe_WithSubs(void) CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID4; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId0, PipedId)); SETUP(CFE_SB_Subscribe(MsgId1, PipedId)); @@ -2005,7 +1681,6 @@ void Test_DeletePipe_WithSubs(void) EVTSENT(CFE_SB_PIPE_ADDED_EID); EVTSENT(CFE_SB_PIPE_DELETED_EID); - REPORT(); } /* end Test_DeletePipe_WithSubs */ /* @@ -2015,17 +1690,12 @@ void Test_DeletePipe_InvalidPipeId(void) { CFE_SB_PipeId_t PipeId = 30; - START(); - - SB_ResetUnitTest(); - ASSERT_EQ(CFE_SB_DeletePipe(PipeId), CFE_SB_BAD_ARGUMENT); EVTCNT(1); EVTSENT(CFE_SB_DEL_PIPE_ERR1_EID); - REPORT(); } /* end Test_DeletePipe_InvalidPipeId */ /* @@ -2037,9 +1707,6 @@ void Test_DeletePipe_InvalidPipeOwner(void) uint32 RealOwner; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); /* Change owner of pipe through memory corruption */ @@ -2057,7 +1724,6 @@ void Test_DeletePipe_InvalidPipeOwner(void) CFE_SB.PipeTbl[PipedId].AppId = RealOwner; TEARDOWN(CFE_SB_DeletePipe(PipedId)); - REPORT(); } /* end Test_DeletePipe_InvalidPipeId */ /* @@ -2069,9 +1735,6 @@ void Test_DeletePipe_WithAppid(void) uint32 AppId = 0; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID1, PipedId)); SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID2, PipedId)); @@ -2082,7 +1745,6 @@ void Test_DeletePipe_WithAppid(void) EVTCNT(14); - REPORT(); } /* end Test_DeletePipe_WithAppid */ /* @@ -2090,16 +1752,12 @@ void Test_DeletePipe_WithAppid(void) */ void Test_PipeOpts_API(void) { - STARTBLOCK(); - - Test_SetPipeOpts_BadID(); - Test_SetPipeOpts_NotOwner(); - Test_SetPipeOpts(); - Test_GetPipeOpts_BadID(); - Test_GetPipeOpts_BadPtr(); - Test_GetPipeOpts(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SetPipeOpts_BadID); + SB_UT_ADD_SUBTEST(Test_SetPipeOpts_NotOwner); + SB_UT_ADD_SUBTEST(Test_SetPipeOpts); + SB_UT_ADD_SUBTEST(Test_GetPipeOpts_BadID); + SB_UT_ADD_SUBTEST(Test_GetPipeOpts_BadPtr); + SB_UT_ADD_SUBTEST(Test_GetPipeOpts); } /* end Test_PipeOpts_API */ /* @@ -2107,13 +1765,9 @@ void Test_PipeOpts_API(void) */ void Test_GetPipeName_API(void) { - STARTBLOCK(); - - Test_GetPipeName_NullPtr(); - Test_GetPipeName_InvalidId(); - Test_GetPipeName(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_GetPipeName_NullPtr); + SB_UT_ADD_SUBTEST(Test_GetPipeName_InvalidId); + SB_UT_ADD_SUBTEST(Test_GetPipeName); } /* end Test_GetGetPipeName_API */ /* @@ -2121,13 +1775,10 @@ void Test_GetPipeName_API(void) */ void Test_GetPipeName_NullPtr(void) { - START(); - ASSERT_EQ(CFE_SB_GetPipeName(NULL, OS_MAX_API_NAME, 0), CFE_SB_BAD_ARGUMENT); EVTSENT(CFE_SB_GETPIPENAME_NULL_PTR_EID); - REPORT(); } /* end Test_GetPipeName_NullPtr */ /* @@ -2136,7 +1787,6 @@ void Test_GetPipeName_NullPtr(void) void Test_GetPipeName_InvalidId(void) { char PipeName[OS_MAX_API_NAME]; - START(); UT_SetDeferredRetcode(UT_KEY(OS_QueueGetInfo), 1, OS_ERROR); @@ -2144,7 +1794,6 @@ void Test_GetPipeName_InvalidId(void) EVTSENT(CFE_SB_GETPIPENAME_ID_ERR_EID); - REPORT(); } /* end Test_GetPipeName_InvalidId */ /* @@ -2159,8 +1808,6 @@ void Test_GetPipeName(void) "TestPipe1", 0 }; - START(); - SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")); UT_SetDataBuffer( @@ -2174,7 +1821,6 @@ void Test_GetPipeName(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_GetPipeName */ /* @@ -2182,13 +1828,9 @@ void Test_GetPipeName(void) */ void Test_GetPipeIdByName_API(void) { - STARTBLOCK(); - - Test_GetPipeIdByName_NullPtrs(); - Test_GetPipeIdByName_InvalidName(); - Test_GetPipeIdByName(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_GetPipeIdByName_NullPtrs); + SB_UT_ADD_SUBTEST(Test_GetPipeIdByName_InvalidName); + SB_UT_ADD_SUBTEST(Test_GetPipeIdByName); } /* end Test_GetPipeIdByName_API */ /* @@ -2197,7 +1839,6 @@ void Test_GetPipeIdByName_API(void) void Test_GetPipeIdByName_NullPtrs(void) { CFE_SB_PipeId_t PipeIDOut = 0; - START(); ASSERT_EQ(CFE_SB_GetPipeIdByName(&PipeIDOut, NULL), CFE_SB_BAD_ARGUMENT); @@ -2207,7 +1848,6 @@ void Test_GetPipeIdByName_NullPtrs(void) EVTSENT(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID); - REPORT(); } /* end Test_GetPipeIdByName_NullPtrs */ /* @@ -2216,13 +1856,11 @@ void Test_GetPipeIdByName_NullPtrs(void) void Test_GetPipeIdByName_InvalidName(void) { CFE_SB_PipeId_t PipeIdOut = 0; - START(); ASSERT_EQ(CFE_SB_GetPipeIdByName(&PipeIdOut, "invalid"), CFE_SB_BAD_ARGUMENT); EVTSENT(CFE_SB_GETPIPEIDBYNAME_NAME_ERR_EID); - REPORT(); } /* end Test_GetPipeIdByName_InvalidName */ /* @@ -2231,7 +1869,6 @@ void Test_GetPipeIdByName_InvalidName(void) void Test_GetPipeIdByName(void) { CFE_SB_PipeId_t PipeId = 0, PipeIdOut = 0; - START(); SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")); @@ -2247,7 +1884,6 @@ void Test_GetPipeIdByName(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_GetPipeIdByName */ /* @@ -2255,13 +1891,10 @@ void Test_GetPipeIdByName(void) */ void Test_SetPipeOpts_BadID(void) { - START(); - ASSERT_EQ(CFE_SB_SetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, 0), CFE_SB_BAD_ARGUMENT); EVTSENT(CFE_SB_SETPIPEOPTS_ID_ERR_EID); - REPORT(); } /* end Test_SetPipeOpts_BadID */ /* @@ -2273,8 +1906,6 @@ void Test_SetPipeOpts_NotOwner(void) uint8 PipeTblIdx = 0; uint32 OrigOwner = 0; - START(); - SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); PipeTblIdx = CFE_SB_GetPipeIdx(PipeID); @@ -2289,7 +1920,6 @@ void Test_SetPipeOpts_NotOwner(void) TEARDOWN(CFE_SB_DeletePipe(PipeID)); - REPORT(); } /* end Test_SetPipeOpts_NotOwner */ /* @@ -2299,8 +1929,6 @@ void Test_SetPipeOpts(void) { CFE_SB_PipeId_t PipeID = 0; - START(); - SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); ASSERT(CFE_SB_SetPipeOpts(PipeID, 0)); @@ -2309,7 +1937,6 @@ void Test_SetPipeOpts(void) TEARDOWN(CFE_SB_DeletePipe(PipeID)); - REPORT(); } /* end Test_SetPipeOpts */ /* @@ -2319,13 +1946,10 @@ void Test_GetPipeOpts_BadID(void) { uint8 Opts = 0; - START(); - ASSERT_EQ(CFE_SB_GetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, &Opts), CFE_SB_BAD_ARGUMENT); EVTSENT(CFE_SB_GETPIPEOPTS_ID_ERR_EID); - REPORT(); } /* end Test_GetPipeOpts_BadID */ /* @@ -2335,8 +1959,6 @@ void Test_GetPipeOpts_BadPtr(void) { CFE_SB_PipeId_t PipeID = 0; - START(); - SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); ASSERT_EQ(CFE_SB_GetPipeOpts(PipeID, NULL), CFE_SB_BAD_ARGUMENT); @@ -2345,7 +1967,6 @@ void Test_GetPipeOpts_BadPtr(void) TEARDOWN(CFE_SB_DeletePipe(PipeID)); - REPORT(); } /* end Test_GetPipeOpts_BadPtr */ /* @@ -2356,8 +1977,6 @@ void Test_GetPipeOpts(void) CFE_SB_PipeId_t PipeID = 0; uint8 Opts = 0; - START(); - SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); ASSERT(CFE_SB_GetPipeOpts(PipeID, &Opts)); @@ -2366,7 +1985,6 @@ void Test_GetPipeOpts(void) TEARDOWN(CFE_SB_DeletePipe(PipeID)); - REPORT(); } /* end Test_GetPipeOpts */ /* @@ -2374,23 +1992,19 @@ void Test_GetPipeOpts(void) */ void Test_Subscribe_API(void) { - STARTBLOCK(); - - Test_Subscribe_SubscribeEx(); - Test_Subscribe_InvalidPipeId(); - Test_Subscribe_InvalidMsgId(); - Test_Subscribe_MaxMsgLim(); - Test_Subscribe_DuplicateSubscription(); - Test_Subscribe_LocalSubscription(); - Test_Subscribe_MaxDestCount(); - Test_Subscribe_MaxMsgIdCount(); - Test_Subscribe_SendPrevSubs(); - Test_Subscribe_FindGlobalMsgIdCnt(); - Test_Subscribe_PipeNonexistent(); - Test_Subscribe_SubscriptionReporting(); - Test_Subscribe_InvalidPipeOwner(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_Subscribe_SubscribeEx); + SB_UT_ADD_SUBTEST(Test_Subscribe_InvalidPipeId); + SB_UT_ADD_SUBTEST(Test_Subscribe_InvalidMsgId); + SB_UT_ADD_SUBTEST(Test_Subscribe_MaxMsgLim); + SB_UT_ADD_SUBTEST(Test_Subscribe_DuplicateSubscription); + SB_UT_ADD_SUBTEST(Test_Subscribe_LocalSubscription); + SB_UT_ADD_SUBTEST(Test_Subscribe_MaxDestCount); + SB_UT_ADD_SUBTEST(Test_Subscribe_MaxMsgIdCount); + SB_UT_ADD_SUBTEST(Test_Subscribe_SendPrevSubs); + SB_UT_ADD_SUBTEST(Test_Subscribe_FindGlobalMsgIdCnt); + SB_UT_ADD_SUBTEST(Test_Subscribe_PipeNonexistent); + SB_UT_ADD_SUBTEST(Test_Subscribe_SubscriptionReporting); + SB_UT_ADD_SUBTEST(Test_Subscribe_InvalidPipeOwner); } /* end Test_Subscribe_API */ /* @@ -2404,9 +2018,6 @@ void Test_Subscribe_SubscribeEx(void) uint16 PipeDepth = 10; uint16 MsgLim = 8; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); ASSERT(CFE_SB_SubscribeEx(MsgId, PipeId, Quality, MsgLim)); @@ -2418,7 +2029,6 @@ void Test_Subscribe_SubscribeEx(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Subscribe_SubscribeEx */ /* @@ -2429,16 +2039,12 @@ void Test_Subscribe_InvalidPipeId(void) CFE_SB_PipeId_t PipeId = 2; CFE_SB_MsgId_t MsgId = SB_UT_ALTERNATE_INVALID_MID; - START(); - - SB_ResetUnitTest(); ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); EVTCNT(2); EVTSENT(CFE_SB_SUB_INV_PIPE_EID); - REPORT(); } /* end Test_Subscribe_InvalidPipeId */ /* @@ -2450,9 +2056,6 @@ void Test_Subscribe_InvalidMsgId(void) CFE_SB_MsgId_t MsgId = SB_UT_ALTERNATE_INVALID_MID; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); @@ -2463,7 +2066,6 @@ void Test_Subscribe_InvalidMsgId(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Subscribe_InvalidMsgId */ /* @@ -2477,9 +2079,6 @@ void Test_Subscribe_MaxMsgLim(void) uint16 PipeDepth = 10; uint16 MsgLim; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); MsgLim = 0xffff; @@ -2491,7 +2090,6 @@ void Test_Subscribe_MaxMsgLim(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Subscribe_MaxMsgLim */ /* @@ -2503,9 +2101,6 @@ void Test_Subscribe_DuplicateSubscription(void) CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); @@ -2517,7 +2112,6 @@ void Test_Subscribe_DuplicateSubscription(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Subscribe_DuplicateSubscription */ /* @@ -2530,9 +2124,6 @@ void Test_Subscribe_LocalSubscription(void) uint16 PipeDepth = 10; uint16 MsgLim = 4; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); ASSERT(CFE_SB_SubscribeLocal(MsgId, PipeId, MsgLim)); @@ -2542,7 +2133,7 @@ void Test_Subscribe_LocalSubscription(void) EVTSENT(CFE_SB_PIPE_ADDED_EID); TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); + } /* end Test_Subscribe_LocalSubscription */ /* @@ -2556,10 +2147,6 @@ void Test_Subscribe_MaxDestCount(void) uint16 PipeDepth = 50; int32 i; - START(); - - SB_ResetUnitTest(); - /* Create pipes */ for (i = 0; i < CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1; i++) { @@ -2590,7 +2177,6 @@ void Test_Subscribe_MaxDestCount(void) TEARDOWN(CFE_SB_DeletePipe(PipeId[i])); } - REPORT(); } /* end Test_Subscribe_MaxDestCount */ /* @@ -2604,10 +2190,6 @@ void Test_Subscribe_MaxMsgIdCount(void) uint16 PipeDepth = 50; int32 i; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); @@ -2630,7 +2212,6 @@ void Test_Subscribe_MaxMsgIdCount(void) TEARDOWN(CFE_SB_DeletePipe(PipeId1)); TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - REPORT(); } /* end Test_Subscribe_MaxMsgIdCount */ /* @@ -2647,13 +2228,10 @@ void Test_Subscribe_SendPrevSubs(void) uint16 PipeDepth = 50; CFE_SB_SendPrevSubs_t SendPrevSubsMsg; - START(); - /* note that the message is not currently used or required, * but creating one and initializing it for completeness, in * case that changes in the future */ memset(&SendPrevSubsMsg, 0, sizeof(SendPrevSubsMsg)); - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); @@ -2678,7 +2256,6 @@ void Test_Subscribe_SendPrevSubs(void) TEARDOWN(CFE_SB_DeletePipe(PipeId1)); TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - REPORT(); } /* end Test_Subscribe_SendPrevSubs */ /* @@ -2695,9 +2272,6 @@ void Test_Subscribe_FindGlobalMsgIdCnt(void) uint16 PipeDepth = 50; uint16 MsgLim = 4; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); @@ -2722,7 +2296,6 @@ void Test_Subscribe_FindGlobalMsgIdCnt(void) TEARDOWN(CFE_SB_DeletePipe(PipeId1)); TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - REPORT(); } /* end Test_Subscribe_FindGlobalMsgIdCnt */ /* @@ -2733,17 +2306,12 @@ void Test_Subscribe_PipeNonexistent(void) CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; CFE_SB_PipeId_t PipeId = 55; - START(); - - SB_ResetUnitTest(); - ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); EVTCNT(2); EVTSENT(CFE_SB_SUB_INV_PIPE_EID); - REPORT(); } /* end Test_Subscribe_PipeNonexistent */ /* @@ -2756,10 +2324,6 @@ void Test_Subscribe_SubscriptionReporting(void) CFE_SB_Qos_t Quality; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); /* Enable subscription reporting */ @@ -2783,7 +2347,6 @@ void Test_Subscribe_SubscriptionReporting(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Subscribe_SubscriptionReporting */ /* @@ -2796,9 +2359,6 @@ void Test_Subscribe_InvalidPipeOwner(void) uint16 PipeDepth = 10; int32 RealOwner; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); /* Change owner of pipe through memory corruption */ @@ -2816,7 +2376,6 @@ void Test_Subscribe_InvalidPipeOwner(void) CFE_SB.PipeTbl[PipeId].AppId = RealOwner; TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Subscribe_InvalidPipeOwner */ /* @@ -2824,19 +2383,15 @@ void Test_Subscribe_InvalidPipeOwner(void) */ void Test_Unsubscribe_API(void) { - STARTBLOCK(); - - Test_Unsubscribe_Basic(); - Test_Unsubscribe_Local(); - Test_Unsubscribe_InvalParam(); - Test_Unsubscribe_NoMatch(); - Test_Unsubscribe_InvalidPipe(); - Test_Unsubscribe_InvalidPipeOwner(); - Test_Unsubscribe_FirstDestWithMany(); - Test_Unsubscribe_MiddleDestWithMany(); - Test_Unsubscribe_GetDestPtr(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_Basic); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_Local); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_InvalParam); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_NoMatch); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_InvalidPipe); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_InvalidPipeOwner); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_FirstDestWithMany); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_MiddleDestWithMany); + SB_UT_ADD_SUBTEST(Test_Unsubscribe_GetDestPtr); } /* end Test_Unsubscribe_API */ /* @@ -2848,9 +2403,6 @@ void Test_Unsubscribe_Basic(void) CFE_SB_MsgId_t MsgId = SB_UT_INTERMEDIATE_VALID_MID; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); @@ -2861,7 +2413,7 @@ void Test_Unsubscribe_Basic(void) EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - REPORT(); + } /* end Test_Unsubscribe_Basic */ /* @@ -2873,9 +2425,6 @@ void Test_Unsubscribe_Local(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); @@ -2887,7 +2436,6 @@ void Test_Unsubscribe_Local(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - REPORT(); } /* end Test_Unsubscribe_Local */ /* @@ -2900,9 +2448,6 @@ void Test_Unsubscribe_InvalParam(void) uint16 PipeDepth = 50; CFE_SB_PipeId_t SavedPipeId; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); /* Perform test using a bad message ID */ @@ -2933,7 +2478,6 @@ void Test_Unsubscribe_InvalParam(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - REPORT(); } /* end Test_Unsubscribe_InvalParam */ /* @@ -2946,9 +2490,6 @@ void Test_Unsubscribe_NoMatch(void) CFE_SB_MsgRouteIdx_t Idx; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); @@ -2966,7 +2507,6 @@ void Test_Unsubscribe_NoMatch(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - REPORT(); } /* end Test_Unsubscribe_NoMatch */ /* @@ -2978,9 +2518,6 @@ void Test_Unsubscribe_InvalidPipe(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); @@ -2992,7 +2529,6 @@ void Test_Unsubscribe_InvalidPipe(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - REPORT(); } /* end Test_Unsubscribe_InvalidPipe */ /* @@ -3005,9 +2541,6 @@ void Test_Unsubscribe_InvalidPipeOwner(void) uint32 RealOwner; uint16 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3027,7 +2560,6 @@ void Test_Unsubscribe_InvalidPipeOwner(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_Unsubscribe_InvalidPipeOwner */ /* @@ -3042,9 +2574,6 @@ void Test_Unsubscribe_FirstDestWithMany(void) CFE_SB_PipeId_t TestPipe3; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2")); SETUP(CFE_SB_CreatePipe(&TestPipe3, PipeDepth, "TestPipe3")); @@ -3062,7 +2591,6 @@ void Test_Unsubscribe_FirstDestWithMany(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe2)); TEARDOWN(CFE_SB_DeletePipe(TestPipe3)); - REPORT(); } /* end Test_Unsubscribe_FirstDestWithMany */ /* @@ -3077,10 +2605,6 @@ void Test_Unsubscribe_MiddleDestWithMany(void) CFE_SB_PipeId_t TestPipe3; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2")); SETUP(CFE_SB_CreatePipe(&TestPipe3, PipeDepth, "TestPipe3")); @@ -3098,7 +2622,6 @@ void Test_Unsubscribe_MiddleDestWithMany(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe2)); TEARDOWN(CFE_SB_DeletePipe(TestPipe3)); - REPORT(); } /* end Test_Unsubscribe_MiddleDestWithMany */ /* @@ -3112,10 +2635,6 @@ void Test_Unsubscribe_GetDestPtr(void) CFE_SB_PipeId_t TestPipe2; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); SETUP(CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2")); SETUP(CFE_SB_Subscribe(MsgId, TestPipe1)); @@ -3131,7 +2650,6 @@ void Test_Unsubscribe_GetDestPtr(void) TEARDOWN(CFE_SB_DeletePipe(TestPipe1)); TEARDOWN(CFE_SB_DeletePipe(TestPipe2)); - REPORT(); } /* end Test_Unsubscribe_GetDestPtr */ /* @@ -3139,29 +2657,25 @@ void Test_Unsubscribe_GetDestPtr(void) */ void Test_SendMsg_API(void) { - STARTBLOCK(); - - Test_SendMsg_NullPtr(); - Test_SendMsg_InvalidMsgId(); - Test_SendMsg_NoSubscribers(); - Test_SendMsg_MaxMsgSizePlusOne(); - Test_SendMsg_BasicSend(); - Test_SendMsg_SequenceCount(); - Test_SendMsg_QueuePutError(); - Test_SendMsg_PipeFull(); - Test_SendMsg_MsgLimitExceeded(); - Test_SendMsg_GetPoolBufErr(); - Test_SendMsg_ZeroCopyGetPtr(); - Test_SendMsg_ZeroCopySend(); - Test_SendMsg_ZeroCopyPass(); - Test_SendMsg_ZeroCopyReleasePtr(); - Test_SendMsg_DisabledDestination(); - Test_SendMsg_SendWithMetadata(); - Test_SendMsg_InvalidMsgId_ZeroCopy(); - Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(); - Test_SendMsg_NoSubscribers_ZeroCopy(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_SendMsg_NullPtr); + SB_UT_ADD_SUBTEST(Test_SendMsg_InvalidMsgId); + SB_UT_ADD_SUBTEST(Test_SendMsg_NoSubscribers); + SB_UT_ADD_SUBTEST(Test_SendMsg_MaxMsgSizePlusOne); + SB_UT_ADD_SUBTEST(Test_SendMsg_BasicSend); + SB_UT_ADD_SUBTEST(Test_SendMsg_SequenceCount); + SB_UT_ADD_SUBTEST(Test_SendMsg_QueuePutError); + SB_UT_ADD_SUBTEST(Test_SendMsg_PipeFull); + SB_UT_ADD_SUBTEST(Test_SendMsg_MsgLimitExceeded); + SB_UT_ADD_SUBTEST(Test_SendMsg_GetPoolBufErr); + SB_UT_ADD_SUBTEST(Test_SendMsg_ZeroCopyGetPtr); + SB_UT_ADD_SUBTEST(Test_SendMsg_ZeroCopySend); + SB_UT_ADD_SUBTEST(Test_SendMsg_ZeroCopyPass); + SB_UT_ADD_SUBTEST(Test_SendMsg_ZeroCopyReleasePtr); + SB_UT_ADD_SUBTEST(Test_SendMsg_DisabledDestination); + SB_UT_ADD_SUBTEST(Test_SendMsg_SendWithMetadata); + SB_UT_ADD_SUBTEST(Test_SendMsg_InvalidMsgId_ZeroCopy); + SB_UT_ADD_SUBTEST(Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy); + SB_UT_ADD_SUBTEST(Test_SendMsg_NoSubscribers_ZeroCopy); } /* end Test_SendMsg_API */ /* @@ -3169,16 +2683,12 @@ void Test_SendMsg_API(void) */ void Test_SendMsg_NullPtr(void) { - START(); - - SB_ResetUnitTest(); ASSERT_EQ(CFE_SB_SendMsg(NULL), CFE_SB_BAD_ARGUMENT); EVTCNT(1); EVTSENT(CFE_SB_SEND_BAD_ARG_EID); - REPORT(); } /* end Test_SendMsg_NullPtr */ /* @@ -3189,9 +2699,6 @@ void Test_SendMsg_InvalidMsgId(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, SB_UT_ALTERNATE_INVALID_MID, sizeof(TlmPkt), true); CFE_SB_SetMsgId(TlmPktPtr, CFE_SB_INVALID_MSG_ID); @@ -3210,7 +2717,6 @@ void Test_SendMsg_InvalidMsgId(void) EVTSENT(CFE_SB_SEND_INV_MSGID_EID); - REPORT(); } /* end Test_SendMsg_InvalidMsgId */ /* @@ -3222,10 +2728,6 @@ void Test_SendMsg_NoSubscribers(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - START(); - - SB_ResetUnitTest(); - CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); ASSERT(CFE_SB_SendMsg(TlmPktPtr)); @@ -3233,7 +2735,6 @@ void Test_SendMsg_NoSubscribers(void) EVTSENT(CFE_SB_SEND_NO_SUBS_EID); - REPORT(); } /* end Test_SendMsg_NoSubscribers */ /* @@ -3245,9 +2746,6 @@ void Test_SendMsg_MaxMsgSizePlusOne(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1, false); ASSERT_EQ(CFE_SB_SendMsg(TlmPktPtr), CFE_SB_MSG_TOO_BIG); @@ -3256,7 +2754,6 @@ void Test_SendMsg_MaxMsgSizePlusOne(void) EVTSENT(CFE_SB_MSG_TOO_BIG_EID); - REPORT(); } /* end Test_SendMsg_MaxMsgSizePlusOne */ /* @@ -3270,9 +2767,6 @@ void Test_SendMsg_BasicSend(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 2; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); @@ -3283,7 +2777,6 @@ void Test_SendMsg_BasicSend(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_BasicSend */ /* @@ -3298,9 +2791,6 @@ void Test_SendMsg_SequenceCount(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3347,7 +2837,6 @@ void Test_SendMsg_SequenceCount(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_SequenceCount */ /* @@ -3361,9 +2850,6 @@ void Test_SendMsg_QueuePutError(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 2; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId4Error, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId4Error)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); @@ -3378,7 +2864,6 @@ void Test_SendMsg_QueuePutError(void) TEARDOWN(CFE_SB_DeletePipe(PipeId4Error)); - REPORT(); } /* end Test_SendMsg_QueuePutError */ /* @@ -3392,9 +2877,6 @@ void Test_SendMsg_PipeFull(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 1; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3413,7 +2895,7 @@ void Test_SendMsg_PipeFull(void) EVTSENT(CFE_SB_Q_FULL_ERR_EID); TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); + } /* end Test_SendMsg_PipeFull */ /* @@ -3427,9 +2909,6 @@ void Test_SendMsg_MsgLimitExceeded(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 5; - START(); - - SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); @@ -3450,7 +2929,6 @@ void Test_SendMsg_MsgLimitExceeded(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_MsgLimitExceeded */ /* @@ -3464,9 +2942,6 @@ void Test_SendMsg_GetPoolBufErr(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth; - START(); - - SB_ResetUnitTest(); PipeDepth = 1; CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "GetPoolErrPipe")); @@ -3484,7 +2959,6 @@ void Test_SendMsg_GetPoolBufErr(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_GetPoolBufErr */ /* @@ -3496,10 +2970,6 @@ void Test_SendMsg_ZeroCopyGetPtr(void) CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl; uint16 MsgSize = 10; - START(); - - SB_ResetUnitTest(); - /* Have GetPoolBuf stub return error on its next call (buf descriptor * allocation failed) */ @@ -3536,7 +3006,6 @@ void Test_SendMsg_ZeroCopyGetPtr(void) EVTCNT(0); - REPORT(); } /* end Test_SendMsg_ZeroCopyGetPtr */ /* @@ -3552,15 +3021,16 @@ void Test_SendMsg_ZeroCopySend(void) uint32 PipeDepth = 10; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyTestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); - if(ASSERT_TRUE((ZeroCpyMsgPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), - &ZeroCpyBufHndl)) != NULL)) + ZeroCpyMsgPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t),&ZeroCpyBufHndl); + if (ZeroCpyMsgPtr == NULL) + { + UtAssert_Failed("Unexpected NULL pointer returned from ZeroCopyGetPtr"); + } + else { CFE_SB_InitMsg(ZeroCpyMsgPtr, MsgId, sizeof(SB_UT_Test_Tlm_t), true); CCSDS_WR_SEQ(ZeroCpyMsgPtr->Hdr, 22); @@ -3585,7 +3055,6 @@ void Test_SendMsg_ZeroCopySend(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_ZeroCopySend */ /* @@ -3602,10 +3071,6 @@ void Test_SendMsg_ZeroCopyPass(void) CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 Seq = 22; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyPassTestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3614,8 +3079,7 @@ void Test_SendMsg_ZeroCopyPass(void) if (ZeroCpyMsgPtr == NULL) { - UT_Text("Unexpected NULL pointer returned from ZeroCopyGetPtr"); - TestStat = CFE_FAIL; + UtAssert_Failed("Unexpected NULL pointer returned from ZeroCopyGetPtr"); } else { @@ -3637,17 +3101,12 @@ void Test_SendMsg_ZeroCopyPass(void) if (PtrToMsg == NULL) { - UT_Text("Unexpected NULL return from receive in zero copy pass test"); - TestStat = CFE_FAIL; + UtAssert_Failed("Unexpected NULL return from receive in zero copy pass test"); } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != Seq) + else { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=%d, act=%d", + UtAssert_True(CCSDS_RD_SEQ(PtrToMsg->Hdr) == Seq, "sequence count for send in sequence count test, exp=%d, act=%d", Seq, CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; } EVTCNT(3); @@ -3656,7 +3115,6 @@ void Test_SendMsg_ZeroCopyPass(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_ZeroCopyPass */ /* @@ -3672,9 +3130,6 @@ void Test_SendMsg_ZeroCopyReleasePtr(void) CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl3 = 0; uint16 MsgSize = 10; - START(); - - SB_ResetUnitTest(); ZeroCpyMsgPtr1 = CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl1); ZeroCpyMsgPtr2 = CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl2); ZeroCpyMsgPtr3 = CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl3); @@ -3711,7 +3166,6 @@ void Test_SendMsg_ZeroCopyReleasePtr(void) EVTCNT(0); - REPORT(); } /* end Test_SendMsg_ZeroCopyReleasePtr */ /* @@ -3726,9 +3180,6 @@ void Test_SendMsg_DisabledDestination(void) CFE_SB_DestinationD_t *DestPtr; int32 PipeDepth; - START(); - - SB_ResetUnitTest(); PipeDepth = 2; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -3745,7 +3196,6 @@ void Test_SendMsg_DisabledDestination(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_DisabledDestination */ /* @@ -3769,10 +3219,7 @@ void Test_SendMsg_SendWithMetadata(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPktBufDesc.TlmPkt; int32 PipeDepth; - START(); - memset(&TlmPktBufDesc, 0, sizeof(TlmPktBufDesc)); - SB_ResetUnitTest(); PipeDepth = 2; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -3786,7 +3233,6 @@ void Test_SendMsg_SendWithMetadata(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SendMsg_SendWithMetadata */ /* @@ -3797,22 +3243,19 @@ void Test_SendMsg_InvalidMsgId_ZeroCopy(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr; - START(); - - SB_ResetUnitTest(); TlmPktPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), (CFE_SB_ZeroCopyHandle_t *) &TlmPkt); + if (TlmPktPtr == NULL) { - UT_Text("Unexpected NULL pointer returned from ZeroCopyGetPtr"); - TestStat = CFE_FAIL; + UtAssert_Failed("Unexpected NULL pointer returned from ZeroCopyGetPtr"); } else { CFE_SB_InitMsg(TlmPktPtr, SB_UT_ALTERNATE_INVALID_MID, - sizeof(SB_UT_Test_Tlm_t), true); - ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, - CFE_SB_SEND_ZEROCOPY), CFE_SB_BAD_ARGUMENT); + sizeof(SB_UT_Test_Tlm_t), true); + ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, + CFE_SB_SEND_ZEROCOPY), CFE_SB_BAD_ARGUMENT); } @@ -3820,7 +3263,6 @@ void Test_SendMsg_InvalidMsgId_ZeroCopy(void) EVTSENT(CFE_SB_SEND_INV_MSGID_EID); - REPORT(); } /* end Test_SendMsg_InvalidMsgId_ZeroCopy */ /* @@ -3833,21 +3275,17 @@ void Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr; - START(); - - SB_ResetUnitTest(); TlmPktPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), (CFE_SB_ZeroCopyHandle_t *) &TlmPkt); if (TlmPktPtr == NULL) { - UT_Text("Unexpected NULL pointer returned from ZeroCopyGetPtr"); - TestStat = CFE_FAIL; + UtAssert_Failed("Unexpected NULL pointer returned from ZeroCopyGetPtr"); } else { CFE_SB_InitMsg(TlmPktPtr, MsgId, CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1, false); - ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, - CFE_SB_SEND_ZEROCOPY), CFE_SB_MSG_TOO_BIG); + ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, + CFE_SB_SEND_ZEROCOPY), CFE_SB_MSG_TOO_BIG); } @@ -3855,7 +3293,6 @@ void Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(void) EVTSENT(CFE_SB_MSG_TOO_BIG_EID); - REPORT(); } /* end Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy */ /* @@ -3868,15 +3305,11 @@ void Test_SendMsg_NoSubscribers_ZeroCopy(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr; - START(); - - SB_ResetUnitTest(); TlmPktPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), (CFE_SB_ZeroCopyHandle_t *) &TlmPkt); if (TlmPktPtr == NULL) { - UT_Text("Unexpected NULL pointer returned from ZeroCopyGetPtr"); - TestStat = CFE_FAIL; + UtAssert_Failed("Unexpected NULL pointer returned from ZeroCopyGetPtr"); } else { @@ -3889,7 +3322,6 @@ void Test_SendMsg_NoSubscribers_ZeroCopy(void) EVTSENT(CFE_SB_SEND_NO_SUBS_EID); - REPORT(); } /* end Test_SendMsg_NoSubscribers_ZeroCopy */ /* @@ -3897,22 +3329,18 @@ void Test_SendMsg_NoSubscribers_ZeroCopy(void) */ void Test_RcvMsg_API(void) { - STARTBLOCK(); - - Test_RcvMsg_InvalidPipeId(); - Test_RcvMsg_InvalidTimeout(); - Test_RcvMsg_Poll(); - Test_RcvMsg_GetLastSenderNull(); - Test_RcvMsg_GetLastSenderInvalidPipe(); - Test_RcvMsg_GetLastSenderInvalidCaller(); - Test_RcvMsg_GetLastSenderNoValidSender(); - Test_RcvMsg_GetLastSenderSuccess(); - Test_RcvMsg_Timeout(); - Test_RcvMsg_PipeReadError(); - Test_RcvMsg_PendForever(); - Test_RcvMsg_InvalidBufferPtr(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_RcvMsg_InvalidPipeId); + SB_UT_ADD_SUBTEST(Test_RcvMsg_InvalidTimeout); + SB_UT_ADD_SUBTEST(Test_RcvMsg_Poll); + SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderNull); + SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderInvalidPipe); + SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderInvalidCaller); + SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderNoValidSender); + SB_UT_ADD_SUBTEST(Test_RcvMsg_GetLastSenderSuccess); + SB_UT_ADD_SUBTEST(Test_RcvMsg_Timeout); + SB_UT_ADD_SUBTEST(Test_RcvMsg_PipeReadError); + SB_UT_ADD_SUBTEST(Test_RcvMsg_PendForever); + SB_UT_ADD_SUBTEST(Test_RcvMsg_InvalidBufferPtr); } /* end Test_RcvMsg_API */ /* @@ -3923,9 +3351,6 @@ void Test_RcvMsg_InvalidPipeId(void) CFE_SB_MsgPtr_t PtrToMsg; CFE_SB_PipeId_t InvalidPipeId = 20; - START(); - - SB_ResetUnitTest(); CFE_SB.PipeTbl[InvalidPipeId].InUse = CFE_SB_NOT_IN_USE; ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, InvalidPipeId, CFE_SB_POLL), CFE_SB_BAD_ARGUMENT); @@ -3935,7 +3360,6 @@ void Test_RcvMsg_InvalidPipeId(void) EVTSENT(CFE_SB_BAD_PIPEID_EID); - REPORT(); } /* end Test_RcvMsg_InvalidPipeId */ /* @@ -3948,9 +3372,6 @@ void Test_RcvMsg_InvalidTimeout(void) uint32 PipeDepth = 10; int32 TimeOut = -5; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut), CFE_SB_BAD_ARGUMENT); @@ -3961,7 +3382,6 @@ void Test_RcvMsg_InvalidTimeout(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_InvalidTimeout */ /* @@ -3973,9 +3393,6 @@ void Test_RcvMsg_Poll(void) CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_POLL), CFE_SB_NO_MESSAGE); @@ -3986,7 +3403,6 @@ void Test_RcvMsg_Poll(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_Poll */ /* @@ -3997,9 +3413,6 @@ void Test_RcvMsg_GetLastSenderNull(void) CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); ASSERT_EQ(CFE_SB_GetLastSenderId(NULL, PipeId), CFE_SB_BAD_ARGUMENT); @@ -4010,7 +3423,6 @@ void Test_RcvMsg_GetLastSenderNull(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_GetLastSenderNull */ /* @@ -4023,10 +3435,6 @@ void Test_RcvMsg_GetLastSenderInvalidPipe(void) CFE_SB_SenderId_t *GLSPtr; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); - SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, InvalidPipeId), CFE_SB_BAD_ARGUMENT); @@ -4037,7 +3445,6 @@ void Test_RcvMsg_GetLastSenderInvalidPipe(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_GetLastSenderInvalidPipe */ /* @@ -4050,9 +3457,6 @@ void Test_RcvMsg_GetLastSenderInvalidCaller(void) uint32 PipeDepth = 10; uint32 OrigPipeOwner; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); /* Change pipe owner ID to execute 'invalid caller' code */ @@ -4068,7 +3472,6 @@ void Test_RcvMsg_GetLastSenderInvalidCaller(void) CFE_SB.PipeTbl[PipeId].AppId = OrigPipeOwner; TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_GetLastSenderInvalidCaller */ @@ -4078,9 +3481,6 @@ void Test_RcvMsg_GetLastSenderNoValidSender(void) CFE_SB_SenderId_t *GLSPtr; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, PipeId), CFE_SB_NO_MSG_RECV); @@ -4088,7 +3488,6 @@ void Test_RcvMsg_GetLastSenderNoValidSender(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_GetLastSenderNoValidSender */ @@ -4104,9 +3503,6 @@ void Test_RcvMsg_GetLastSenderSuccess(void) CFE_SB_MsgPtr_t PtrToMsg; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, SB_UT_TLM_MID, sizeof(TlmPkt), true); SETUP(CFE_SB_Subscribe(SB_UT_TLM_MID, PipeId)); @@ -4118,7 +3514,6 @@ void Test_RcvMsg_GetLastSenderSuccess(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_GetLastSenderSuccess */ /* @@ -4131,9 +3526,6 @@ void Test_RcvMsg_Timeout(void) uint32 PipeDepth = 10; int32 TimeOut = 200; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, OS_QUEUE_TIMEOUT); @@ -4145,7 +3537,6 @@ void Test_RcvMsg_Timeout(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_Timeout */ /* @@ -4157,9 +3548,6 @@ void Test_RcvMsg_PipeReadError(void) CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, OS_ERROR); ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_PIPE_RD_ERR); @@ -4170,7 +3558,6 @@ void Test_RcvMsg_PipeReadError(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_PipeReadError */ /* @@ -4186,9 +3573,6 @@ void Test_RcvMsg_PendForever(void) CFE_SB_PipeD_t *PipeDscPtr; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -4208,7 +3592,6 @@ void Test_RcvMsg_PendForever(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_PendForever */ /* @@ -4220,9 +3603,6 @@ void Test_CleanupApp_API(void) CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); CFE_SB_ZeroCopyGetPtr(PipeDepth, &ZeroCpyBufHndl); CFE_SB_ZeroCopyGetPtr(PipeDepth, &ZeroCpyBufHndl); @@ -4249,7 +3629,6 @@ void Test_CleanupApp_API(void) EVTSENT(CFE_SB_PIPE_DELETED_EID); - REPORT(); } /* end Test_CleanupApp_API */ /* @@ -4260,9 +3639,6 @@ void Test_RcvMsg_InvalidBufferPtr(void) CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); ASSERT_EQ(CFE_SB_RcvMsg(NULL, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_BAD_ARGUMENT); @@ -4273,7 +3649,6 @@ void Test_RcvMsg_InvalidBufferPtr(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_InvalidBufferPtr */ /* @@ -4281,21 +3656,31 @@ void Test_RcvMsg_InvalidBufferPtr(void) */ void Test_SB_Utils(void) { - STARTBLOCK(); - - Test_CFE_SB_InitMsg(); - Test_CFE_SB_MsgHdrSize(); - Test_CFE_SB_GetUserData(); - Test_CFE_SB_SetGetMsgId(); - Test_CFE_SB_SetGetUserDataLength(); - Test_CFE_SB_SetGetTotalMsgLength(); - Test_CFE_SB_SetGetMsgTime(); - Test_CFE_SB_TimeStampMsg(); - Test_CFE_SB_SetGetCmdCode(); - Test_CFE_SB_ChecksumUtils(); - Test_CFE_SB_ValidateMsgId(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_CFE_SB_InitMsg); + SB_UT_ADD_SUBTEST(Test_CFE_SB_MsgHdrSize_Cmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_MsgHdrSize_Tlm); + SB_UT_ADD_SUBTEST(Test_CFE_SB_GetUserData_Cmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_GetUserData_CmdNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_GetUserData_Tlm); + SB_UT_ADD_SUBTEST(Test_CFE_SB_GetUserData_TlmNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetMsgId); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetUserDataLength_Cmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetUserDataLength_CmdNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetUserDataLength_Tlm); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetUserDataLength_TlmNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetTotalMsgLength); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetMsgTime_Cmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetMsgTime_CmdNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetMsgTime_Tlm); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetMsgTime_TlmNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_TimeStampMsg); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetCmdCode_Cmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_SetGetCmdCode_NonCmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_ChecksumUtils_Cmd); + SB_UT_ADD_SUBTEST(Test_CFE_SB_ChecksumUtils_CmdNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_ChecksumUtils_Tlm); + SB_UT_ADD_SUBTEST(Test_CFE_SB_ChecksumUtils_TlmNoSecHdr); + SB_UT_ADD_SUBTEST(Test_CFE_SB_ValidateMsgId); } /* end Test_SB_Utils */ /* @@ -4303,12 +3688,8 @@ void Test_SB_Utils(void) */ void Test_CFE_SB_InitMsg(void) { - STARTBLOCK(); - - Test_CFE_SB_InitMsg_True(); - Test_CFE_SB_InitMsg_False(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_CFE_SB_InitMsg_True); + SB_UT_ADD_SUBTEST(Test_CFE_SB_InitMsg_False); } /* end Test_CFE_SB_InitMsg */ /* @@ -4319,22 +3700,17 @@ void Test_CFE_SB_InitMsg_True(void) SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - START(); - - SB_ResetUnitTest(); - /* Set entire cmd packet to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); CFE_SB_InitMsg(SBCmdPtr, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(SBCmd), true); - ASSERT_TRUE(SBCmd.Cmd32Param1 == 0 && - SBCmd.Cmd16Param1 == 0 && - SBCmd.Cmd16Param2 == 0 && - SBCmd.Cmd8Param1 == 0 && - SBCmd.Cmd8Param2 == 0 && - SBCmd.Cmd8Param3 == 0 && - SBCmd.Cmd8Param4 == 0); - - REPORT(); + ASSERT_EQ(SBCmd.Cmd32Param1, 0); + ASSERT_EQ(SBCmd.Cmd16Param1, 0); + ASSERT_EQ(SBCmd.Cmd16Param2, 0); + ASSERT_EQ(SBCmd.Cmd8Param1, 0); + ASSERT_EQ(SBCmd.Cmd8Param2, 0); + ASSERT_EQ(SBCmd.Cmd8Param3, 0); + ASSERT_EQ(SBCmd.Cmd8Param4, 0); + } /* end Test_CFE_SB_InitMsg_True */ /* @@ -4345,85 +3721,66 @@ void Test_CFE_SB_InitMsg_False(void) SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - START(); - - SB_ResetUnitTest(); - /* Set entire cmd packet to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); - ASSERT_TRUE(SBCmd.Cmd32Param1 == 0xffffffff && - SBCmd.Cmd16Param1 == 0xffff && - SBCmd.Cmd16Param2 == 0xffff && - SBCmd.Cmd8Param1 == 0xff && - SBCmd.Cmd8Param2 == 0xff && - SBCmd.Cmd8Param3 == 0xff && - SBCmd.Cmd8Param4 == 0xff); - CFE_SB_InitMsg(SBCmdPtr, CFE_SB_ValueToMsgId(CFE_SB_CMD_MID), sizeof(SBCmd), false); - REPORT(); + ASSERT_EQ(SBCmd.Cmd32Param1, 0xffffffff); + ASSERT_EQ(SBCmd.Cmd16Param1, 0xffff); + ASSERT_EQ(SBCmd.Cmd16Param2, 0xffff); + ASSERT_EQ(SBCmd.Cmd8Param1, 0xff); + ASSERT_EQ(SBCmd.Cmd8Param2, 0xff); + ASSERT_EQ(SBCmd.Cmd8Param3, 0xff); + ASSERT_EQ(SBCmd.Cmd8Param4, 0xff); + + } /* end Test_CFE_SB_InitMsg_False */ /* ** Test getting the size of a command/telemetry message header */ -void Test_CFE_SB_MsgHdrSize(void) +void Test_CFE_SB_MsgHdrSize_Cmd(void) { CCSDS_PriHdr_t * PktPtr; - CFE_SB_MsgId_t msgId; SB_UT_Test_Cmd_t testCmd; - SB_UT_Test_Tlm_t testTlm; - - START(); - - CFE_SB_MsgPtr_t MsgPtr = (CFE_SB_MsgPtr_t)&testCmd; + CFE_SB_MsgPtr_t MsgPtr; + MsgPtr = (CFE_SB_MsgPtr_t)&testCmd; PktPtr = (CCSDS_PriHdr_t*)MsgPtr; /* Test for cmds w/sec hdr */ - SB_ResetUnitTest(); - - msgId = SB_UT_CMD_MID; CFE_SB_InitMsg(MsgPtr, - msgId, + SB_UT_CMD_MID, sizeof(testCmd), 0); /* Set this to Command Type */ - CCSDS_WR_TYPE(*PktPtr, 1); + CCSDS_WR_TYPE(*PktPtr, 1); /* No sec hdr */ CCSDS_WR_SHDR(*PktPtr, 1); ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CFE_SB_CmdHdr_t)); - REPORT(); - /* Test for cmds wo/sec hdr */ - START(); - SB_ResetUnitTest(); - - CFE_SB_InitMsg(MsgPtr, - SB_UT_TLM_MID, - sizeof(testCmd), - 0); - /* Set this to Command Type */ - CCSDS_WR_TYPE(*PktPtr, 1); + CCSDS_WR_TYPE(*PktPtr, 1); /* No sec hdr */ CCSDS_WR_SHDR(*PktPtr, 0); ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CCSDS_PriHdr_t)); - REPORT(); +} /* end Test_CFE_SB_MsgHdrSize */ - START(); +void Test_CFE_SB_MsgHdrSize_Tlm(void) +{ + CCSDS_PriHdr_t * PktPtr; + SB_UT_Test_Tlm_t testTlm; + CFE_SB_MsgPtr_t MsgPtr; /* Test for tlm w/sec hdr */ - SB_ResetUnitTest(); - MsgPtr = (CFE_SB_MsgPtr_t)&testTlm; PktPtr = (CCSDS_PriHdr_t*)MsgPtr; @@ -4435,123 +3792,100 @@ void Test_CFE_SB_MsgHdrSize(void) ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CFE_SB_TlmHdr_t)); - REPORT(); - START(); /* Test for tlm wo/sec hdr */ - SB_ResetUnitTest(); - CFE_SB_SetMsgId(MsgPtr, SB_UT_TLM_MID); /* Set this to Telemetry Type */ - CCSDS_WR_TYPE(*PktPtr, 0); + CCSDS_WR_TYPE(*PktPtr, 0); CCSDS_WR_SHDR(*PktPtr, 0); ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CCSDS_PriHdr_t)); - REPORT(); -} /* end Test_CFE_SB_MsgHdrSize */ +} /* end Test_CFE_SB_MsgHdrSize_Tlm */ /* ** Test getting a pointer to the user data portion of a message */ -void Test_CFE_SB_GetUserData(void) +void Test_CFE_SB_GetUserData_Cmd(void) { SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - SB_UT_Test_Tlm_t SBTlm; - CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; - SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; - CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; uint8 *ActualAdrReturned; uint8 *ExpAdrReturned; - CFE_SB_MsgId_t msgId; - - START(); /* Test address returned for cmd pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - - msgId = SB_UT_CMD_MID; - ExpAdrReturned = (uint8 *) SBCmdPtr + sizeof(CFE_SB_CmdHdr_t); - CFE_SB_InitMsg(SBCmdPtr, msgId, sizeof(SB_UT_Test_Cmd_t), true); + CFE_SB_InitMsg(SBCmdPtr, SB_UT_CMD_MID, sizeof(SB_UT_Test_Cmd_t), true); ActualAdrReturned = CFE_SB_GetUserData(SBCmdPtr); + UtAssert_True(ActualAdrReturned == ExpAdrReturned, + "Address of data for commands with secondary header is " + "packet address + 8\n PktAddr %p, Rtn %p, Exp %p", + (void *) SBCmdPtr, ActualAdrReturned, ExpAdrReturned); - if (ActualAdrReturned != ExpAdrReturned) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Address of data for commands with secondary header is " - "packet address + 8\n PktAddr %p, Rtn %p, Exp %p", - (void *) SBCmdPtr, ActualAdrReturned, ExpAdrReturned); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - REPORT(); +} /* end Test_CFE_SB_GetUserData */ + +void Test_CFE_SB_GetUserData_CmdNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + uint8 *ActualAdrReturned; + uint8 *ExpAdrReturned; /* Test address returned for cmd pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); + CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_CMD_MID); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); ActualAdrReturned = CFE_SB_GetUserData(SBNoSecHdrPktPtr); ExpAdrReturned = (uint8 *) SBNoSecHdrPktPtr + 6; - if (ActualAdrReturned != ExpAdrReturned) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Address of data for commands without secondary header is " - "packet address + 6\n PktAddr %p, Rtn %p, Exp %p", - (void *) SBNoSecHdrPktPtr, ActualAdrReturned, ExpAdrReturned); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + UtAssert_True(ActualAdrReturned == ExpAdrReturned, + "Address of data for commands without secondary header is " + "packet address + 6\n PktAddr %p, Rtn %p, Exp %p", + (void *) SBNoSecHdrPktPtr, ActualAdrReturned, ExpAdrReturned); + +} /* end Test_CFE_SB_GetUserData */ - REPORT(); +void Test_CFE_SB_GetUserData_Tlm(void) +{ + SB_UT_Test_Tlm_t SBTlm; + CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; + uint8 *ActualAdrReturned; + uint8 *ExpAdrReturned; /* Test address returned for tlm pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; CFE_SB_InitMsg(SBTlmPtr, SB_UT_TLM_MID, sizeof(SB_UT_Test_Tlm_t), true); ActualAdrReturned = CFE_SB_GetUserData(SBTlmPtr); ExpAdrReturned = (uint8 *) SBTlmPtr + sizeof(CFE_SB_TlmHdr_t); - if (ActualAdrReturned != ExpAdrReturned) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, + UtAssert_True(ActualAdrReturned == ExpAdrReturned, "Address of data for telemetry packets with secondary header " "is Pkt Addr + 12\n PktAddr %p, Rtn %p, Exp %p", (void *) SBTlmPtr, ActualAdrReturned, ExpAdrReturned); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - REPORT(); +} /* end Test_CFE_SB_GetUserData */ + +void Test_CFE_SB_GetUserData_TlmNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + uint8 *ActualAdrReturned; + uint8 *ExpAdrReturned; /* Test address returned for tlm pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); ActualAdrReturned = CFE_SB_GetUserData(SBNoSecHdrPktPtr); ExpAdrReturned = (uint8 *) SBNoSecHdrPktPtr + sizeof(CCSDS_PriHdr_t); - if (ActualAdrReturned != ExpAdrReturned) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, + UtAssert_True(ActualAdrReturned == ExpAdrReturned, "Address of data for telemetry packets without secondary " "header is Pkt Addr + 6\n PktAddr %p, Rtn %p, Exp %p", (void *) SBNoSecHdrPktPtr, ActualAdrReturned, ExpAdrReturned); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - REPORT(); } /* end Test_CFE_SB_GetUserData */ /* @@ -4565,11 +3899,7 @@ void Test_CFE_SB_SetGetMsgId(void) CFE_SB_MsgId_t MsgIdSet; uint32 i; - START(); - /* Test setting and getting the message ID of a message */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Set entire command packet to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); @@ -4577,24 +3907,15 @@ void Test_CFE_SB_SetGetMsgId(void) CFE_SB_SetMsgId(SBCmdPtr, MsgIdSet); MsgIdReturned = CFE_SB_GetMsgId(SBCmdPtr); - if (!CFE_SB_MsgId_Equal(MsgIdReturned, MsgIdSet)) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, + UtAssert_True(CFE_SB_MsgId_Equal(MsgIdReturned, MsgIdSet), "CFE_SB_GetMsgId returned 0x%lx, expected 0x%lx", (unsigned long) CFE_SB_MsgIdToValue(MsgIdReturned), (unsigned long) CFE_SB_MsgIdToValue(MsgIdSet)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - REPORT(); /* Test setting and getting the message ID of a message looping through * all values */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - /* Looping through every value from 0 to 0xffff */ for (i = 0; i <= 0xFFFF; i++) @@ -4609,38 +3930,24 @@ void Test_CFE_SB_SetGetMsgId(void) } } - REPORT(); } /* end Test_CFE_SB_SetGetMsgId */ /* ** Test setting and getting the user data size of a message */ -void Test_CFE_SB_SetGetUserDataLength(void) +void Test_CFE_SB_SetGetUserDataLength_Cmd(void) { SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - SB_UT_Test_Tlm_t SBTlm; - CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; - SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; - CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; int32 SetSize; uint16 SizeReturned; int16 ActualPktLenField; int16 ExpPktLenField; - CFE_SB_MsgId_t msgId; - - START(); /* CCSDS pkt length field = SecHdrSize + data - 1 */ /* Loop through all pkt length values for cmd pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - - msgId = SB_UT_CMD_MID; - - CFE_SB_InitMsg(SBCmdPtr, msgId, sizeof(SB_UT_Test_Cmd_t), true); - + CFE_SB_InitMsg(SBCmdPtr, SB_UT_CMD_MID, sizeof(SB_UT_Test_Cmd_t), true); for (SetSize = 0; SetSize < 0x10000; SetSize++) { @@ -4650,28 +3957,24 @@ void Test_CFE_SB_SetGetUserDataLength(void) ExpPktLenField = sizeof(CCSDS_CommandPacket_t) + SetSize - sizeof(CCSDS_PriHdr_t) - 1; /* SecHdrSize + data - 1 */ - if (SizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned) SizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } + ASSERT_EQ (SizeReturned, SetSize); + ASSERT_EQ (ActualPktLenField, ExpPktLenField); } - REPORT(); - - /* Loop through all pkt length values for cmd pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; +} /* end Test_CFE_SB_SetGetUserDataLength */ - msgId = SB_UT_TLM_MID; +void Test_CFE_SB_SetGetUserDataLength_CmdNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + int32 SetSize; + uint16 SizeReturned; + int16 ActualPktLenField; + int16 ExpPktLenField; - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, msgId); + /* Loop through all pkt length values for cmd pkts wo/sec hdr */ + memset(&SBNoSecHdrPkt, 0, sizeof(SBNoSecHdrPktPtr)); + CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_CMD_MID); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); for (SetSize = 0; SetSize < 0x10000; SetSize++) @@ -4681,28 +3984,24 @@ void Test_CFE_SB_SetGetUserDataLength(void) ActualPktLenField = UT_GetActualPktLenField(SBNoSecHdrPktPtr); ExpPktLenField = 0 + SetSize - 1; /* SecHdrSize + data - 1 */ - if (SizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned) SizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } + ASSERT_EQ (SizeReturned, SetSize); + ASSERT_EQ (ActualPktLenField, ExpPktLenField); } - REPORT(); - /* Loop through all pkt length values for tlm pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; +} /* end Test_CFE_SB_SetGetUserDataLength */ - msgId = SB_UT_TLM_MID; +void Test_CFE_SB_SetGetUserDataLength_Tlm(void) +{ + SB_UT_Test_Tlm_t SBTlm; + CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; + int32 SetSize; + uint16 SizeReturned; + int16 ActualPktLenField; + int16 ExpPktLenField; - CFE_SB_InitMsg(SBTlmPtr, msgId, sizeof(SB_UT_Test_Tlm_t), true); + /* Loop through all pkt length values for tlm pkts w/sec hdr */ + CFE_SB_InitMsg(SBTlmPtr, SB_UT_TLM_MID, sizeof(SB_UT_Test_Tlm_t), true); for (SetSize = 0; SetSize < 0x10000; SetSize++) { @@ -4712,28 +4011,24 @@ void Test_CFE_SB_SetGetUserDataLength(void) ExpPktLenField = sizeof(CCSDS_TelemetryPacket_t) + SetSize - sizeof(CCSDS_PriHdr_t) - 1; /* SecHdrSize + data - 1 */ - if (SizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned int) SizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } + ASSERT_EQ (SizeReturned, SetSize); + ASSERT_EQ (ActualPktLenField, ExpPktLenField); } - REPORT(); - - /* Loop through all pkt length values for tlm pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; +} /* end Test_CFE_SB_SetGetUserDataLength */ - msgId = SB_UT_TLM_MID; +void Test_CFE_SB_SetGetUserDataLength_TlmNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + int32 SetSize; + uint16 SizeReturned; + int16 ActualPktLenField; + int16 ExpPktLenField; - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, msgId); + /* Loop through all pkt length values for tlm pkts wo/sec hdr */ + memset(&SBNoSecHdrPkt, 0, sizeof(SBNoSecHdrPktPtr)); + CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); @@ -4744,20 +4039,10 @@ void Test_CFE_SB_SetGetUserDataLength(void) ActualPktLenField = UT_GetActualPktLenField(SBNoSecHdrPktPtr); ExpPktLenField = 0 + SetSize - 1; /* SecHdrSize + data - 1 */ - if (SizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned int) SizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } + ASSERT_EQ (SizeReturned, SetSize); + ASSERT_EQ (ActualPktLenField, ExpPktLenField); } - REPORT(); } /* end Test_CFE_SB_SetGetUserDataLength */ /* @@ -4767,22 +4052,17 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) { SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - SB_UT_Test_Tlm_t SBTlm; - CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; - SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; - CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; int32 SetSize; uint16 TotalMsgSizeReturned; int16 ActualPktLenField; int16 ExpPktLenField; - START(); - /* CCSDS pkt length field = TotalPktSize - 7 */ - /* Loop through all pkt length values for cmd pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; + /* + * Note this is no different for commands vs. telemetry vs. secondary header... + * This consolidates all the separate test cases - testing for different header types is redundant. + */ CFE_SB_SetMsgId(SBCmdPtr, SB_UT_CMD_MID); for (SetSize = 0; SetSize < 0x10000; SetSize++) @@ -4792,123 +4072,20 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) ActualPktLenField = UT_GetActualPktLenField(SBCmdPtr); ExpPktLenField = SetSize - 7; /* TotalPktSize - 7 */ - if (TotalMsgSizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned int) TotalMsgSizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } + ASSERT_EQ (TotalMsgSizeReturned, SetSize); + ASSERT_EQ (ActualPktLenField, ExpPktLenField); } - REPORT(); - - /* Loop through all pkt length values for cmd pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); - - for (SetSize = 0; SetSize < 0x10000; SetSize++) - { - CFE_SB_SetTotalMsgLength(SBNoSecHdrPktPtr, SetSize); - TotalMsgSizeReturned = CFE_SB_GetTotalMsgLength(SBNoSecHdrPktPtr); - ActualPktLenField = UT_GetActualPktLenField(SBNoSecHdrPktPtr); - ExpPktLenField = SetSize - 7; /* TotalPktSize - 7 */ - - if (TotalMsgSizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned int) TotalMsgSizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } - } - - REPORT(); - - /* Loop through all pkt length values for tlm pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - CFE_SB_SetMsgId(SBTlmPtr, SB_UT_TLM_MID); - - for (SetSize = 0; SetSize < 0x10000; SetSize++) - { - CFE_SB_SetTotalMsgLength(SBTlmPtr, SetSize); - TotalMsgSizeReturned = CFE_SB_GetTotalMsgLength(SBTlmPtr); - ActualPktLenField = UT_GetActualPktLenField(SBTlmPtr); - ExpPktLenField = SetSize - 7; /* TotalPktSize - 7 */ - - if (TotalMsgSizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned int) TotalMsgSizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } - } - - REPORT(); - - /* Loop through all pkt length values for tlm pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); - - for (SetSize = 0; SetSize < 0x10000; SetSize++) - { - CFE_SB_SetTotalMsgLength(SBNoSecHdrPktPtr, SetSize); - TotalMsgSizeReturned = CFE_SB_GetTotalMsgLength(SBNoSecHdrPktPtr); - ActualPktLenField = UT_GetActualPktLenField(SBNoSecHdrPktPtr); - ExpPktLenField = SetSize - 7; /* TotalPktSize - 7 */ - - if (TotalMsgSizeReturned != SetSize || - ActualPktLenField != ExpPktLenField) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SzRet=%u, SetSz=%ld, ActPL=%d, ExpPL=%d", - (unsigned int) TotalMsgSizeReturned, (long) SetSize, - (int) ActualPktLenField, (int) ExpPktLenField); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } - } - - REPORT(); } /* end Test_CFE_SB_SetGetTotalMsgLength */ /* ** Test setting and getting the message time field */ -void Test_CFE_SB_SetGetMsgTime(void) +void Test_CFE_SB_SetGetMsgTime_Cmd(void) { SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - SB_UT_Test_Tlm_t SBTlm; - CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; - SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; - CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; CFE_TIME_SysTime_t SetTime, GetTime; - int32 RtnFromSet; - CFE_SB_MsgId_t msgId; - - START(); - - /* Begin test for cmd pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Set MsgId to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); @@ -4916,43 +4093,27 @@ void Test_CFE_SB_SetGetMsgTime(void) /* Set MsgId */ CFE_SB_SetMsgId(SBCmdPtr, SB_UT_CMD_MID); - SetTime.Seconds = 0x4321; SetTime.Subseconds = 0x8765; - RtnFromSet = CFE_SB_SetMsgTime(SBCmdPtr, SetTime); + /* Verify CFE_SB_SetMsgTime returns CFE_SB_WRONG_MSG_TYPE for cmd + * pkts w/sec hdr */ + ASSERT_EQ(CFE_SB_SetMsgTime(SBCmdPtr, SetTime), CFE_SB_WRONG_MSG_TYPE); + GetTime.Seconds = 0xffff; GetTime.Subseconds = 0xffff; GetTime = CFE_SB_GetMsgTime(SBCmdPtr); - /* Verify CFE_SB_SetMsgTime returns CFE_SB_WRONG_MSG_TYPE for cmd - * pkts w/sec hdr - */ - if (RtnFromSet != CFE_SB_WRONG_MSG_TYPE) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "RtnFromSet=%ld, ExpReturn=0x%lx", - (long) RtnFromSet, (unsigned long) CFE_SB_WRONG_MSG_TYPE); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBCmdPtr, sizeof(SBCmd)); - } /* Verify the call to CFE_SB_GetMsgTime returns a time value of zero */ - else if (GetTime.Seconds != 0 || GetTime.Subseconds != 0) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "GetTime.Sec=%lu, GetTime.Subsec=%lu", - (unsigned long) GetTime.Seconds, - (unsigned long) GetTime.Subseconds); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBCmdPtr, sizeof(SBCmd)); - } + ASSERT_EQ(GetTime.Seconds, 0); + ASSERT_EQ(GetTime.Subseconds, 0); - REPORT(); +} /* end Test_CFE_SB_SetGetMsgTime */ - /* Begin test for cmd pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; +void Test_CFE_SB_SetGetMsgTime_CmdNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + CFE_TIME_SysTime_t SetTime, GetTime; /* Set MsgId to all f's */ memset(SBNoSecHdrPktPtr, 0xff, sizeof(SBNoSecHdrPkt)); @@ -4964,87 +4125,55 @@ void Test_CFE_SB_SetGetMsgTime(void) SetTime.Seconds = 0x4321; SetTime.Subseconds = 0x8765; - RtnFromSet = CFE_SB_SetMsgTime(SBNoSecHdrPktPtr, SetTime); + /* Verify CFE_SB_SetMsgTime returns CFE_SB_WRONG_MSG_TYPE for cmd + * pkts wo/sec hdr */ + ASSERT_EQ(CFE_SB_SetMsgTime(SBNoSecHdrPktPtr, SetTime), CFE_SB_WRONG_MSG_TYPE); + GetTime.Seconds = 0xffff; GetTime.Subseconds = 0xffff; GetTime = CFE_SB_GetMsgTime(SBNoSecHdrPktPtr); - /* Verify CFE_SB_SetMsgTime returns CFE_SB_WRONG_MSG_TYPE for cmd - * pkts wo/sec hdr - */ - if (RtnFromSet != CFE_SB_WRONG_MSG_TYPE) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "RtnFromSet=%ld, ExpReturn=0x%lx", - (long) RtnFromSet, (unsigned long) CFE_SB_WRONG_MSG_TYPE); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SB_UT_TstPktWoSecHdr_t)); - } /* Verify the call to CFE_SB_GetMsgTime returns a time value of zero */ - else if (GetTime.Seconds != 0 || GetTime.Subseconds != 0) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "GetTime.Sec=%lu, GetTime.Subsec=%lu", - (unsigned long) GetTime.Seconds, - (unsigned long) GetTime.Subseconds); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SB_UT_TstPktWoSecHdr_t)); - } + ASSERT_EQ(GetTime.Seconds, 0); + ASSERT_EQ(GetTime.Subseconds, 0); + +} /* end Test_CFE_SB_SetGetMsgTime */ - REPORT(); +void Test_CFE_SB_SetGetMsgTime_Tlm(void) +{ + SB_UT_Test_Tlm_t SBTlm; + CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; + CFE_TIME_SysTime_t SetTime, GetTime; /* Begin test for tlm pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Set MsgId to all f's */ memset(SBTlmPtr, 0xff, sizeof(SBTlm)); - msgId = SB_UT_TLM_MID; - /* Set MsgId to 0x0805 */ - CFE_SB_SetMsgId(SBTlmPtr, msgId); + CFE_SB_SetMsgId(SBTlmPtr, SB_UT_TLM_MID); SetTime.Seconds = 0x01234567; SetTime.Subseconds = 0x89abcdef; - RtnFromSet = CFE_SB_SetMsgTime(SBTlmPtr, SetTime); + /* Verify CFE_SB_SetMsgTime returns CFE_SUCCESS for tlm pkts w/sec hdr */ + ASSERT_EQ(CFE_SB_SetMsgTime(SBTlmPtr, SetTime), CFE_SUCCESS); + GetTime.Seconds = 0xffff; GetTime.Subseconds = 0xffff; GetTime = CFE_SB_GetMsgTime(SBTlmPtr); - /* Verify CFE_SB_SetMsgTime returns CFE_SUCCESS for tlm pkts w/sec hdr */ - if (RtnFromSet != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "RtnFromSet=%ld, ExpReturn=0", (long)RtnFromSet); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBTlmPtr, sizeof(SBTlm)); - } /* Verify CFE_SB_GetMsgTime returns the SetTime value w/2 LSBytes * of subseconds zeroed out */ - else if (GetTime.Seconds != SetTime.Seconds || - GetTime.Subseconds != (SetTime.Subseconds & 0xffff0000)) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "SetTime.Sec=%lu, GetTime.Sec=%lu, SetTime.Subsec=%lu, " - "GetTime.Subsec=%lu", - (unsigned long) SetTime.Seconds, - (unsigned long) GetTime.Seconds, - (unsigned long) SetTime.Subseconds, - (unsigned long) GetTime.Subseconds); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBTlmPtr, sizeof(SBTlm)); - } + ASSERT_EQ(GetTime.Seconds, SetTime.Seconds); + ASSERT_EQ(GetTime.Subseconds, SetTime.Subseconds & 0xffff0000); - REPORT(); +} /* end Test_CFE_SB_SetGetMsgTime */ - /* Begin test for tlm pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; +void Test_CFE_SB_SetGetMsgTime_TlmNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + CFE_TIME_SysTime_t SetTime, GetTime; /* Set MsgId to all f's */ memset(SBNoSecHdrPktPtr, 0xff, sizeof(SBNoSecHdrPkt)); @@ -5054,36 +4183,15 @@ void Test_CFE_SB_SetGetMsgTime(void) CCSDS_WR_SHDR(*((CCSDS_PriHdr_t*)SBNoSecHdrPktPtr), 0); SetTime.Seconds = 0x01234567; SetTime.Subseconds = 0x89abcdef; - RtnFromSet = CFE_SB_SetMsgTime(SBNoSecHdrPktPtr, SetTime); + ASSERT_EQ(CFE_SB_SetMsgTime(SBNoSecHdrPktPtr, SetTime), CFE_SB_WRONG_MSG_TYPE); GetTime.Seconds = 0xffff; GetTime.Subseconds = 0xffff; GetTime = CFE_SB_GetMsgTime(SBNoSecHdrPktPtr); - /* Verify CFE_SB_SetMsgTime returns CFE_SB_WRONG_MSG_TYPE for tlm - * pkts wo/sec hdr - */ - if (RtnFromSet != CFE_SB_WRONG_MSG_TYPE) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "RtnFromSet=%ld, ExpReturn=0x%lx", - (long) RtnFromSet, (unsigned long) CFE_SB_WRONG_MSG_TYPE); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - } /* Verify the call to CFE_SB_GetMsgTime returns a time value of zero */ - else if (GetTime.Seconds != 0 || GetTime.Subseconds != 0) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "GetTime.Sec=%lu, GetTime.Subsec=%lu", - (unsigned long) GetTime.Seconds, - (unsigned long) GetTime.Subseconds); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - } + ASSERT_EQ(GetTime.Seconds, 0); + ASSERT_EQ(GetTime.Subseconds, 0); - REPORT(); } /* end Test_CFE_SB_SetGetMsgTime */ /* @@ -5096,11 +4204,6 @@ void Test_CFE_SB_TimeStampMsg(void) CFE_TIME_SysTime_t GetTime; uint32 ExpSecs; - START(); - - /* Begin test for tlm pkts w/sec hdr */ - SB_ResetUnitTest(); - /* Note: Only Tlm Pkt with Sec Hdr is tested here because this function * (Test_CFE_SB_TimeStampMsg) is simply a call to * Test_CFE_SB_SetGetMsgTime. Test_CFE_SB_SetGetMsgTime has covered @@ -5126,54 +4229,30 @@ void Test_CFE_SB_TimeStampMsg(void) * CFE_TIME_GetTime. The stub for CFE_TIME_GetTime simply increments * the seconds cnt on each call */ - if (GetTime.Seconds != ExpSecs || GetTime.Subseconds != 0) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "GetTime.Sec=%lu, ExpSecs=%lu; GetTime.Subsec=%lu, " - "ExpSubsecs=0", - (unsigned long) GetTime.Seconds, - (unsigned long) ExpSecs, - (unsigned long) GetTime.Subseconds); - UT_Text(cMsg); - TestStat = CFE_FAIL; - UT_DisplayPkt(SBTlmPtr, sizeof(SB_UT_Test_Tlm_t)); - } + ASSERT_EQ(GetTime.Seconds, ExpSecs); + ASSERT_EQ(GetTime.Subseconds, 0); - REPORT(); } /* end Test_CFE_SB_TimeStampMsg */ /* ** Test setting and getting the opcode field of message */ -void Test_CFE_SB_SetGetCmdCode(void) +void Test_CFE_SB_SetGetCmdCode_Cmd(void) { SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - SB_UT_Test_Tlm_t SBTlm; - CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; - SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; - CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; - int32 RtnFromSet, ExpRtnFrmSet; - uint16 CmdCodeSet, CmdCodeReturned; - uint8 ActualCmdCodeField; - int16 ExpCmdCode; + uint16 CmdCodeSet; + uint16 ExpCmdCode; CCSDS_PriHdr_t *PktPtr; - CFE_SB_MsgId_t msgId; - - START(); /* Loop through all cmd code values(plus a few invalid) for cmd * pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Set MsgId to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); - msgId = SB_UT_CMD_MID; - - CFE_SB_InitMsg(SBCmdPtr, msgId, sizeof(SB_UT_Test_Cmd_t), true); + CFE_SB_InitMsg(SBCmdPtr, SB_UT_CMD_MID, sizeof(SB_UT_Test_Cmd_t), true); PktPtr = (CCSDS_PriHdr_t*)SBCmdPtr; @@ -5181,243 +4260,97 @@ void Test_CFE_SB_SetGetCmdCode(void) for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) { - RtnFromSet = CFE_SB_SetCmdCode(SBCmdPtr, CmdCodeSet); - - ExpRtnFrmSet = CFE_SUCCESS; - CmdCodeReturned = CFE_SB_GetCmdCode(SBCmdPtr); - ActualCmdCodeField = UT_GetActualCmdCodeField(SBCmdPtr); + ASSERT_EQ(CFE_SB_SetCmdCode(SBCmdPtr, CmdCodeSet), CFE_SUCCESS); /* GSFC CmdCode is the 7 LSBs of the 1st byte of cmd sec hdr */ ExpCmdCode = CmdCodeSet & 0x007f; - if (CmdCodeReturned != ExpCmdCode || - ActualCmdCodeField != ExpCmdCode || - RtnFromSet != ExpRtnFrmSet) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "CCRet=%d, CCSet=%d, ActCC=%d, ExpCC=%d, " - "RtnFrmSet=0x%lx, ExpRtFrmSet=0x%lx", - CmdCodeReturned, CmdCodeSet, ActualCmdCodeField, - ExpCmdCode, (unsigned long) RtnFromSet, - (unsigned long) ExpRtnFrmSet); - UT_Text(cMsg); - UT_DisplayPkt(SBCmdPtr, sizeof(SBCmd)); - TestStat = CFE_FAIL; - break; - } + ASSERT_EQ(CFE_SB_GetCmdCode(SBCmdPtr), ExpCmdCode); + ASSERT_EQ(UT_GetActualCmdCodeField(SBCmdPtr), ExpCmdCode); } - REPORT(); + + +} /* end Test_CFE_SB_SetGetCmdCode */ + +void Test_CFE_SB_SetGetCmdCode_NonCmd(void) +{ + SB_UT_Test_Tlm_t SBTlm; + CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + CCSDS_PriHdr_t *PktPtr; /* Loop through all cmd code values (plus a few invalid) for cmd * pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Set MsgId to all f's */ memset(SBNoSecHdrPktPtr, 0xff, sizeof(SB_UT_TstPktWoSecHdr_t)); + memset(SBTlmPtr, 0xff, sizeof(SBTlm)); /* Set MsgId */ - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); - + CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_CMD_MID); PktPtr = (CCSDS_PriHdr_t*)SBNoSecHdrPktPtr; - CCSDS_WR_SHDR(*PktPtr,0); - for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) - { - RtnFromSet = CFE_SB_SetCmdCode(SBNoSecHdrPktPtr, CmdCodeSet); - ExpRtnFrmSet = CFE_SB_WRONG_MSG_TYPE; - CmdCodeReturned = CFE_SB_GetCmdCode(SBNoSecHdrPktPtr); - ActualCmdCodeField = UT_GetActualCmdCodeField(SBNoSecHdrPktPtr); - - /* GSFC CmdCode is the 7 LSBs of the 1st byte of cmd Sec hdr */ - ExpCmdCode = CmdCodeSet & 0x007f; - - if (RtnFromSet != ExpRtnFrmSet) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "CCRet=%d, CCSet=%d, ActCC=%d, ExpCC=%d, " - "RtnFrmSet=0x%lx, ExpRtFrmSet=0x%lx", - CmdCodeReturned, CmdCodeSet, ActualCmdCodeField, - ExpCmdCode, (unsigned long) RtnFromSet, - (unsigned long) ExpRtnFrmSet); - UT_Text(cMsg); - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - TestStat = CFE_FAIL; - break; - } - } - - REPORT(); - - /* Loop through all cmd code values (plus a few invalid) for tlm - * pkts w/sec hdr - */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; + ASSERT_EQ(CFE_SB_SetCmdCode(SBNoSecHdrPktPtr, 11), CFE_SB_WRONG_MSG_TYPE); + ASSERT_EQ(CFE_SB_GetCmdCode(SBNoSecHdrPktPtr), 0); - /* Set MsgId to all f's */ - memset(SBTlmPtr, 0xff, sizeof(SBTlm)); - /* Set MsgId to 0x0805 */ CFE_SB_SetMsgId(SBTlmPtr, SB_UT_TLM_MID); - PktPtr = (CCSDS_PriHdr_t*)SBTlmPtr; - CCSDS_WR_SHDR(*PktPtr,1); - for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) - { - RtnFromSet = CFE_SB_SetCmdCode(SBTlmPtr, CmdCodeSet); - ExpRtnFrmSet = CFE_SB_WRONG_MSG_TYPE; - CmdCodeReturned = CFE_SB_GetCmdCode(SBTlmPtr); - ActualCmdCodeField = UT_GetActualCmdCodeField(SBTlmPtr); - - /* GSFC CmdCode is the 7 LSBs of the 1st byte of cmd Sec hdr */ - ExpCmdCode = CmdCodeSet & 0x007f; - - if (RtnFromSet != ExpRtnFrmSet) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "CCRet=%d, CCSet=%d, ActCC=%d, ExpCC=%d, " - "RtnFrmSet=0x%lx, ExpRtFrmSet=0x%lx", - CmdCodeReturned, CmdCodeSet, ActualCmdCodeField, - ExpCmdCode, (unsigned long) RtnFromSet, - (unsigned long) ExpRtnFrmSet); - UT_Text(cMsg); - UT_DisplayPkt(SBTlmPtr, sizeof(SBTlm)); - TestStat = CFE_FAIL; - break; - } - } - - REPORT(); - - /* Loop through all cmd code values (plus a few invalid) for tlm - * pkts wo/sec hdr - */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; - - /* Set pkt to all f's */ - memset(SBNoSecHdrPktPtr, 0xff, sizeof(SBNoSecHdrPkt)); - - /* Set MsgId to 0x0005 */ - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); - - PktPtr = (CCSDS_PriHdr_t*)SBNoSecHdrPktPtr; + ASSERT_EQ(CFE_SB_SetCmdCode(SBTlmPtr, 22), CFE_SB_WRONG_MSG_TYPE); + ASSERT_EQ(CFE_SB_GetCmdCode(SBTlmPtr), 0); - CCSDS_WR_SHDR(*PktPtr,0); - - for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) - { - RtnFromSet = CFE_SB_SetCmdCode(SBNoSecHdrPktPtr, CmdCodeSet); - ExpRtnFrmSet = CFE_SB_WRONG_MSG_TYPE; - CmdCodeReturned = CFE_SB_GetCmdCode(SBNoSecHdrPktPtr); - ActualCmdCodeField = UT_GetActualCmdCodeField(SBNoSecHdrPktPtr); - - /* GSFC CmdCode is the 7 LSBs of the 1st byte of cmd sec hdr */ - ExpCmdCode = CmdCodeSet & 0x007f; - - if (RtnFromSet != ExpRtnFrmSet) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "CCRet=%d, CCSet=%d, ActCC=%d, ExpCC=%d, " - "RtnFrmSet=0x%lx, ExpRtFrmSet=0x%lx", - CmdCodeReturned, CmdCodeSet, ActualCmdCodeField, - ExpCmdCode, (unsigned long) RtnFromSet, - (unsigned long) ExpRtnFrmSet); - UT_Text(cMsg); - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - TestStat = CFE_FAIL; - break; - } - } - - REPORT(); } /* end Test_CFE_SB_SetGetCmdCode */ - /* ** Test generating, setting, getting, and validating a checksum field ** for a message */ -void Test_CFE_SB_ChecksumUtils(void) +void Test_CFE_SB_ChecksumUtils_Cmd(void) { SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; - SB_UT_Test_Tlm_t SBTlm; - CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; - SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; - CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; - uint16 RtnFrmGet, ExpRtnFrmGet; - bool RtnFrmValidate, ExpRtnFrmVal; - - START(); - - /* Begin test for cmd pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; + uint16 ExpRtnFrmGet; /* Initialize pkt, setting data to zero */ - CFE_SB_InitMsg(SBCmdPtr, CFE_SB_ValueToMsgId(0x1805), sizeof(SBCmd), true); - - CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1805 ); + CFE_SB_InitMsg(SBCmdPtr, SB_UT_CMD_MID4, sizeof(SBCmd), true); /* Set checksum field */ CFE_SB_GenerateChecksum(SBCmdPtr); - RtnFrmGet = CFE_SB_GetChecksum(SBCmdPtr); #ifndef MESSAGE_FORMAT_IS_CCSDS_VER_2 ExpRtnFrmGet = 0x2f; #else ExpRtnFrmGet = 0x65; #endif + ASSERT_EQ(CFE_SB_GetChecksum(SBCmdPtr), ExpRtnFrmGet); /* Validation expected to return true */ - RtnFrmValidate = CFE_SB_ValidateChecksum(SBCmdPtr); - ExpRtnFrmVal = true; - - if (RtnFrmGet != ExpRtnFrmGet || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected results in 1st check, RtnFrmValidate=%d, " - "ExpRtnFrmVal=%d, RtnFrmGet=0x%x, ExpRtnFrmGet=0x%x", - RtnFrmValidate, ExpRtnFrmVal, RtnFrmGet, ExpRtnFrmGet); - UT_Text(cMsg); - UT_DisplayPkt(SBCmdPtr, sizeof(SBCmd)); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CFE_SB_ValidateChecksum(SBCmdPtr)); - /* Change 1 byte in pkt and verify checksum is no longer valid. - * Increment MsgId by 1 to 0x1806. Validation expected to - * return false + /* Flip 1 bit in pkt and verify checksum is no longer valid. + * Validation expected to return false */ - CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1806 ); + SBCmdPtr->Byte[0] ^= 0x02; - RtnFrmValidate = CFE_SB_ValidateChecksum(SBCmdPtr); - ExpRtnFrmVal = false; + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBCmdPtr)); - if (TestStat == CFE_FAIL || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Second validate...RtnFrmValidate=%d, ExpRtnFrmVal=%d", - RtnFrmValidate, ExpRtnFrmVal); - UT_Text(cMsg); - UT_DisplayPkt(SBCmdPtr, sizeof(SBCmd)); - TestStat = CFE_FAIL; - } +} /* end Test_CFE_SB_ChecksumUtils */ - REPORT(); +void Test_CFE_SB_ChecksumUtils_CmdNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; /* Begin test for cmd pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Initialize pkt, setting data to zero */ - CFE_SB_InitMsg(SBNoSecHdrPktPtr, CFE_SB_ValueToMsgId(0x1005), + CFE_SB_InitMsg(SBNoSecHdrPktPtr, SB_UT_BARE_CMD_MID3, sizeof(SBNoSecHdrPkt), true); @@ -5425,139 +4358,70 @@ void Test_CFE_SB_ChecksumUtils(void) /* Set checksum field */ CFE_SB_GenerateChecksum(SBNoSecHdrPktPtr); - RtnFrmGet = CFE_SB_GetChecksum(SBNoSecHdrPktPtr); - ExpRtnFrmGet = 0; + ASSERT_EQ(CFE_SB_GetChecksum(SBNoSecHdrPktPtr), 0); /* Validation expected to return false */ - RtnFrmValidate = CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr); - ExpRtnFrmVal = false; + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr)); - if (RtnFrmGet != ExpRtnFrmGet || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected results in 1st check, RtnFrmValidate=%d, " - "ExpRtnFrmVal=%d, RtnFrmGet=0x%x, ExpRtnFrmGet=0x%x", - RtnFrmValidate, ExpRtnFrmVal, RtnFrmGet, ExpRtnFrmGet); - UT_Text(cMsg); - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - TestStat = CFE_FAIL; - } - - /* Change 1 byte in pkt and verify checksum is no longer valid. - * Increment MsgId by 1 to 0x1006. Validation expected to - * return false + /* Flip 1 bit in pkt and verify checksum is no longer valid. + * Validation expected to return false */ - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); + SBNoSecHdrPktPtr->Byte[0] ^= 0x02; - CCSDS_WR_SHDR( SBCmdPtr->Hdr, 0 ); - RtnFrmValidate = CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr); - ExpRtnFrmVal = false; + CCSDS_WR_SHDR( SBNoSecHdrPktPtr->Hdr, 0 ); + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr)); - if (TestStat == CFE_FAIL || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Second validate...RtnFrmValidate=%d, ExpRtnFrmVal=%d", - RtnFrmValidate, ExpRtnFrmVal); - UT_Text(cMsg); - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - TestStat = CFE_FAIL; - } +} /* end Test_CFE_SB_ChecksumUtils */ - REPORT(); +void Test_CFE_SB_ChecksumUtils_Tlm(void) +{ + SB_UT_Test_Tlm_t SBTlm; + CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; /* Begin test for tlm pkts w/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; /* Initialize pkt, setting data to zero */ CFE_SB_InitMsg(SBTlmPtr, CFE_SB_ValueToMsgId(0x0805), sizeof(SBTlm), true); /* Set checksum field */ CFE_SB_GenerateChecksum(SBTlmPtr); - RtnFrmGet = CFE_SB_GetChecksum(SBTlmPtr); - ExpRtnFrmGet = 0; + ASSERT_EQ(CFE_SB_GetChecksum(SBTlmPtr), 0); /* Validation expected to return false */ - RtnFrmValidate = CFE_SB_ValidateChecksum(SBTlmPtr); - ExpRtnFrmVal = false; - - if (RtnFrmGet != ExpRtnFrmGet || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected results in 1st check, RtnFrmValidate=%d, " - "ExpRtnFrmVal=%d, RtnFrmGet=0x%x, ExpRtnFrmGet=0x%x", - RtnFrmValidate, ExpRtnFrmVal, RtnFrmGet, ExpRtnFrmGet); - UT_Text(cMsg); - UT_DisplayPkt(SBTlmPtr, sizeof(SBTlm)); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBTlmPtr)); - /* Change 1 byte in pkt and verify checksum is no longer valid. - * Increment MsgId by 1 to 0x0806. Validation expected to return false + /* Flip 1 bit in pkt and verify checksum is no longer valid. + * Validation expected to return false */ - CFE_SB_SetMsgId(SBTlmPtr, CFE_SB_ValueToMsgId(0x1806)); - RtnFrmValidate = CFE_SB_ValidateChecksum(SBTlmPtr); - ExpRtnFrmVal = false; + SBTlmPtr->Byte[0] ^= 0x02; - if (TestStat == CFE_FAIL || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Second validate...RtnFrmValidate=%d, ExpRtnFrmVal=%d", - RtnFrmValidate, ExpRtnFrmVal); - UT_Text(cMsg); - UT_DisplayPkt(SBTlmPtr, sizeof(SBTlm)); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBTlmPtr)); - REPORT(); +} /* end Test_CFE_SB_ChecksumUtils */ - /* Begin test for tlm pkts wo/sec hdr */ - SB_ResetUnitTest(); - TestStat = CFE_PASS; +void Test_CFE_SB_ChecksumUtils_TlmNoSecHdr(void) +{ + SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; + CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; + /* Begin test for tlm pkts wo/sec hdr */ /* Initialize pkt, setting data to zero */ - CFE_SB_InitMsg(SBNoSecHdrPktPtr, CFE_SB_ValueToMsgId(0x0005), + CFE_SB_InitMsg(SBNoSecHdrPktPtr, SB_UT_BARE_TLM_MID3, sizeof(SBNoSecHdrPkt), true); /* Setting checksum field */ CFE_SB_GenerateChecksum(SBNoSecHdrPktPtr); - RtnFrmGet = CFE_SB_GetChecksum(SBNoSecHdrPktPtr); - ExpRtnFrmGet = 0; + ASSERT_EQ(CFE_SB_GetChecksum(SBNoSecHdrPktPtr), 0); /* Validation expected to return false */ - RtnFrmValidate = CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr); - ExpRtnFrmVal = false; - - if (RtnFrmGet != ExpRtnFrmGet || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected results in 1st check, RtnFrmValidate=%d, " - "ExpRtnFrmVal=%d, RtnFrmGet=0x%x, ExpRtnFrmGet=0x%x", - RtnFrmValidate, ExpRtnFrmVal, RtnFrmGet, ExpRtnFrmGet); - UT_Text(cMsg); - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr)); - /* Change 1 byte in pkt and verify checksum is no longer valid. - * Increment MsgId by 1 to 0x0006. Validation expected to - * return false + /* Flip 1 bit in pkt and verify checksum is no longer valid. + * Validation expected to return false */ - CFE_SB_SetMsgId(SBNoSecHdrPktPtr, CFE_SB_ValueToMsgId(0x0006)); - RtnFrmValidate = CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr); - ExpRtnFrmVal = false; + SBNoSecHdrPktPtr->Byte[0] ^= 0x02; + ASSERT_TRUE(!CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr)); - if (TestStat == CFE_FAIL || RtnFrmValidate != ExpRtnFrmVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Second validate...RtnFrmValidate=%d, ExpRtnFrmVal=%d", - RtnFrmValidate, ExpRtnFrmVal); - UT_Text(cMsg); - UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); - TestStat = CFE_FAIL; - } - - REPORT(); } /* end Test_CFE_SB_ChecksumUtils */ /* @@ -5567,23 +4431,13 @@ void Test_CFE_SB_ValidateMsgId(void) { CFE_SB_MsgId_t MsgId; - START(); - - SB_ResetUnitTest(); - /* Validate Msg Id */ MsgId = SB_UT_LAST_VALID_MID; CFE_SB_ValidateMsgId(MsgId); - REPORT(); - - START(); - /* Test for invalid msg id */ MsgId = SB_UT_ALTERNATE_INVALID_MID; CFE_SB_ValidateMsgId(MsgId); - - REPORT(); } /* @@ -5591,20 +4445,20 @@ void Test_CFE_SB_ValidateMsgId(void) */ void Test_SB_SpecialCases(void) { - STARTBLOCK(); - - Test_OS_MutSem_ErrLogic(); - Test_ReqToSendEvent_ErrLogic(); - Test_PutDestBlk_ErrLogic(); - Test_CFE_SB_GetPipeIdx(); - Test_CFE_SB_Buffers(); - Test_CFE_SB_BadPipeInfo(); - Test_SB_SendMsgPaths(); - Test_RcvMsg_UnsubResubPath(); - Test_MessageString(); - Test_SB_IdxPushPop(); - - ENDBLOCK(); + SB_UT_ADD_SUBTEST(Test_OS_MutSem_ErrLogic); + SB_UT_ADD_SUBTEST(Test_ReqToSendEvent_ErrLogic); + SB_UT_ADD_SUBTEST(Test_PutDestBlk_ErrLogic); + SB_UT_ADD_SUBTEST(Test_CFE_SB_GetPipeIdx); + SB_UT_ADD_SUBTEST(Test_CFE_SB_Buffers); + SB_UT_ADD_SUBTEST(Test_CFE_SB_BadPipeInfo); + SB_UT_ADD_SUBTEST(Test_SB_SendMsgPaths_Nominal); + SB_UT_ADD_SUBTEST(Test_SB_SendMsgPaths_LimitErr); + SB_UT_ADD_SUBTEST(Test_SB_SendMsgPaths_FullErr); + SB_UT_ADD_SUBTEST(Test_SB_SendMsgPaths_WriteErr); + SB_UT_ADD_SUBTEST(Test_SB_SendMsgPaths_IgnoreOpt); + SB_UT_ADD_SUBTEST(Test_RcvMsg_UnsubResubPath); + SB_UT_ADD_SUBTEST(Test_MessageString); + SB_UT_ADD_SUBTEST(Test_SB_IdxPushPop); } /* end Test_SB_SpecialCases */ /* @@ -5615,10 +4469,6 @@ void Test_SB_IdxPushPop() int32 i; CFE_SB_MsgRouteIdx_t Idx; - START(); - - SB_ResetUnitTest(); - CFE_SB_InitIdxStack(); for (i = 0; i < CFE_PLATFORM_SB_MAX_MSG_IDS; i++) @@ -5632,15 +4482,6 @@ void Test_SB_IdxPushPop() Idx = CFE_SB_RouteIdxPop_Unsync(); ASSERT_EQ(CFE_SB_RouteIdxToValue(Idx), CFE_SB_RouteIdxToValue(CFE_SB_INVALID_ROUTE_IDX)); - /* - * This sub-unit test is dependent upon the previous - * Maybe do a - * - SB_ResetUnitTest(); - - CFE_SB_InitIdxStack(); - * again here - */ for (i = 0; i < CFE_PLATFORM_SB_MAX_MSG_IDS; i++) { /* Un-subscribe from all messages */ @@ -5649,7 +4490,6 @@ void Test_SB_IdxPushPop() CFE_SB_RouteIdxPush_Unsync(CFE_SB_ValueToRouteIdx(i)); - REPORT(); } /* end Test_SB_IdxPushPop */ @@ -5662,9 +4502,6 @@ void Test_OS_MutSem_ErrLogic(void) CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 50; - START(); - - SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, OS_SEM_FAILURE); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 2, OS_SEM_FAILURE); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); @@ -5678,7 +4515,6 @@ void Test_OS_MutSem_ErrLogic(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_OS_MutSemTake_ErrLogic */ /* @@ -5689,10 +4525,6 @@ void Test_ReqToSendEvent_ErrLogic(void) uint32 TaskId = 13; uint32 Bit = 5; - START(); - - SB_ResetUnitTest(); - /* Clear task bits, then call function, which should set the bit for * the specified task */ @@ -5706,7 +4538,6 @@ void Test_ReqToSendEvent_ErrLogic(void) EVTCNT(0); - REPORT(); } /* end Test_ReqToSendEvent_ErrLogic */ /* @@ -5715,14 +4546,10 @@ void Test_ReqToSendEvent_ErrLogic(void) */ void Test_PutDestBlk_ErrLogic(void) { - START(); - - SB_ResetUnitTest(); ASSERT_EQ(CFE_SB_PutDestinationBlk(NULL), CFE_SB_BAD_ARGUMENT); EVTCNT(0); - REPORT(); } /* end Test_PutDestBlk_ErrLogic */ /* @@ -5730,16 +4557,12 @@ void Test_PutDestBlk_ErrLogic(void) */ void Test_CFE_SB_GetPipeIdx(void) { - START(); - - SB_ResetUnitTest(); CFE_SB.PipeTbl[0].PipeId = 0; CFE_SB.PipeTbl[0].InUse = CFE_SB_NOT_IN_USE; ASSERT_EQ(CFE_SB_GetPipeIdx(0), CFE_SB_INVALID_PIPE); EVTCNT(0); - REPORT(); } /* end Test_CFE_SB_GetPipeIdx */ /* @@ -5751,9 +4574,6 @@ void Test_CFE_SB_Buffers(void) CFE_SB_BufferD_t *bd; - START(); - - SB_ResetUnitTest(); CFE_SB.StatTlmMsg.Payload.MemInUse = 0; CFE_SB.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_BufferD_t) * 4; bd = CFE_SB_GetBufferFromPool(SB_UT_FIRST_VALID_MID, 0); @@ -5762,10 +4582,6 @@ void Test_CFE_SB_Buffers(void) EVTCNT(0); - REPORT(); - - START(); - ExpRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_ReturnBufferToPool(bd); @@ -5773,20 +4589,12 @@ void Test_CFE_SB_Buffers(void) EVTCNT(0); - REPORT(); - - START(); - bd->UseCount = 0; CFE_SB_DecrBufUseCnt(bd); ASSERT_EQ(bd->UseCount, 0); EVTCNT(0); - REPORT(); - - START(); - UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB.StatTlmMsg.Payload.MemInUse = 0; CFE_SB_PutDestinationBlk((CFE_SB_DestinationD_t *) bd); @@ -5795,7 +4603,6 @@ void Test_CFE_SB_Buffers(void) EVTCNT(0); - REPORT(); } /* end Test_CFE_SB_Buffers */ /* @@ -5807,9 +4614,6 @@ void Test_CFE_SB_BadPipeInfo(void) uint16 PipeDepth = 10; CFE_SB_Qos_t CFE_SB_Default_Qos; - START(); - - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1")); /* Set the pipe ID to an erroneous value and attempt to delete the pipe */ @@ -5819,10 +4623,6 @@ void Test_CFE_SB_BadPipeInfo(void) EVTCNT(2); - REPORT(); - - START(); - /* Reset the pipe ID and delete the pipe */ CFE_SB.PipeTbl[0].PipeId = 0; @@ -5833,14 +4633,13 @@ void Test_CFE_SB_BadPipeInfo(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_CFE_SB_BadPipeInfo */ /* ** Test send housekeeping information command */ -void Test_SB_SendMsgPaths(void) +void Test_SB_SendMsgPaths_Nominal(void) { CFE_SB_CmdHdr_t NoParamCmd; CFE_SB_MsgId_t MsgId; @@ -5849,10 +4648,6 @@ void Test_SB_SendMsgPaths(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 2; - START(); - - /* Test inhibiting sending a "no subscriptions for a message ID" message */ - SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_ValueToMsgId(CFE_SB_SEND_HK_MID), sizeof(NoParamCmd), true); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; @@ -5877,7 +4672,6 @@ void Test_SB_SendMsgPaths(void) /* Create a message ID with the command bit set and disable reporting */ MsgId = SB_UT_CMD_MID; - SB_ResetUnitTest(); CFE_SB.SenderReporting = 0; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -5887,13 +4681,18 @@ void Test_SB_SendMsgPaths(void) EVTCNT(3); TEARDOWN(CFE_SB_DeletePipe(PipeId)); +} /* end Test_SB_SendMsgPaths */ - REPORT(); +void Test_SB_SendMsgPaths_LimitErr(void) +{ + CFE_SB_MsgId_t MsgId; + CFE_SB_PipeId_t PipeId; + SB_UT_Test_Tlm_t TlmPkt; + CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; + int32 PipeDepth = 2; - START(); /* Test inhibiting sending a "message ID limit error" message */ - SB_ResetUnitTest(); MsgId = SB_UT_TLM_MID; CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); @@ -5912,12 +4711,19 @@ void Test_SB_SendMsgPaths(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); +} /* end Test_SB_SendMsgPaths */ - START(); + +void Test_SB_SendMsgPaths_FullErr(void) +{ + CFE_SB_MsgId_t MsgId; + CFE_SB_PipeId_t PipeId; + SB_UT_Test_Tlm_t TlmPkt; + CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; + int32 PipeDepth = 2; /* Test inhibiting sending a "pipe full" message */ - SB_ResetUnitTest(); + MsgId = SB_UT_TLM_MID; CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -5936,13 +4742,19 @@ void Test_SB_SendMsgPaths(void) EVTCNT(3); TEARDOWN(CFE_SB_DeletePipe(PipeId)); +} /* end Test_SB_SendMsgPaths */ - REPORT(); +void Test_SB_SendMsgPaths_WriteErr(void) +{ + CFE_SB_MsgId_t MsgId; + CFE_SB_PipeId_t PipeId; + SB_UT_Test_Tlm_t TlmPkt; + CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; + int32 PipeDepth = 2; - START(); /* Test inhibiting sending a "pipe write error" message */ - SB_ResetUnitTest(); + MsgId = SB_UT_TLM_MID; SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); @@ -5958,12 +4770,19 @@ void Test_SB_SendMsgPaths(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); +} /* end Test_SB_SendMsgPaths */ + +void Test_SB_SendMsgPaths_IgnoreOpt(void) +{ + CFE_SB_MsgId_t MsgId; + CFE_SB_PipeId_t PipeId; + SB_UT_Test_Tlm_t TlmPkt; + CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; + int32 PipeDepth = 2; - START(); /* Setup Test skipping sending to a pipe when the pipe option is set to ignore */ - SB_ResetUnitTest(); + MsgId = SB_UT_TLM_MID; CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SkipPipe")); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -5975,9 +4794,9 @@ void Test_SB_SendMsgPaths(void) TEARDOWN(CFE_SB_SetPipeOpts(PipeId, 0)); TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_SB_SendMsgPaths */ + /* ** Test receiving a message response to a unsubscribing to message, then ** resubscribing to it while it's in the pipe @@ -5991,8 +4810,6 @@ void Test_RcvMsg_UnsubResubPath(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; uint32 PipeDepth = 10; - START(); - SB_ResetUnitTest(); SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); SETUP(CFE_SB_Subscribe(MsgId, PipeId)); @@ -6010,7 +4827,6 @@ void Test_RcvMsg_UnsubResubPath(void) TEARDOWN(CFE_SB_DeletePipe(PipeId)); - REPORT(); } /* end Test_RcvMsg_UnsubResubPath */ /* @@ -6023,8 +4839,6 @@ void Test_MessageString(void) char *DestStringPtr = DestString; const char *DefString = "default"; - SB_ResetUnitTest(); - /* Test setting string where the destination size > source string size */ CFE_SB_MessageStringSet(DestStringPtr, SrcString, sizeof(DestString), strlen(SrcString)); diff --git a/fsw/cfe-core/unit-test/sb_UT.h b/fsw/cfe-core/unit-test/sb_UT.h index 0b7f014a2..0ec5effef 100644 --- a/fsw/cfe-core/unit-test/sb_UT.h +++ b/fsw/cfe-core/unit-test/sb_UT.h @@ -1385,7 +1385,7 @@ void Test_SB_Cmds_SubRptOff(void); ** ** \par Description ** This function tests the command handler response to an invalid -** command code. +** command code in the CFE_SB_CMD_MID handler. ** ** \par Assumptions, External Events, and Notes: ** None @@ -1398,7 +1398,28 @@ void Test_SB_Cmds_SubRptOff(void); ** \sa #UT_Report ** ******************************************************************************/ -void Test_SB_Cmds_UnexpCmdCode(void); +void Test_SB_Cmds_CmdUnexpCmdCode(void); + +/*****************************************************************************/ +/** +** \brief Test command handler response to an invalid command code +** +** \par Description +** This function tests the command handler response to an invalid +** command code in the CFE_SB_SUB_RPT_CTRL_MID handler +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_InitMsg, #CFE_SB_SetCmdCode, +** \sa #CFE_SB_ProcessCmdPipePkt, #UT_GetNumEventsSent, #UT_EventIsInHistory, +** \sa #UT_Report +** +******************************************************************************/ +void Test_SB_Cmds_SubRptUnexpCmdCode(void); /*****************************************************************************/ /** @@ -3167,10 +3188,29 @@ void Test_CFE_SB_InitMsg_False(void); /*****************************************************************************/ /** -** \brief Test getting the size of a command/telemetry message header +** \brief Test getting the size of a command message header +** +** \par Description +** This function tests getting the size of a command message +** header. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \returns +** This function does not return a value. +** +** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_MsgHdrSize, #UT_Report +** +******************************************************************************/ +void Test_CFE_SB_MsgHdrSize_Cmd(void); + +/*****************************************************************************/ +/** +** \brief Test getting the size of a telemetry message header ** ** \par Description -** This function tests getting the size of a command/telemetry message +** This function tests getting the size of a telemetry message ** header. ** ** \par Assumptions, External Events, and Notes: @@ -3182,7 +3222,7 @@ void Test_CFE_SB_InitMsg_False(void); ** \sa #UT_Text, #SB_ResetUnitTest, #CFE_SB_MsgHdrSize, #UT_Report ** ******************************************************************************/ -void Test_CFE_SB_MsgHdrSize(void); +void Test_CFE_SB_MsgHdrSize_Tlm(void); /*****************************************************************************/ /** @@ -3202,7 +3242,10 @@ void Test_CFE_SB_MsgHdrSize(void); ** \sa #UT_Report ** ******************************************************************************/ -void Test_CFE_SB_GetUserData(void); +void Test_CFE_SB_GetUserData_Cmd(void); +void Test_CFE_SB_GetUserData_CmdNoSecHdr(void); +void Test_CFE_SB_GetUserData_Tlm(void); +void Test_CFE_SB_GetUserData_TlmNoSecHdr(void); /*****************************************************************************/ /** @@ -3242,7 +3285,10 @@ void Test_CFE_SB_SetGetMsgId(void); ** \sa #UT_GetActualPktLenField, #UT_Report ** ******************************************************************************/ -void Test_CFE_SB_SetGetUserDataLength(void); +void Test_CFE_SB_SetGetUserDataLength_Cmd(void); +void Test_CFE_SB_SetGetUserDataLength_CmdNoSecHdr(void); +void Test_CFE_SB_SetGetUserDataLength_Tlm(void); +void Test_CFE_SB_SetGetUserDataLength_TlmNoSecHdr(void); /*****************************************************************************/ /** @@ -3281,7 +3327,10 @@ void Test_CFE_SB_SetGetTotalMsgLength(void); ** \sa #CFE_SB_GetMsgTime, #UT_DisplayPkt, #UT_Report ** ******************************************************************************/ -void Test_CFE_SB_SetGetMsgTime(void); +void Test_CFE_SB_SetGetMsgTime_Cmd(void); +void Test_CFE_SB_SetGetMsgTime_CmdNoSecHdr(void); +void Test_CFE_SB_SetGetMsgTime_Tlm(void); +void Test_CFE_SB_SetGetMsgTime_TlmNoSecHdr(void); /*****************************************************************************/ /** @@ -3320,7 +3369,8 @@ void Test_CFE_SB_TimeStampMsg(void); ** \sa #UT_Report ** ******************************************************************************/ -void Test_CFE_SB_SetGetCmdCode(void); +void Test_CFE_SB_SetGetCmdCode_Cmd(void); +void Test_CFE_SB_SetGetCmdCode_NonCmd(void); /*****************************************************************************/ /** @@ -3342,7 +3392,10 @@ void Test_CFE_SB_SetGetCmdCode(void); ** \sa #CFE_SB_SetMsgId, #UT_Report ** ******************************************************************************/ -void Test_CFE_SB_ChecksumUtils(void); +void Test_CFE_SB_ChecksumUtils_Cmd(void); +void Test_CFE_SB_ChecksumUtils_CmdNoSecHdr(void); +void Test_CFE_SB_ChecksumUtils_Tlm(void); +void Test_CFE_SB_ChecksumUtils_TlmNoSecHdr(void); /*****************************************************************************/ /** @@ -3524,7 +3577,11 @@ void Test_CFE_SB_BadPipeInfo(void); ** \sa #CFE_SB_SendMsg, #CFE_SB_DeletePipe, #CFE_SB_SubscribeEx, #UT_Report ** ******************************************************************************/ -void Test_SB_SendMsgPaths(void); +void Test_SB_SendMsgPaths_Nominal(void); +void Test_SB_SendMsgPaths_LimitErr(void); +void Test_SB_SendMsgPaths_FullErr(void); +void Test_SB_SendMsgPaths_WriteErr(void); +void Test_SB_SendMsgPaths_IgnoreOpt(void); /*****************************************************************************/ /** diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index bbca578d3..19c208306 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -693,145 +693,102 @@ uint32 UT_PrintfIsInHistory(const char *MsgToSearchFor) return UT_GetMessageCount(MsgToSearchFor, &UT_PrintfBuffer, UT_StrCmpFormatStr); } -int32 TestStat; - -void UT_STARTBLOCK_impl(const char *FileName, int LineNum, const char *TestName) -{ -#ifdef VERBOSE - char cMsg[UT_MAX_MESSAGE_LENGTH]; - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Start Block", TestName, FileName, LineNum); - UT_Text(cMsg); -#endif /* VERBOSE */ -} - -void UT_START_impl(const char *FileName, int LineNum, const char *TestName) +void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), const char *GroupName, const char *TestName) { -#ifdef VERBOSE - char cMsg[UT_MAX_MESSAGE_LENGTH]; - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Start", TestName, FileName, LineNum); - UT_Text(cMsg); -#endif /* VERBOSE */ - - TestStat = CFE_PASS; -} + char CompleteTestName[128]; + const char *GroupPtr; + const char *TestPtr; -void UT_REPORT_impl(const char *FileName, int LineNum, const char *TestName) -{ - UT_Report(FileName, LineNum, TestStat, TestName, "Report"); -} + /* Remove any common prefix between the two names. + * They are often function names that all start with "Test_XXX" + * and this repetitive information just becomes clutter. + */ + GroupPtr = GroupName; + TestPtr = TestName; + while (*GroupPtr != 0 && *GroupPtr == *TestPtr) + { + ++GroupPtr; + ++TestPtr; + } -bool UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) -{ - char cMsg[UT_MAX_MESSAGE_LENGTH]; + /* + * Only break at an underscore(_) to avoid weird effects + */ + while(TestPtr > TestName && *TestPtr != '_') + { + --TestPtr; + } + if (*TestPtr == '_') + { + ++TestPtr; + } - if(FnRet != CFE_SUCCESS) + /* + * Remove a remaining "Test_" prefix on the group name. + * Again just to remove common repetitive content + */ + GroupPtr = GroupName; + if (strncmp(GroupPtr, "Test_", 5) == 0) { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Setup failed (%s returned %ld)", - TestName, FileName, LineNum, FnName, (long int)FnRet); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; + GroupPtr += 5; } - return true; + + (void)snprintf(CompleteTestName, sizeof(CompleteTestName), "%s.%s", GroupPtr, TestPtr); + + /* + * Note that UtTest_Add() does not copy the string - it retains the passed-in pointer. + * Therefore it must be duplicated. + * + * This isn't an issue on Linux as the memory is freed when the process exits, but + * might be an issue on VxWorks. + */ + + UtTest_Add(Test, Setup, Teardown, strdup(CompleteTestName)); } -bool UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) { - char cMsg[UT_MAX_MESSAGE_LENGTH]; + UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TSF, FileName, LineNum, "%s - Setup - %s returned %ld", + TestName, FnName, (long int)FnRet); +} - if(FnRet != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Assert failed (%s returned %ld)", - TestName, FileName, LineNum, FnName, (long int)FnRet); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; - } - return true; +void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + UtAssertEx(FnRet == CFE_SUCCESS, UtAssert_GetContext(), FileName, LineNum, "%s - %s returned %ld, expected CFE_SUCCESS", + TestName, FnName, (long int)FnRet); } -bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, +void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *FnName, int32 FnRet, const char *ExpName, int32 Exp) { - char cMsg[UT_MAX_MESSAGE_LENGTH]; - - if(FnRet != Exp) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Assert failed (%s [%ld] != %s[%ld])", - TestName, FileName, LineNum, FnName, (long int)FnRet, ExpName, (long int)Exp); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; - } - return true; + UtAssertEx(FnRet == Exp, UtAssert_GetContext(), FileName, LineNum, "%s - value %ld, expected %s[%ld]", + FnName, (long)FnRet, ExpName, (long)Exp); } -bool UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, +void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, const char *ExpName, bool Exp) { - char cMsg[UT_MAX_MESSAGE_LENGTH]; - - if(!Exp) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Assert failed (%s)", - TestName, FileName, LineNum, ExpName); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; - } - return true; + UtAssertEx(Exp, UtAssert_GetContext(), FileName, LineNum, "%s - %s", + TestName, ExpName); } -bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp) +void UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp) { - char cMsg[UT_MAX_MESSAGE_LENGTH]; - int32 CntSent = UT_GetNumEventsSent(); - if(CntSent != CntExp) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Event count (sent: %ld != expected: %ld)", - TestName, FileName, LineNum, (long int)CntSent, (long int)CntExp); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; - } - return true; -} - -bool UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId) -{ - char cMsg[UT_MAX_MESSAGE_LENGTH]; - if(!UT_EventIsInHistory(EvtId)) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Event not sent (%s [%ld])", - TestName, FileName, LineNum, EvtName, (long int)EvtId); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; - } - return true; + UtAssertEx(CntSent == CntExp, UtAssert_GetContext(), FileName, LineNum, "%s - event count (sent %ld, expected %ld)", + TestName, (long int)CntSent, (long int)CntExp); } -bool UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId) { - char cMsg[UT_MAX_MESSAGE_LENGTH]; - - if(FnRet != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Teardown failed (%s returned %ld)", - TestName, FileName, LineNum, FnName, (long int)FnRet); - UT_Text(cMsg); - TestStat = CFE_FAIL; - return false; - } - return true; + UtAssertEx(UT_EventIsInHistory(EvtId), UtAssert_GetContext(), FileName, LineNum, "%s - sent event %s [%ld]", + TestName, EvtName, (long int)EvtId); } -void UT_ENDBLOCK_impl(const char *FileName, int LineNum, const char *TestName) +void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) { -#ifdef VERBOSE - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) End Block", TestName, FileName, LineNum); - UT_Text(); -#endif /* VERBOSE */ + UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TTF, FileName, LineNum, "%s - Teardown failed (%s returned %ld)", + TestName, FnName, (long int)FnRet); } + diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 25afc12df..1ad145001 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -687,106 +687,28 @@ void UT_CheckForOpenSockets(void); ******************************************************************************/ CFE_ES_ResetData_t *UT_GetResetDataPtr(void); -/*****************************************************************************/ -/** -** \brief Global representing the current state of a unit test function. -** -** \par Description -** This global variable is used by the test macros to track whether -** the current test is succeeding or has failed. Many of the macros -** fall through if this is not set to CFE_PASS (usually TestStat -** is set to CFE_PASS by the START() macro and is changed to -** CFE_FAIL by any test step [setup/assert/teardown] that fails). -** -** \par Assumptions, External Events, and Notes: -** None -** -** \sa #CFE_PASS, #CFE_FAIL, #START, #REPORT, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE -** \sa #EVTCNT, #EVTSENT, #TEARDOWN -** -******************************************************************************/ -extern int32 TestStat; - -/*****************************************************************************/ -/** -** \brief Test is currently passing. -** -** \sa #TestStat, #CFE_FAIL -** -******************************************************************************/ -#define CFE_PASS 1 - -/*****************************************************************************/ -/** -** \brief Test has failed. -** -** \sa #TestStat, #CFE_PASS -** -******************************************************************************/ -#define CFE_FAIL 0 - -/** \brief Function to be called by the STARTBLOCK() macro */ -void UT_STARTBLOCK_impl(const char *FileName, int LineNum, const char *TestName); - -/*****************************************************************************/ -/** -** \brief Start a block of tests. -** -** \par Description -** Macro to be called at the start of a test block (a test function -** comprised of calls to multiple individual test functions.) -** -** Does nothing, generates a text entry if VERBOSE is defined. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \sa #ENDBLOCK -** -******************************************************************************/ -#define STARTBLOCK() UT_STARTBLOCK_impl(__FILE__, __LINE__, __func__) - -/** \brief Function to be called by the START() macro */ -void UT_START_impl(const char *FileName, int LineNum, const char *TestName); /*****************************************************************************/ /** -** \brief Start an individual test. +** \brief Add a test as a member of a subgroup. ** ** \par Description -** Macro to be called at the start of an individual test. This sets the -** TestStat variable to be CFE_PASS, and generates a text message if -** VERBOSE is defined. -** -** \par Assumptions, External Events, and Notes: -** None -** -** \sa #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN -** -******************************************************************************/ -#define START() UT_START_impl(__FILE__, __LINE__, __func__) - -/** \brief Function to be called by the REPORT() macro */ -void UT_REPORT_impl(const char *FileName, int LineNum, const char *TestName); - -/*****************************************************************************/ -/** -** \brief Report the result of a test. +** Allow tests to be grouped together ** -** \par Description -** This reports whether the test passed or failed (as maintained by the -** TestStat global variable.) Call this at the end of every test. +** This is just a wrapper around UtTest_Add() that registers +** a test with a "GroupName.TestName" convention. Purely an +** organizational/identification helper for units which have +** lots of tests. ** ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #TEARDOWN -** ******************************************************************************/ -#define REPORT() UT_REPORT_impl(__FILE__, __LINE__, __func__) +void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(void), + const char *GroupName, const char *TestName); /** \brief Function to be called by the SETUP() macro */ -bool UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); +void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); /*****************************************************************************/ /** @@ -803,10 +725,10 @@ bool UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, cons ** \sa #START, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define SETUP(FN) (TestStat == CFE_PASS ? UT_SETUP_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) : false) +#define SETUP(FN) (UT_SETUP_impl(__FILE__, __LINE__, __func__, (#FN), (FN))) /** \brief Function to be called by the ASSERT() macro */ -bool UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); +void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); /*****************************************************************************/ /** @@ -823,10 +745,10 @@ bool UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, con ** \sa #START, #SETUP, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define ASSERT(FN) (TestStat == CFE_PASS ? UT_ASSERT_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) : false) +#define ASSERT(FN) (UT_ASSERT_impl(__FILE__, __LINE__, __func__, (#FN), (FN))) /** \brief Function to be called by the ASSERT_EQ() macro */ -bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, +void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *FnName, int32 FnRet, const char *ExpName, int32 Exp); /*****************************************************************************/ @@ -845,10 +767,11 @@ bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, ** \sa #START, #SETUP, #ASSERT, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define ASSERT_EQ(FN,EXP) (TestStat == CFE_PASS ? UT_ASSERT_EQ_impl(__FILE__, __LINE__, __func__, (#FN), (FN), (#EXP), (EXP)) : false) +#define ASSERT_EQ(FN,EXP) (UT_ASSERT_EQ_impl(__FILE__, __LINE__, (#FN), (FN), (#EXP), (EXP))) + /** \brief Function to be called by the ASSERT_EQ() macro */ -bool UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, +void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, const char *ExpName, bool Exp); /*****************************************************************************/ @@ -867,10 +790,10 @@ bool UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName ** \sa #START, #SETUP, #ASSERT, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define ASSERT_TRUE(EXP) (TestStat == CFE_PASS ? UT_ASSERT_TRUE_impl(__FILE__, __LINE__, __func__, (#EXP), (EXP)) : false) +#define ASSERT_TRUE(EXP) (UT_ASSERT_TRUE_impl(__FILE__, __LINE__, __func__, (#EXP), (EXP))) /** \brief Function to be called by the EVTCNT() macro */ -bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp); +void UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp); /*****************************************************************************/ /** @@ -887,10 +810,10 @@ bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int ** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define EVTCNT(EXP) (TestStat == CFE_PASS ? UT_EVTCNT_impl(__FILE__, __LINE__, __func__, (EXP)) : false) +#define EVTCNT(EXP) (UT_EVTCNT_impl(__FILE__, __LINE__, __func__, (EXP))) /** \brief Function to be called by the EVTSENT() macro */ -bool UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId); +void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId); /*****************************************************************************/ /** @@ -906,10 +829,10 @@ bool UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, co ** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define EVTSENT(EVT) (TestStat == CFE_PASS ? UT_EVTSENT_impl(__FILE__, __LINE__, __func__, (#EVT), (EVT)) : false) +#define EVTSENT(EVT) (UT_EVTSENT_impl(__FILE__, __LINE__, __func__, (#EVT), (EVT))) /** \brief Function to be called by the TEARDOWN() macro */ -bool UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); +void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); /*****************************************************************************/ /** ** \brief Checks the successful execution of a teardown function. @@ -925,23 +848,6 @@ bool UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, c ** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT ** ******************************************************************************/ -#define TEARDOWN(FN) (TestStat == CFE_PASS ? UT_TEARDOWN_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) : false) - -/*****************************************************************************/ -/** -** \brief Marks the end of a block of tests. -** -** \par Description -** Implementation function and associated ENDBLOCK() macro. Most CFE API functions will be tested with -** a block of tests, each of which will be performed in sequence. This function does -** -** \par Assumptions, External Events, and Notes: -** None -** -** \sa #STARTBLOCK -** -******************************************************************************/ -void UT_ENDBLOCK_impl(const char *FileName, int LineNum, const char *TestName); -#define ENDBLOCK() UT_ENDBLOCK_impl(__FILE__, __LINE__, __func__) +#define TEARDOWN(FN) (UT_TEARDOWN_impl(__FILE__, __LINE__, __func__, (#FN), (FN))) #endif /* __UT_STUBS_H_ */ From 4864d8b0824df4ae4df40cabc8f3e8035fed9ca5 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Tue, 16 Jun 2020 23:07:05 -0400 Subject: [PATCH 2/3] HOTFIX: Update docs to reflect changes in nasa/sample_app PR #73 --- docs/cFE Application Developers Guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cFE Application Developers Guide.md b/docs/cFE Application Developers Guide.md index 2f88a80c0..329cff100 100644 --- a/docs/cFE Application Developers Guide.md +++ b/docs/cFE Application Developers Guide.md @@ -451,7 +451,7 @@ Reference sample_app on Github for “live” example. | fsw/src/sample_app.h | Main header file for sample_app. It contains your main global typedef, prototypes, and miscellaneous define. | | fsw/src/sample_app_events.h | Defines sample_app event IDs | | fsw/src/sample_app_msg.h | Defines sample_app commands and its structures | -| fsw/tables/sample_table.c | Define sample_app table(s) | +| fsw/tables/sample_app_table.c | Define sample_app table(s) | | fsw/platform_inc/sample_app_msgids.h | Define sample_app message IDs | | fsw/mission_inc/sample_app_perfids.h | Define sample_app performance IDs | From eefbfd0224c2821c95652b84c27379f2ab8d9645 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Wed, 17 Jun 2020 15:04:00 -0400 Subject: [PATCH 3/3] Increase version to 6.7.20 and update Readme --- README.md | 5 +++++ fsw/cfe-core/src/inc/cfe_version.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f465bf2d0..c4dbcbca9 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,11 @@ This is a collection of services and associated framework to be located in the ` ## Version History +### Development Build: 6.7.20 + +- SB Unit use of the UT assert framework is closer to original design intent +- See + ### Development Build: 6.7.19 - API Change: cFE ut_sb_stubs now has CFE_SB_DeletePipe available. diff --git a/fsw/cfe-core/src/inc/cfe_version.h b/fsw/cfe-core/src/inc/cfe_version.h index 49be7920e..b967be642 100644 --- a/fsw/cfe-core/src/inc/cfe_version.h +++ b/fsw/cfe-core/src/inc/cfe_version.h @@ -95,7 +95,7 @@ */ #define CFE_MAJOR_VERSION 6 #define CFE_MINOR_VERSION 7 -#define CFE_REVISION 19 +#define CFE_REVISION 20 #endif /* _cfe_version_ */