From c18cd91c760a6cc8d10cf1e9a7d0ae30f93d98d3 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Fri, 24 Apr 2020 10:45:30 -0700 Subject: [PATCH 1/2] fix #491 - UT macros --- fsw/cfe-core/unit-test/sb_UT.c | 7430 +++++---------------------- fsw/cfe-core/unit-test/sb_UT.h | 6 - fsw/cfe-core/unit-test/ut_support.c | 142 + fsw/cfe-core/unit-test/ut_support.h | 257 + 4 files changed, 1770 insertions(+), 6065 deletions(-) diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 2c1f4cd7a..ccb346e5c 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -66,30 +66,24 @@ void UtTest_Setup(void) UT_ADD_TEST(Test_SB_Utils); UtTest_Add(Test_SB_SpecialCases, NULL, UT_CheckForOpenSockets, "Test_SB_SpecialCases"); - + UT_ADD_TEST(Test_SB_Macros); } /* end main */ - /* ** Function for calling SB and CCSDS Macros ** test functions */ void Test_SB_Macros(void) { -#ifdef UT_VERBOSE - UT_Text("Begin CCSDS Macros"); -#endif + STARTBLOCK(); Test_SB_CCSDSPriHdr_Macros(); Test_SB_CCSDSSecHdr_Macros(); - -#ifdef UT_VERBOSE - UT_Text("End Begin CCSDS Macros"); -#endif -} /* end Test_SB_Macros */ + ENDBLOCK(); +} /* end Test_SB_Macros */ /* **Test_SB_CCSDSSecHdr_Macros @@ -97,165 +91,93 @@ void Test_SB_Macros(void) void Test_SB_CCSDSSecHdr_Macros(void) { CFE_SB_CmdHdr_t NoParamPkt; - - uint32 ExpRtn; - uint32 ActRtn; - uint32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Test_SB_CCSDSSecHdr_Macros Test"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = 0x01; - + CCSDS_CLR_CMDSEC_HDR(NoParamPkt.Sec); - CCSDS_WR_FC(NoParamPkt.Sec, 1); - ActRtn = CCSDS_RD_FC(NoParamPkt.Sec); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read ccsds function code test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + ASSERT_TRUE(CCSDS_RD_FC(NoParamPkt.Sec) == 0x01); + + REPORT(); + + START(); + SB_ResetUnitTest(); - ExpRtn = 0xFF; - + CCSDS_CLR_CMDSEC_HDR(NoParamPkt.Sec); - CCSDS_WR_CHECKSUM(NoParamPkt.Sec, 0xFF); - ActRtn = CCSDS_RD_CHECKSUM(NoParamPkt.Sec); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read ccsds checksum test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + ASSERT_TRUE(CCSDS_RD_CHECKSUM(NoParamPkt.Sec) == 0xFF); + + REPORT(); + #ifdef MESSAGE_FORMAT_IS_CCSDS_VER_2 - + + START(); + SB_ResetUnitTest(); - ExpRtn = 0x01; - + CCSDS_CLR_SEC_APIDQ(NoParamPkt.SpacePacket.ApidQ); - CCSDS_WR_EDS_VER(NoParamPkt.SpacePacket.ApidQ, 0x01); - ActRtn = CCSDS_RD_EDS_VER(NoParamPkt.SpacePacket.ApidQ); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read eds version test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + + ASSERT_TRUE(CCSDS_RD_EDS_VER(NoParamPkt.SpacePacket.ApidQ) == 0x01); + + REPORT(); + + START(); + SB_ResetUnitTest(); - ExpRtn = 0x01; - + CCSDS_CLR_SEC_APIDQ(NoParamPkt.SpacePacket.ApidQ); - CCSDS_WR_ENDIAN(NoParamPkt.SpacePacket.ApidQ, 0x01); - ActRtn = CCSDS_RD_ENDIAN(NoParamPkt.SpacePacket.ApidQ); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read endian flag test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + + ASSERT_TRUE(CCSDS_RD_ENDIAN(NoParamPkt.SpacePacket.ApidQ) == 0x01); + + REPORT(); + + START(); + SB_ResetUnitTest(); - ExpRtn = 0x01; - + CCSDS_CLR_SEC_APIDQ(NoParamPkt.SpacePacket.ApidQ); - CCSDS_WR_PLAYBACK(NoParamPkt.SpacePacket.ApidQ, 0x01); - ActRtn = CCSDS_RD_PLAYBACK(NoParamPkt.SpacePacket.ApidQ); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read playback flag test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + + ASSERT_TRUE(CCSDS_RD_PLAYBACK(NoParamPkt.SpacePacket.ApidQ) == 0x01); + + REPORT(); + + START(); + SB_ResetUnitTest(); - ExpRtn = 0xFF; - + CCSDS_CLR_SEC_APIDQ(NoParamPkt.SpacePacket.ApidQ); - CCSDS_WR_SUBSYSTEM_ID(NoParamPkt.SpacePacket.ApidQ, 0xFF); - ActRtn = CCSDS_RD_SUBSYSTEM_ID(NoParamPkt.SpacePacket.ApidQ); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read subsystem id test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + + ASSERT_TRUE(CCSDS_RD_SUBSYSTEM_ID(NoParamPkt.SpacePacket.ApidQ) == 0xFF); + + REPORT(); + + START(); + SB_ResetUnitTest(); - ExpRtn = 0xFF; - + CCSDS_CLR_SEC_APIDQ(NoParamPkt.SpacePacket.ApidQ); - CCSDS_WR_SUBSYSTEM_ID(NoParamPkt.SpacePacket.ApidQ, 0xFF); - ActRtn = CCSDS_RD_SUBSYSTEM_ID(NoParamPkt.SpacePacket.ApidQ); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read subsystem id test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + + ASSERT_TRUE(CCSDS_RD_SUBSYSTEM_ID(NoParamPkt.SpacePacket.ApidQ) == 0xFF); + SB_ResetUnitTest(); - ExpRtn = 0xFFFF; - + CCSDS_CLR_SEC_APIDQ(NoParamPkt.SpacePacket.ApidQ); - CCSDS_WR_SYSTEM_ID(NoParamPkt.SpacePacket.ApidQ, 0xFFFF); - ActRtn = CCSDS_RD_SYSTEM_ID(NoParamPkt.SpacePacket.ApidQ); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read subsystem id test, " - "exp=0x%04X, act= 0x%04X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + + ASSERT_TRUE(CCSDS_RD_SYSTEM_ID(NoParamPkt.SpacePacket.ApidQ) == 0xFFFF); + + REPORT(); #endif - - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SB_CCSDSSecHdr_Macros", "CCSDS Secondary Header Macro Test"); } /* end Test_SB_CCSDSSecHdr_Macros */ /* @@ -264,172 +186,94 @@ void Test_SB_CCSDSSecHdr_Macros(void) void Test_SB_CCSDSPriHdr_Macros(void) { CFE_SB_Msg_t Msg; - - - uint32 ExpRtn; - uint32 ActRtn; - uint32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Test_SB_CCSDS_Macros Test"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = 0x1899; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_SID(Msg.Hdr, 0x1899); - ActRtn = CCSDS_RD_SID(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read stream id test, " - "exp=0x%04X, act= 0x%04X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_SID(Msg.Hdr) == 0x1899); - SB_ResetUnitTest(); - ExpRtn = 0x07FF; + REPORT(); + START(); + + SB_ResetUnitTest(); + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_APID(Msg.Hdr, 0x07FF); - ActRtn = CCSDS_RD_APID(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read apid test, " - "exp=0x%08X, act= 0x%08X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_APID(Msg.Hdr) == 0x07FF); + + REPORT(); + START(); + SB_ResetUnitTest(); - ExpRtn = 1; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_SHDR(Msg.Hdr, 1); + + ASSERT_TRUE(CCSDS_RD_SHDR(Msg.Hdr) == 1); + + REPORT(); - ActRtn = CCSDS_RD_SHDR(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read sec hdr flag test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - + START(); + SB_ResetUnitTest(); - ExpRtn = 1; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_TYPE(Msg.Hdr, 1); + + ASSERT_TRUE(CCSDS_RD_TYPE(Msg.Hdr) == 1); + + REPORT(); - ActRtn = CCSDS_RD_TYPE(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read pri hdr type flag test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + START(); + SB_ResetUnitTest(); - ExpRtn = 1; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_VERS(Msg.Hdr, 1); + + ASSERT_TRUE(CCSDS_RD_VERS(Msg.Hdr) == 1); + + REPORT(); - ActRtn = CCSDS_RD_VERS(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read pri hdr version flag test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + START(); + SB_ResetUnitTest(); - ExpRtn = 0x3FFF; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_SEQ(Msg.Hdr, 0x3FFF); + + ASSERT_TRUE(CCSDS_RD_SEQ(Msg.Hdr) == 0x3FFF); + + REPORT(); - ActRtn = CCSDS_RD_SEQ(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read pri hdr sequence test, " - "exp=0x%04X, act= 0x%04X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + START(); + SB_ResetUnitTest(); - ExpRtn = 0x03; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_SEQFLG(Msg.Hdr, 0x03); + + ASSERT_TRUE(CCSDS_RD_SEQFLG(Msg.Hdr) == 0x03); + + REPORT(); - ActRtn = CCSDS_RD_SEQFLG(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read pri hdr sequence flag test, " - "exp=0x%02X, act= 0x%02X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - + START(); + SB_ResetUnitTest(); - ExpRtn = 0xFFFF; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - CCSDS_WR_LEN(Msg.Hdr, 0xFFFF); - - ActRtn = CCSDS_RD_LEN(Msg.Hdr); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from write/read pri hdr length test, " - "exp=0x%04X, act= 0x%04X", - (unsigned int) ExpRtn, (unsigned int) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SB_CCSDS_Macros", "CCSDS Macro Test"); + + ASSERT_TRUE(CCSDS_RD_LEN(Msg.Hdr) == 0xFFFF); + + REPORT(); } /* end Test_SB_CCSDSPriHdr_Macros */ /* @@ -449,9 +293,7 @@ void SB_ResetUnitTest(void) */ void Test_SB_AppInit(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test App Init"); -#endif + STARTBLOCK(); Test_SB_AppInit_ESRegFail(); Test_SB_AppInit_EVSRegFail(); @@ -462,9 +304,7 @@ void Test_SB_AppInit(void) Test_SB_AppInit_GetPoolFail(); Test_SB_AppInit_PutPoolFail(); -#ifdef UT_VERBOSE - UT_Text("End Test App Init"); -#endif + ENDBLOCK(); } /* end Test_SB_AppInit */ /* @@ -472,44 +312,17 @@ void Test_SB_AppInit(void) */ void Test_SB_AppInit_ESRegFail(void) { - int32 ExpRtn; - int32 ActRtn; int32 ForcedRtnVal = -1; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of ES_RegisterApp Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_RegisterApp), 1, ForcedRtnVal); - ExpRtn = ForcedRtnVal; - ActRtn = CFE_SB_AppInit(); + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - if (ActRtn != ForcedRtnVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from AppInit in ES reg error test, " - "exp=%ld, act= %ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act= %ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "ES_RegisterApp failure"); + REPORT(); } /* end Test_SB_AppInit_ESRegFail */ /* @@ -517,43 +330,17 @@ void Test_SB_AppInit_ESRegFail(void) */ void Test_SB_AppInit_EVSRegFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; int32 ForcedRtnVal = -1; -#ifdef UT_VERBOSE - UT_Text("Start of EVS_Register Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_EVS_Register), 1, ForcedRtnVal); - ActRtn = CFE_SB_AppInit(); + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - if (ActRtn != ForcedRtnVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from AppInit in EVS Reg Error test, " - "exp=%ld, act= %ld", - (long) ForcedRtnVal, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act= %ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "EVS register failure"); + REPORT(); } /* end Test_SB_AppInit_EVSRegFail */ /* @@ -561,15 +348,10 @@ void Test_SB_AppInit_EVSRegFail(void) */ void Test_SB_AppInit_EVSSendEvtFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; int32 ForcedRtnVal = -1; CFE_ES_TaskInfo_t TestTaskInfo; -#ifdef UT_VERBOSE - UT_Text("Start of EVS_SendEvent Failure Test"); -#endif + START(); SB_ResetUnitTest(); @@ -585,33 +367,13 @@ void Test_SB_AppInit_EVSSendEvtFail(void) * (The others use SendEventWithAppID which is a different counter). */ UT_SetDeferredRetcode(UT_KEY(CFE_EVS_SendEvent), 1, ForcedRtnVal); - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ForcedRtnVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from AppInit in EVSSendEvtFail test, " - "exp=0x%lx, act= 0x%lx", - (unsigned long) ForcedRtnVal, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act= %ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); - CFE_SB_DeletePipe(CFE_SB.CmdPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "EVS SendEvent failure"); + REPORT(); } /* end Test_SB_AppInit_EVSSendEvtFail */ /* @@ -619,13 +381,7 @@ void Test_SB_AppInit_EVSSendEvtFail(void) */ void Test_SB_AppInit_CrPipeFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Start of SB_CreatePipe Failure Test"); -#endif + START(); SB_ResetUnitTest(); @@ -633,40 +389,13 @@ void Test_SB_AppInit_CrPipeFail(void) * type of error code. */ UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_ERROR); - ExpRtn = CFE_SB_PIPE_CR_ERR; - ActRtn = CFE_SB_AppInit(); + ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_PIPE_CR_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in CreatePipe Error2 " - "test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CR_PIPE_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_CR_PIPE_ERR_EID) == false) - { - UT_Text("CFE_SB_CR_PIPE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } - - CFE_SB_DeletePipe(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "Create pipe failure"); + REPORT(); } /* end Test_SB_AppInit_CrPipeFail */ /* @@ -675,50 +404,20 @@ void Test_SB_AppInit_CrPipeFail(void) void Test_SB_AppInit_Sub1Fail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Subscription 1 Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, -1); - ExpRtn = CFE_SB_BUF_ALOC_ERR; - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in Sub1 test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DEST_BLK_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_DEST_BLK_ERR_EID) == false) - { - UT_Text("CFE_SB_DEST_BLK_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "Subscription 1 failure"); + REPORT(); } /* end Test_SB_AppInit_Sub1Fail */ /* @@ -727,50 +426,20 @@ void Test_SB_AppInit_Sub1Fail(void) void Test_SB_AppInit_Sub2Fail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Subscription 2 Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 2, -1); - ExpRtn = CFE_SB_BUF_ALOC_ERR; - ActRtn = CFE_SB_AppInit(); + ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in Sub2 test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTSENT(CFE_SB_DEST_BLK_ERR_EID); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (UT_EventIsInHistory(CFE_SB_DEST_BLK_ERR_EID) == false) - { - UT_Text("CFE_SB_DEST_BLK_ERR_EID not sent"); - TestStat = CFE_FAIL; - } - - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "Subscription 2 failure"); + REPORT(); } /* end Test_SB_AppInit_Sub2Fail */ /* @@ -779,45 +448,20 @@ void Test_SB_AppInit_Sub2Fail(void) void Test_SB_AppInit_GetPoolFail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; int32 ForcedRtnVal = -1; -#ifdef UT_VERBOSE - UT_Text("Start of GetPool Failure Test"); -#endif + START(); - SB_ResetUnitTest(); + SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 3, ForcedRtnVal); - ExpRtn = ForcedRtnVal; - ActRtn = CFE_SB_AppInit(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in GetPool test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "GetPool failure"); + REPORT(); } /* end Test_SB_AppInit_GetPoolFail */ /* @@ -826,45 +470,20 @@ void Test_SB_AppInit_GetPoolFail(void) void Test_SB_AppInit_PutPoolFail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; int32 ForcedRtnVal = -1; -#ifdef UT_VERBOSE - UT_Text("Start of PutPool Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, ForcedRtnVal); - ExpRtn = ForcedRtnVal; - ActRtn = CFE_SB_AppInit(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in PutPool Test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "PutPool Failure"); + REPORT(); } /* end Test_SB_AppInit_PutPoolFail */ /* @@ -872,16 +491,12 @@ void Test_SB_AppInit_PutPoolFail(void) */ void Test_SB_MainRoutine(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test for MainRoutine"); -#endif + STARTBLOCK(); Test_SB_Main_RcvErr(); Test_SB_Main_InitErr(); -#ifdef UT_VERBOSE - UT_Text("End Test for MainRoutine"); -#endif + ENDBLOCK(); } /* end Test_SB_MainRoutine */ /* @@ -890,44 +505,22 @@ void Test_SB_MainRoutine(void) void Test_SB_Main_RcvErr(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Main Loop, Rcv Error Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, -1); CFE_SB_TaskMain(); - ExpRtn = 8; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(8); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_INIT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_Q_RD_ERR_EID) == false) - { - UT_Text("CFE_SB_Q_RD_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_Q_RD_ERR_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_TaskMain", "Rcv Error failure"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SB_Main_RcvErr */ /* @@ -936,32 +529,17 @@ void Test_SB_Main_RcvErr(void) void Test_SB_Main_InitErr(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Main Loop, Init Error Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_TaskMain(); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_TaskMain", "Init Error failure"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + REPORT(); } /* end Test_SB_Main_InitErr */ /* @@ -969,9 +547,7 @@ void Test_SB_Main_InitErr(void) */ void Test_SB_Cmds(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test for SB Commands"); -#endif + STARTBLOCK(); Test_SB_Cmds_Noop(); Test_SB_Cmds_RstCtrs(); @@ -1009,9 +585,7 @@ void Test_SB_Cmds(void) Test_SB_Cmds_BadCmdLength(); Test_SB_Cmds_UnexpMsgId(); -#ifdef UT_VERBOSE - UT_Text("End CFE_SB_ProcessCmdPipePkt"); -#endif + ENDBLOCK(); } /* end Test_SB_Cmds */ /* @@ -1020,40 +594,20 @@ void Test_SB_Cmds(void) void Test_SB_Cmds_Noop(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - No-op"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, 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; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_CMD0_RCVD_EID) == false) - { - UT_Text("CFE_SB_CMD0_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CMD0_RCVD_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "No-op command test"); + REPORT(); } /* end Test_SB_Cmds_Noop */ /* @@ -1062,40 +616,20 @@ void Test_SB_Cmds_Noop(void) void Test_SB_Cmds_RstCtrs(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat= CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Reset Counters"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, 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; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_CMD1_RCVD_EID) == false) - { - UT_Text("CFE_SB_CMD1_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CMD1_RCVD_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Reset Counters command test"); + REPORT(); } /* Test_SB_Cmds_RstCtrs */ /* @@ -1104,46 +638,22 @@ void Test_SB_Cmds_RstCtrs(void) void Test_SB_Cmds_Stats(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send SB Stats"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, 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; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_SND_STATS_EID) == false) - { - UT_Text("CFE_SB_SND_STATS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_STATS_EID); - if (UT_EventIsInHistory(CFE_SB_SND_STATS_EID) == false) - { - UT_Text("CFE_SB_SND_STATS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_STATS_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send SB Stats command test"); + REPORT(); } /* end Test_SB_Cmds_Stats */ /* @@ -1153,13 +663,8 @@ void Test_SB_Cmds_RoutingInfoDef(void) { CFE_SB_PipeId_t PipeId = 0; CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info, Using Default Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1169,61 +674,25 @@ void Test_SB_Cmds_RoutingInfoDef(void) strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename)); /* Make some routing info by calling CFE_SB_AppInit */ - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_AppInit, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_AppInit()); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 9; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(9); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_CMD1_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_INIT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Routing Info command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoDef */ /* @@ -1232,44 +701,24 @@ void Test_SB_Cmds_RoutingInfoDef(void) void Test_SB_Cmds_RoutingInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info2, Using Specified " - "Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, sizeof(WriteFileCmd), true); - CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, - CFE_SB_SEND_ROUTING_INFO_CC); + SETUP(CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, + CFE_SB_SEND_ROUTING_INFO_CC)); strncpy((char *)WriteFileCmd.Payload.Filename, "RoutingTstFile", sizeof(WriteFileCmd.Payload.Filename)); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Routing Info2 command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoSpec */ /* @@ -1278,13 +727,8 @@ void Test_SB_Cmds_RoutingInfoSpec(void) void Test_SB_Cmds_RoutingInfoCreateFail(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info3, File Create Fails"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1296,28 +740,14 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) /* Make function CFE_SB_SendRtgInfo return CFE_SB_FILE_IO_ERR */ UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR); + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_ERR1_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_ERR1_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_ERR1_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Routing Info3 command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoCreateFail */ /* @@ -1325,50 +755,18 @@ void Test_SB_Cmds_RoutingInfoCreateFail(void) */ void Test_SB_Cmds_RoutingInfoHdrFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info4, FileHdrWrite Fails"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendRtgInfo("RoutingTstFile"); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendRtgInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendRtgInfo", - "Send Routing Info4 command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoHdrFail */ /* @@ -1378,83 +776,31 @@ void Test_SB_Cmds_RoutingInfoHdrFail(void) void Test_SB_Cmds_RoutingInfoWriteFail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info5, Second FileWrite Fails"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = CFE_SUCCESS; /* Make some routing info by calling CFE_SB_AppInit */ - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_AppInit, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_AppInit()); UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendRtgInfo("RoutingTstFile"); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendRtgInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendRtgInfo("RoutingTstFile"), CFE_SB_FILE_IO_ERR); - ExpRtn = 9; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(9); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_INIT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendRtgInfo", - "Send Routing Info5 command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoWriteFail */ /* @@ -1467,13 +813,8 @@ void Test_SB_Cmds_PipeInfoDef(void) CFE_SB_PipeId_t PipeId2; CFE_SB_PipeId_t PipeId3; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info, Using Default Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1483,41 +824,23 @@ void Test_SB_Cmds_PipeInfoDef(void) strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename)); /* Create some pipe info */ - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_SND_RTG_EID); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - CFE_SB_DeletePipe(PipeId3); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Pipe Info command test"); + REPORT(); } /* end Test_SB_Cmds_PipeInfoDef */ /* @@ -1526,13 +849,8 @@ void Test_SB_Cmds_PipeInfoDef(void) void Test_SB_Cmds_PipeInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info2, Using Specified Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1542,27 +860,12 @@ void Test_SB_Cmds_PipeInfoSpec(void) strncpy((char *)WriteFileCmd.Payload.Filename, "PipeTstFile", sizeof(WriteFileCmd.Payload.Filename)); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Pipe Info2 command test"); + REPORT(); } /* end Test_SB_Cmds_PipeInfoSpec */ /* @@ -1570,50 +873,17 @@ void Test_SB_Cmds_PipeInfoSpec(void) */ void Test_SB_Cmds_PipeInfoCreateFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info3, File Create Fails"); -#endif + START(); SB_ResetUnitTest(); UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendPipeInfo("PipeTstFile"); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendPipeInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_SND_RTG_ERR1_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_ERR1_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_ERR1_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendPipeInfo", - "Send Pipe Info3 command test"); + REPORT(); } /* end Test_SB_Cmds_PipeInfoCreateFail */ /* @@ -1621,50 +891,17 @@ void Test_SB_Cmds_PipeInfoCreateFail(void) */ void Test_SB_Cmds_PipeInfoHdrFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info4, FileHdrWrite Fails"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendPipeInfo("PipeTstFile"); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendPipeInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendPipeInfo", - "Send Pipe Info4 command test"); + REPORT(); } /* end Test_SB_Cmds_PipeInfoHdrFail */ /* @@ -1677,62 +914,29 @@ void Test_SB_Cmds_PipeInfoWriteFail(void) CFE_SB_PipeId_t PipeId2; CFE_SB_PipeId_t PipeId3; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info5, Second FileWrite fails"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"); + + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendPipeInfo("PipeTstFile"); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendPipeInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(4); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - CFE_SB_DeletePipe(PipeId3); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendPipeInfo", - "Send Pipe Info5 command test"); + REPORT(); } /* end Test_SB_Cmds_PipeInfoWriteFail */ /* @@ -1751,13 +955,8 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID + 5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID + 6; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info, Using Default Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1767,54 +966,33 @@ void Test_SB_Cmds_MapInfoDef(void) strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename)); /* Create some map info */ - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"); - CFE_SB_Subscribe(MsgId0, PipeId1); - CFE_SB_Subscribe(MsgId0, PipeId2); - CFE_SB_Subscribe(MsgId1, PipeId1); - CFE_SB_Subscribe(MsgId2, PipeId3); - CFE_SB_Subscribe(MsgId3, PipeId3); - CFE_SB_Subscribe(MsgId4, PipeId3); - CFE_SB_Subscribe(MsgId5, PipeId2); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId2)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId3)); + SETUP(CFE_SB_Subscribe(MsgId3, PipeId3)); + SETUP(CFE_SB_Subscribe(MsgId4, PipeId3)); + SETUP(CFE_SB_Subscribe(MsgId5, PipeId2)); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; - CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 18; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(18); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - CFE_SB_DeletePipe(PipeId3); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Map Info command test"); + EVTSENT(CFE_SB_PIPE_ADDED_EID); + + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); + + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + TEARDOWN(CFE_SB_DeletePipe(PipeId3)); + + REPORT(); } /* end Test_SB_Cmds_MapInfoDef */ /* @@ -1823,13 +1001,8 @@ void Test_SB_Cmds_MapInfoDef(void) void Test_SB_Cmds_MapInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info2, Using Specified Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1839,27 +1012,12 @@ void Test_SB_Cmds_MapInfoSpec(void) strncpy((char *)WriteFileCmd.Payload.Filename, "MapTstFile", sizeof(WriteFileCmd.Payload.Filename)); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Map Info2 command test"); + REPORT(); } /* end Test_SB_Cmds_MapInfoSpec */ /* @@ -1867,50 +1025,17 @@ void Test_SB_Cmds_MapInfoSpec(void) */ void Test_SB_Cmds_MapInfoCreateFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info3, File Create Fails"); -#endif + START(); SB_ResetUnitTest(); UT_SetForceFail(UT_KEY(OS_creat), OS_ERROR); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendMapInfo("MapTstFile"); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendMapInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_ERR1_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_ERR1_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_ERR1_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendMapInfo", - "Send Map Info3 command test"); + REPORT(); } /* end Test_SB_Cmds_MapInfoCreateFail */ /* @@ -1918,50 +1043,17 @@ void Test_SB_Cmds_MapInfoCreateFail(void) */ void Test_SB_Cmds_MapInfoHdrFail(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info4, FileHdrWrite Fails"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_FS_WriteHeader), 1, -1); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendMapInfo("MapTstFile"); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendMapInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendMapInfo", - "Send Map Info4 command test"); + REPORT(); } /* end Test_SB_Cmds_MapInfoHdrFail */ /* @@ -1980,77 +1072,39 @@ void Test_SB_Cmds_MapInfoWriteFail(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID + 5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID + 6; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info5, Second FileWrite Fails"); -#endif + START(); SB_ResetUnitTest(); /* Create some map info */ - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3"); - CFE_SB_Subscribe(MsgId0, PipeId1); - CFE_SB_Subscribe(MsgId0, PipeId2); - CFE_SB_Subscribe(MsgId1, PipeId1); - CFE_SB_Subscribe(MsgId2, PipeId3); - CFE_SB_Subscribe(MsgId3, PipeId3); - CFE_SB_Subscribe(MsgId4, PipeId3); - CFE_SB_Subscribe(MsgId5, PipeId2); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_CreatePipe(&PipeId3, PipeDepth, "TestPipe3")); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId2)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId3)); + SETUP(CFE_SB_Subscribe(MsgId3, PipeId3)); + SETUP(CFE_SB_Subscribe(MsgId4, PipeId3)); + SETUP(CFE_SB_Subscribe(MsgId5, PipeId2)); UT_SetDeferredRetcode(UT_KEY(OS_write), 2, -1); - ExpRtn = CFE_SB_FILE_IO_ERR; - ActRtn = CFE_SB_SendMapInfo("MapTstFile"); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SendMapInfo, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendMapInfo("MapTstFile"), CFE_SB_FILE_IO_ERR); - ExpRtn = 18; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(18); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + TEARDOWN(CFE_SB_DeletePipe(PipeId3)); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - CFE_SB_DeletePipe(PipeId3); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendMapInfo", - "Send Map Info5 command test"); + REPORT(); } /* end Test_SB_Cmds_MapInfoWriteFail */ /* @@ -2062,17 +1116,12 @@ void Test_SB_Cmds_EnRouteValParam(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Valid Param"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "EnRouteTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "EnRouteTestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2080,41 +1129,20 @@ void Test_SB_Cmds_EnRouteValParam(void) EnDisRouteCmd.Payload.MsgId = MsgId; EnDisRouteCmd.Payload.Pipe = PipeId; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE2_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE2_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_ENBL_RTE2_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, valid parameter test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SB_Cmds_EnRouteValParam */ /* @@ -2127,18 +1155,13 @@ void Test_SB_Cmds_EnRouteNonExist(void) CFE_SB_PipeId_t PipeId2; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Non Exist"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "EnRouteTestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "EnRouteTestPipe2"); - CFE_SB_Subscribe(MsgId, PipeId1); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "EnRouteTestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "EnRouteTestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId1)); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2146,42 +1169,19 @@ void Test_SB_Cmds_EnRouteNonExist(void) EnDisRouteCmd.Payload.MsgId = MsgId; EnDisRouteCmd.Payload.Pipe = PipeId2; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; - CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(5); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); + EVTSENT(CFE_SB_ENBL_RTE1_EID); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE1_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE1_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, non-existent route test"); + REPORT(); } /* end Test_SB_Cmds_EnRouteNonExist */ /* @@ -2190,13 +1190,8 @@ void Test_SB_Cmds_EnRouteNonExist(void) void Test_SB_Cmds_EnRouteInvParam(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2206,28 +1201,14 @@ void Test_SB_Cmds_EnRouteInvParam(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; EnDisRouteCmd.Payload.Pipe = 3; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_ENBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, invalid pipe ID test"); + REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam */ /* @@ -2236,13 +1217,8 @@ void Test_SB_Cmds_EnRouteInvParam(void) void Test_SB_Cmds_EnRouteInvParam2(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Invalid Msg ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2252,28 +1228,14 @@ void Test_SB_Cmds_EnRouteInvParam2(void) EnDisRouteCmd.Payload.MsgId = CFE_SB_INVALID_MSG_ID; EnDisRouteCmd.Payload.Pipe = 3; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_ENBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, invalid msg ID test"); + REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam2 */ /* @@ -2283,13 +1245,8 @@ void Test_SB_Cmds_EnRouteInvParam2(void) void Test_SB_Cmds_EnRouteInvParam3(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Msg ID Too Large"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2299,28 +1256,14 @@ void Test_SB_Cmds_EnRouteInvParam3(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; EnDisRouteCmd.Payload.Pipe = 0; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_ENBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, msg ID too large test"); + REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam3 */ /* @@ -2332,17 +1275,12 @@ void Test_SB_Cmds_DisRouteValParam(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Valid Param"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "DisRouteTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "DisRouteTestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2351,40 +1289,18 @@ void Test_SB_Cmds_DisRouteValParam(void) EnDisRouteCmd.Payload.Pipe = PipeId; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE2_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE2_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE2_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, valid parameter test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SB_Cmds_DisRouteValParam */ /* @@ -2396,18 +1312,13 @@ void Test_SB_Cmds_DisRouteNonExist(void) CFE_SB_PipeId_t PipeId1, PipeId2; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Non Exist"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "DisRouteTestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "DisRouteTestPipe2"); - CFE_SB_Subscribe(MsgId, PipeId1); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "DisRouteTestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "DisRouteTestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId1)); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2415,42 +1326,19 @@ void Test_SB_Cmds_DisRouteNonExist(void) EnDisRouteCmd.Payload.MsgId = MsgId; EnDisRouteCmd.Payload.Pipe = PipeId2; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; - CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(5); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); + EVTSENT(CFE_SB_DSBL_RTE1_EID); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE1_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE1_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, non-existent route test"); + REPORT(); } /* end Test_SB_Cmds_DisRouteNonExist */ /* @@ -2459,13 +1347,8 @@ void Test_SB_Cmds_DisRouteNonExist(void) void Test_SB_Cmds_DisRouteInvParam(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2475,28 +1358,14 @@ void Test_SB_Cmds_DisRouteInvParam(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; EnDisRouteCmd.Payload.Pipe = 3; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, invalid pipe ID test"); + REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam */ /* @@ -2505,13 +1374,8 @@ void Test_SB_Cmds_DisRouteInvParam(void) void Test_SB_Cmds_DisRouteInvParam2(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Invalid Param2"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2521,28 +1385,14 @@ void Test_SB_Cmds_DisRouteInvParam2(void) EnDisRouteCmd.Payload.MsgId = CFE_SB_INVALID_MSG_ID; EnDisRouteCmd.Payload.Pipe = 3; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, invalid msg ID test"); + REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam2 */ /* @@ -2552,13 +1402,8 @@ void Test_SB_Cmds_DisRouteInvParam2(void) void Test_SB_Cmds_DisRouteInvParam3(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Msg ID Too Large"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2568,28 +1413,14 @@ void Test_SB_Cmds_DisRouteInvParam3(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; EnDisRouteCmd.Payload.Pipe = 0; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, msg ID too large test"); + REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam3 */ /* @@ -2598,13 +1429,8 @@ void Test_SB_Cmds_DisRouteInvParam3(void) void Test_SB_Cmds_SendHK(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Housekeeping Info"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_SEND_HK_MID, @@ -2612,27 +1438,12 @@ void Test_SB_Cmds_SendHK(void) CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_SEND_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_NO_SUBS_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Housekeeping Info command test"); + REPORT(); } /* end Test_SB_Cmds_SendHK */ /* @@ -2649,20 +1460,15 @@ void Test_SB_Cmds_SendPrevSubs(void) uint16 PipeDepth = 50; int32 i; int32 NumEvts; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Previous Subscriptions"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_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; - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); NumEvts = 2; /* one for each pipe create */ /* Two full pkts to be sent plus five entries in a partial pkt, skipping MSGID 0x0D */ @@ -2679,102 +1485,43 @@ void Test_SB_Cmds_SendPrevSubs(void) if (i != CFE_SB_ALLSUBS_TLM_MID) { NumEvts += 2; - ActRtn = CFE_SB_Subscribe(i, PipeId1); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return subscribing in SendPrevSubs Test, " - "i=%d, exp=0x%lx, act=0x%lx", - (int) i, (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - } - } - - CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim); - CFE_SB_ProcessCmdPipePkt(); - NumEvts += 8; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */ - ExpRtn = NumEvts; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - /* Round out the number to three full pkts in order to test branch path - * coverage, MSGID 0x0D was skipped in previous subscription loop - */ - for (; i < CFE_SB_SUB_ENTRIES_PER_PKT * 3; i++) - { - ActRtn = CFE_SB_Subscribe(i, PipeId1); - ExpRtn = CFE_SUCCESS; - NumEvts += 2; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return subscribing in SendPrevSubs Test, " - "i=%ld, exp=0x%lx, act=0x%lx", - (unsigned long) i, (unsigned long) ExpRtn, - (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; + SETUP(CFE_SB_Subscribe(i, PipeId1)); } } - CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim); + SETUP(CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim)); + CFE_SB_ProcessCmdPipePkt(); + NumEvts += 8; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */ - ExpRtn = NumEvts; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(NumEvts); - if (ActRtn != ExpRtn) + /* Round out the number to three full pkts in order to test branch path + * coverage, MSGID 0x0D was skipped in previous subscription loop + */ + for (; i < CFE_SB_SUB_ENTRIES_PER_PKT * 3; i++) { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; + SETUP(CFE_SB_Subscribe(i, PipeId1)); + NumEvts += 2; } + SETUP(CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim)); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_SEND_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + NumEvts += 8; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */ - if (UT_EventIsInHistory(CFE_SB_FULL_SUB_PKT_EID) == false) - { - UT_Text("CFE_SB_FULL_SUB_PKT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(NumEvts); - if (UT_EventIsInHistory(CFE_SB_PART_SUB_PKT_EID) == false) - { - UT_Text("CFE_SB_PART_SUB_PKT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); + EVTSENT(CFE_SB_SEND_NO_SUBS_EID); + EVTSENT(CFE_SB_FULL_SUB_PKT_EID); + EVTSENT(CFE_SB_PART_SUB_PKT_EID); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send previous subscriptions test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + + REPORT(); } /* end Test_SB_Cmds_SendPrevSubs */ /* @@ -2783,13 +1530,8 @@ void Test_SB_Cmds_SendPrevSubs(void) void Test_SB_Cmds_SubRptOn(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Subscription Reporting On"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, @@ -2798,21 +1540,10 @@ void Test_SB_Cmds_SubRptOn(void) CFE_SB_ENABLE_SUB_REPORTING_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Subscription Reporting On test"); + REPORT(); } /* end Test_SB_Cmds_SubRptOn */ /* @@ -2821,13 +1552,8 @@ void Test_SB_Cmds_SubRptOn(void) void Test_SB_Cmds_SubRptOff(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Subscription Reporting Off"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, @@ -2836,21 +1562,10 @@ void Test_SB_Cmds_SubRptOff(void) CFE_SB_DISABLE_SUB_REPORTING_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Subscription Reporting Off test"); + REPORT(); } /* end Test_SB_Cmds_SubRptOff */ /* @@ -2859,13 +1574,8 @@ void Test_SB_Cmds_SubRptOff(void) void Test_SB_Cmds_UnexpCmdCode(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Unexpected Command Code"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, sizeof(NoParamCmd), true); @@ -2874,27 +1584,12 @@ void Test_SB_Cmds_UnexpCmdCode(void) CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, 99); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_BAD_CMD_CODE_EID) == false) - { - UT_Text("CFE_SB_BAD_CMD_CODE_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_BAD_CMD_CODE_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Unexpected command code test"); + REPORT(); } /* end Test_SB_Cmds_UnexpCmdCode */ /* @@ -2906,9 +1601,6 @@ void Test_SB_Cmds_BadCmdLength(void) * Just choosing "EnableRoute" command here as it has a non-empty payload */ CFE_SB_EnableRoute_t EnableRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; SB_ResetUnitTest(); CFE_SB_InitMsg(&EnableRouteCmd, CFE_SB_CMD_MID, sizeof(EnableRouteCmd) - 1, true); @@ -2917,27 +1609,12 @@ void Test_SB_Cmds_BadCmdLength(void) CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnableRouteCmd, CFE_SB_ENABLE_ROUTE_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnableRouteCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_LEN_ERR_EID) == false) - { - UT_Text("CFE_SB_LEN_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_LEN_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Bad command length test"); + REPORT(); } /* end Test_SB_Cmds_BadCmdLength */ /* @@ -2947,39 +1624,19 @@ void Test_SB_Cmds_UnexpMsgId(void) { CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Unexpected MsgId on SB Command Pipe"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, MsgId, sizeof(NoParamCmd), true); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_BAD_MSGID_EID) == false) - { - UT_Text("CFE_SB_BAD_MSGID_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_BAD_MSGID_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Unexpected MsgId on SB command pipe test"); + REPORT(); } /* end Test_SB_Cmds_UnexpMsgId */ /* @@ -2987,17 +1644,13 @@ void Test_SB_Cmds_UnexpMsgId(void) */ void Test_SB_EarlyInit(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test EarlyInit"); -#endif + STARTBLOCK(); Test_SB_EarlyInit_SemCreateError(); Test_SB_EarlyInit_PoolCreateError(); Test_SB_EarlyInit_NoErrors(); -#ifdef UT_VERBOSE - UT_Text("End Test EarlyInit\n"); -#endif + ENDBLOCK(); } /* end Test_SB_EarlyInit */ /* @@ -3005,9 +1658,7 @@ void Test_SB_EarlyInit(void) */ void Test_SB_EarlyInit_SemCreateError(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Sem Create Error Logic test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemCreate), 1, OS_ERR_NO_FREE_IDS); @@ -3021,9 +1672,7 @@ void Test_SB_EarlyInit_SemCreateError(void) */ void Test_SB_EarlyInit_PoolCreateError(void) { -#ifdef UT_VERBOSE - UT_Text("Begin PoolCreateEx Error Logic test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PoolCreateEx), 1, CFE_ES_BAD_ARGUMENT); @@ -3037,9 +1686,7 @@ void Test_SB_EarlyInit_PoolCreateError(void) */ void Test_SB_EarlyInit_NoErrors(void) { -#ifdef UT_VERBOSE - UT_Text("Begin EarlyInit No Errors test"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_EarlyInit(); @@ -3053,9 +1700,7 @@ void Test_SB_EarlyInit_NoErrors(void) */ void Test_CreatePipe_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_CreatePipe_API"); -#endif + STARTBLOCK(); Test_CreatePipe_NullPtr(); Test_CreatePipe_ValPipeDepth(); @@ -3063,9 +1708,7 @@ void Test_CreatePipe_API(void) Test_CreatePipe_MaxPipes(); Test_CreatePipe_SamePipeName(); -#ifdef UT_VERBOSE - UT_Text("End Test_CreatePipe_API\n"); -#endif + ENDBLOCK(); } /* end Test_CreatePipe_API */ /* @@ -3074,52 +1717,22 @@ void Test_CreatePipe_API(void) void Test_CreatePipe_NullPtr(void) { uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Null Pointer"); -#endif + 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); - ExpRtn = CFE_SB_BAD_ARGUMENT; UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); /* Avoids creating socket */ - ActRtn = CFE_SB_CreatePipe(NULL, PipeDepth, "TestPipe"); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in null pointer test, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_CreatePipe(NULL, PipeDepth, "TestPipe"), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_CR_PIPE_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_CR_PIPE_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CR_PIPE_BAD_ARG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CreatePipe_API", "Null pointer test"); + REPORT(); } /* end Test_CreatePipe_NullPtr */ /* @@ -3128,64 +1741,25 @@ void Test_CreatePipe_NullPtr(void) void Test_CreatePipe_ValPipeDepth(void) { CFE_SB_PipeId_t PipeIdReturned[3]; - int32 Rtn[3]; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Valid Pipe Depth"); -#endif + START(); /* Test a few valid pipe depth values */ SB_ResetUnitTest(); - Rtn[0] = CFE_SB_CreatePipe(&PipeIdReturned[0], 99, "TestPipe99"); - Rtn[1] = CFE_SB_CreatePipe(&PipeIdReturned[1], 255, "TestPipe255"); - Rtn[2] = CFE_SB_CreatePipe(&PipeIdReturned[2], - CFE_PLATFORM_SB_MAX_PIPE_DEPTH, "TestPipeMaxDepth"); - - if (Rtn[0] != CFE_SUCCESS || - Rtn[1] != CFE_SUCCESS || - Rtn[2] != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in valid pipe depth test\n " - "Val=99, Rtn1=0x%lx, act=0x%lx\n " - "Val=255, Rtn2=0x%lx, act=0x%lx\n " - "Val=%d, Rtn3=0x%lx, Expected Rtn3=0x%lx", - (unsigned long) Rtn[0], (unsigned long) CFE_SUCCESS, - (unsigned long) Rtn[1], (unsigned long) CFE_SUCCESS, - CFE_PLATFORM_SB_MAX_PIPE_DEPTH, - (unsigned long) Rtn[2], (unsigned long) CFE_SUCCESS); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[0], 99, "TestPipe99")); + ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[1], 255, "TestPipe255")); + ASSERT(CFE_SB_CreatePipe(&PipeIdReturned[2], + CFE_PLATFORM_SB_MAX_PIPE_DEPTH, "TestPipeMaxDepth")); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CreatePipe_API", - "Valid pipe depth test"); + TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[0])); + TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[1])); + TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[2])); - CFE_SB_DeletePipe(PipeIdReturned[0]); - CFE_SB_DeletePipe(PipeIdReturned[1]); - CFE_SB_DeletePipe(PipeIdReturned[2]); + REPORT(); } /* end Test_CreatePipe_ValPipeDepth */ /* @@ -3194,63 +1768,24 @@ void Test_CreatePipe_ValPipeDepth(void) void Test_CreatePipe_InvalPipeDepth(void) { CFE_SB_PipeId_t PipeIdReturned[3]; - int32 Rtn[3]; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe Depth"); -#endif + START(); /* Test a few invalid pipe depth values */ SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); /* Avoid creating socket */ - Rtn[0] = CFE_SB_CreatePipe(&PipeIdReturned[0], 0, "TestPipe1"); + ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[0], 0, "TestPipe1"), CFE_SB_BAD_ARGUMENT); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); - Rtn[1] = CFE_SB_CreatePipe(&PipeIdReturned[1], - CFE_PLATFORM_SB_MAX_PIPE_DEPTH + 1, "TestPipeMaxDepPlus1"); + ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[1], + CFE_PLATFORM_SB_MAX_PIPE_DEPTH + 1, "TestPipeMaxDepPlus1"), CFE_SB_BAD_ARGUMENT); UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 1, OS_SUCCESS); - Rtn[2] = CFE_SB_CreatePipe(&PipeIdReturned[2], 0xffff, "TestPipeffff"); - - if (Rtn[0] != CFE_SB_BAD_ARGUMENT || - Rtn[1] != CFE_SB_BAD_ARGUMENT || - Rtn[2] != CFE_SB_BAD_ARGUMENT) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe depth test for invalid settings\n " - "Val=0, Rtn1=0x%lx, act=0x%lx\n " - "Val=%d, Rtn2=0x%lx, act=0x%lx\n " - "Val=65535, Rtn3=0x%lx, Expected Rtn3=0x%lx", - (unsigned long) Rtn[0], (unsigned long) CFE_SB_BAD_ARGUMENT, - CFE_PLATFORM_SB_MAX_PIPE_DEPTH + 1, - (unsigned long) Rtn[1], (unsigned long) CFE_SB_BAD_ARGUMENT, - (unsigned long) Rtn[2], (unsigned long) CFE_SB_BAD_ARGUMENT); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[2], 0xffff, "TestPipeffff"), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_CR_PIPE_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_CR_PIPE_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CR_PIPE_BAD_ARG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CreatePipe_API", - "Invalid pipe depth test"); + REPORT(); } /* end Test_CreatePipe_InvalPipeDepth */ /* @@ -3260,62 +1795,39 @@ void Test_CreatePipe_MaxPipes(void) { CFE_SB_PipeId_t PipeIdReturned[CFE_PLATFORM_SB_MAX_PIPES + 1]; uint16 PipeDepth = 50; - int32 Rtn[CFE_PLATFORM_SB_MAX_PIPES + 1]; int32 i; - int32 ExpRtn; - int32 TestStat = CFE_PASS; char PipeName[OS_MAX_API_NAME]; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Max Pipes"); -#endif + START(); SB_ResetUnitTest(); /* Create maximum number of pipes + 1. Only one 'create pipe' failure * expected */ - for (i = 0; i < CFE_PLATFORM_SB_MAX_PIPES + 1; i++) + for (i = 0; TestStat == CFE_PASS && i < CFE_PLATFORM_SB_MAX_PIPES + 1; i++) { snprintf(PipeName, OS_MAX_API_NAME, "TestPipe%ld", (long) i); - Rtn[i] = CFE_SB_CreatePipe(&PipeIdReturned[i], - PipeDepth, &PipeName[0]); if (i < CFE_PLATFORM_SB_MAX_PIPES) { - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_CreatePipe(&PipeIdReturned[i], PipeDepth, &PipeName[0])); } else { - ExpRtn = CFE_SB_MAX_PIPES_MET; - } - - if (Rtn[i] != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in max pipes test, " - "i=%ld, exp=0x%lx, act=0x%lx", - (long) i, (unsigned long) ExpRtn, (unsigned long) Rtn[i]); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; + ASSERT_EQ(CFE_SB_CreatePipe(&PipeIdReturned[i], PipeDepth, &PipeName[0]), CFE_SB_MAX_PIPES_MET); } } - if (UT_EventIsInHistory(CFE_SB_MAX_PIPES_MET_EID) == false) - { - UT_Text("CFE_SB_MAX_PIPES_MET_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MAX_PIPES_MET_EID); /* Clean up */ - for (i = 0; i <= CFE_PLATFORM_SB_MAX_PIPES - 1; i++) + for (i = 0; i < CFE_PLATFORM_SB_MAX_PIPES; i++) { - CFE_SB_DeletePipe(i); + TEARDOWN(CFE_SB_DeletePipe(PipeIdReturned[i])); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CreatePipe_API", "Max pipes test"); + REPORT(); } /* end Test_CreatePipe_MaxPipes */ /* @@ -3327,12 +1839,8 @@ void Test_CreatePipe_SamePipeName(void) CFE_SB_PipeId_t PipeId = -1; uint16 PipeDepth = 1; char PipeName[] = "Test_CFE_SB"; - int32 status; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test Create Pipe with Duplicate Pipe Name"); -#endif + START(); SB_ResetUnitTest(); @@ -3341,55 +1849,31 @@ void Test_CreatePipe_SamePipeName(void) UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 2, OS_ERR_NAME_TAKEN); /* First call to CFE_SB_CreatePipe() should succeed */ - status = CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName)); - if (status == CFE_SUCCESS) - { - FirstPipeId = PipeId; - } - else - { - UT_Text("First call to CFE_SB_CreatePipe() failed"); - TestStat = CFE_FAIL; - } + FirstPipeId = PipeId; /* Second call to CFE_SB_CreatePipe with same PipeName should fail */ - status = CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName); + ASSERT_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SB_PIPE_CR_ERR); - if (status == CFE_SUCCESS) - { - UT_Text("Second call to CFE_SB_CreatePipe() passed unexpectedly"); - TestStat = CFE_FAIL; - } + ASSERT_EQ(PipeId, FirstPipeId); - if (PipeId != FirstPipeId) - { - UT_Text("Second call to CFE_SB_CreatePipe() modified the PipeId"); - TestStat = CFE_FAIL; - } + EVTCNT(2); - /* Call to CFE_SB_DeletePipe with the first pipe id created should work fine */ - status = CFE_SB_DeletePipe(PipeId); + EVTSENT(CFE_SB_CR_PIPE_NAME_TAKEN_EID); - if (status != CFE_SUCCESS) - { - UT_Text("Failed to delete pipe"); - TestStat = CFE_FAIL; - } + /* Call to CFE_SB_DeletePipe with the first pipe id created should work fine */ + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CreatePipe_API", "Same pipe name test"); + REPORT(); } - /* ** Function for calling SB delete pipe API test functions */ void Test_DeletePipe_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_DeletePipe_API"); -#endif + STARTBLOCK(); Test_DeletePipe_NoSubs(); Test_DeletePipe_WithSubs(); @@ -3397,9 +1881,7 @@ void Test_DeletePipe_API(void) Test_DeletePipe_InvalidPipeOwner(); Test_DeletePipe_WithAppid(); -#ifdef UT_VERBOSE - UT_Text("End Test_DeletePipe_API\n"); -#endif + ENDBLOCK(); } /* end Test_DeletePipe_API */ /* @@ -3409,55 +1891,19 @@ void Test_DeletePipe_NoSubs(void) { CFE_SB_PipeId_t PipedId; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for No Subscriptions"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe"); - ActRtn = CFE_SB_DeletePipe(PipedId); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in delete pipe test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); + ASSERT(CFE_SB_DeletePipe(PipedId)); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_PIPE_DELETED_EID) == false) - { - UT_Text("CFE_SB_PIPE_DELETED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_PIPE_DELETED_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", - "No subscriptions test"); + REPORT(); } /* end Test_DeletePipe_NoSubs */ /* @@ -3471,59 +1917,23 @@ void Test_DeletePipe_WithSubs(void) CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID + 3; CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID + 4; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test With Subscriptions"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId0, PipedId); - CFE_SB_Subscribe(MsgId1, PipedId); - CFE_SB_Subscribe(MsgId2, PipedId); - CFE_SB_Subscribe(MsgId3, PipedId); - ActRtn = CFE_SB_DeletePipe(PipedId); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in delete pipe test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 14; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId0, PipedId)); + SETUP(CFE_SB_Subscribe(MsgId1, PipedId)); + SETUP(CFE_SB_Subscribe(MsgId2, PipedId)); + SETUP(CFE_SB_Subscribe(MsgId3, PipedId)); + ASSERT(CFE_SB_DeletePipe(PipedId)); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(14); - if (UT_EventIsInHistory(CFE_SB_PIPE_DELETED_EID) == false) - { - UT_Text("CFE_SB_PIPE_DELETED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_PIPE_DELETED_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", - "With subscriptions test"); + REPORT(); } /* end Test_DeletePipe_WithSubs */ /* @@ -3532,48 +1942,18 @@ void Test_DeletePipe_WithSubs(void) void Test_DeletePipe_InvalidPipeId(void) { CFE_SB_PipeId_t PipeId = 30; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_DeletePipe(PipeId); - ExpRtn = CFE_SB_BAD_ARGUMENT; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in delete pipe test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_DeletePipe(PipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_DEL_PIPE_ERR1_EID) == false) - { - UT_Text("CFE_SB_DEL_PIPE_ERR1_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DEL_PIPE_ERR1_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", - "Invalid pipe ID test"); + REPORT(); } /* end Test_DeletePipe_InvalidPipeId */ /* @@ -3584,71 +1964,28 @@ void Test_DeletePipe_InvalidPipeOwner(void) CFE_SB_PipeId_t PipedId; uint32 RealOwner; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe Owner"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CreatePipe in DeletePipe, " - "invalid owner test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); /* Change owner of pipe through memory corruption */ RealOwner = CFE_SB.PipeTbl[PipedId].AppId; /* Choose a value that is sure not to be owner */ CFE_SB.PipeTbl[PipedId].AppId = RealOwner + 1; - ActRtn = CFE_SB_DeletePipe(PipedId); - ExpRtn = CFE_SB_BAD_ARGUMENT; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from DeletePipe in DeletePipe, " - "invalid owner test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_DeletePipe(PipedId), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from UT_GetNumEventsSent, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_DEL_PIPE_ERR2_EID) == false) - { - UT_Text("CFE_SB_DEL_PIPE_ERR2_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DEL_PIPE_ERR2_EID); /* Restore owner id and delete pipe since test is complete */ CFE_SB.PipeTbl[PipedId].AppId = RealOwner; - CFE_SB_DeletePipe(PipedId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", - "Invalid pipe owner test"); + TEARDOWN(CFE_SB_DeletePipe(PipedId)); + + REPORT(); } /* end Test_DeletePipe_InvalidPipeId */ /* @@ -3657,53 +1994,23 @@ void Test_DeletePipe_InvalidPipeOwner(void) void Test_DeletePipe_WithAppid(void) { CFE_SB_PipeId_t PipedId; - CFE_SB_MsgId_t MsgId0 = SB_UT_CMD_MID + 1; - CFE_SB_MsgId_t MsgId1 = SB_UT_CMD_MID + 2; - CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID + 3; - CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID + 4; - uint32 AppId = 0; + uint32 AppId = 0; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test DeletePipeWithAppId API"); -#endif - - SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId0, PipedId); - CFE_SB_Subscribe(MsgId1, PipedId); - CFE_SB_Subscribe(MsgId2, PipedId); - CFE_SB_Subscribe(MsgId3, PipedId); - ActRtn = CFE_SB_DeletePipeWithAppId(PipedId, AppId); - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in delete pipe w/app ID test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + START(); - ExpRtn = 14; - ActRtn = UT_GetNumEventsSent(); + SB_ResetUnitTest(); + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 1, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 2, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 3, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 4, PipedId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_DeletePipeWithAppId(PipedId, AppId)); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", "With app ID test"); + EVTCNT(14); + + REPORT(); } /* end Test_DeletePipe_WithAppid */ /* @@ -3711,9 +2018,7 @@ void Test_DeletePipe_WithAppid(void) */ void Test_PipeOpts_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_PipeOpts_API"); -#endif + STARTBLOCK(); Test_SetPipeOpts_BadID(); Test_SetPipeOpts_NotOwner(); @@ -3722,9 +2027,7 @@ void Test_PipeOpts_API(void) Test_GetPipeOpts_BadPtr(); Test_GetPipeOpts(); -#ifdef UT_VERBOSE - UT_Text("End Test_PipeOpts_API\n"); -#endif + ENDBLOCK(); } /* end Test_PipeOpts_API */ /* @@ -3732,17 +2035,13 @@ void Test_PipeOpts_API(void) */ void Test_GetPipeName_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_GetPipeName_API"); -#endif + STARTBLOCK(); Test_GetPipeName_NullPtr(); Test_GetPipeName_InvalidId(); Test_GetPipeName(); -#ifdef UT_VERBOSE - UT_Text("End Test_GetPipeName_API\n"); -#endif + ENDBLOCK(); } /* end Test_GetGetPipeName_API */ /* @@ -3750,33 +2049,13 @@ void Test_GetPipeName_API(void) */ void Test_GetPipeName_NullPtr(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeName with null ptr"); -#endif - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeName(NULL, OS_MAX_API_NAME, 0)) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } + START(); - if (UT_EventIsInHistory(CFE_SB_GETPIPENAME_NULL_PTR_EID) == false) - { - UT_Text("CFE_SB_GETPIPENAME_NULL_PTR_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeName(NULL, OS_MAX_API_NAME, 0), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPENAME_NULL_PTR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeName_NullPtr", - "Get pipe name with null ptr"); + REPORT(); } /* end Test_GetPipeName_NullPtr */ /* @@ -3784,36 +2063,16 @@ void Test_GetPipeName_NullPtr(void) */ void Test_GetPipeName_InvalidId(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; char PipeName[OS_MAX_API_NAME]; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeName with invalid pipe id"); -#endif + START(); UT_SetDeferredRetcode(UT_KEY(OS_QueueGetInfo), 1, OS_ERROR); - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeName(PipeName, OS_MAX_API_NAME, 0)) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_GETPIPENAME_ID_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPENAME_ID_ERR_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeName(PipeName, OS_MAX_API_NAME, 0), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPENAME_ID_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeName_InvalidId", - "Get pipe name with invalid id"); + REPORT(); } /* end Test_GetPipeName_InvalidId */ /* @@ -3821,8 +2080,6 @@ void Test_GetPipeName_InvalidId(void) */ void Test_GetPipeName(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; char PipeName[OS_MAX_API_NAME]; CFE_SB_PipeId_t PipeId = 0; @@ -3830,52 +2087,22 @@ void Test_GetPipeName(void) "TestPipe1", 0 }; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeName"); -#endif - - ExpRtn = CFE_SUCCESS; - if((ActRtn = CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_CreatePipe, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); + START(); - UT_Report(__FILE__, __LINE__, - CFE_FAIL, "CFE_SB_GetPipeName", - "Get pipe name by id"); - return; - } + SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")); UT_SetDataBuffer( UT_KEY(OS_QueueGetInfo), &queue_info, sizeof(queue_info), false); - ExpRtn = CFE_SUCCESS; - if((ActRtn = CFE_SB_GetPipeName(PipeName, OS_MAX_API_NAME, PipeId)) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_GETPIPENAME_EID) == false) - { - UT_Text("CFE_SB_GETPIPENAME_EID not sent"); + ASSERT(CFE_SB_GetPipeName(PipeName, OS_MAX_API_NAME, PipeId)); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPENAME_EID); - CFE_SB_DeletePipe(PipeId); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeName", - "Get pipe name"); + REPORT(); } /* end Test_GetPipeName */ /* @@ -3883,17 +2110,13 @@ void Test_GetPipeName(void) */ void Test_GetPipeIdByName_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_GetPipeIdByName_API"); -#endif + STARTBLOCK(); Test_GetPipeIdByName_NullPtrs(); Test_GetPipeIdByName_InvalidName(); Test_GetPipeIdByName(); -#ifdef UT_VERBOSE - UT_Text("End Test_GetPipeIdByName_API\n"); -#endif + ENDBLOCK(); } /* end Test_GetPipeIdByName_API */ /* @@ -3901,52 +2124,18 @@ void Test_GetPipeIdByName_API(void) */ void Test_GetPipeIdByName_NullPtrs(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeIDOut = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeIdByName with null ptrs"); -#endif - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeIdByName(&PipeIDOut, NULL)) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeIdByName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEIDBYNAME_EID not sent"); - - TestStat = CFE_FAIL; - } + START(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeIdByName(NULL, "invalid")) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeIdByName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); + ASSERT_EQ(CFE_SB_GetPipeIdByName(&PipeIDOut, NULL), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEIDBYNAME_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeIdByName(NULL, "invalid"), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeIdByName_NullPtrs", - "Get pipe id by name with null ptrs"); + REPORT(); } /* end Test_GetPipeIdByName_NullPtrs */ /* @@ -3954,34 +2143,14 @@ void Test_GetPipeIdByName_NullPtrs(void) */ void Test_GetPipeIdByName_InvalidName(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeIdOut = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeIdByName with invalid pipe name"); -#endif - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeIdByName(&PipeIdOut, "invalid")) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeIdByName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } + START(); - if (UT_EventIsInHistory(CFE_SB_GETPIPEIDBYNAME_NAME_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEIDBYNAME_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeIdByName(&PipeIdOut, "invalid"), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEIDBYNAME_NAME_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeIdByName_InvalidName", - "Get pipe id by name with invalid name"); + REPORT(); } /* end Test_GetPipeIdByName_InvalidName */ /* @@ -3989,26 +2158,10 @@ void Test_GetPipeIdByName_InvalidName(void) */ void Test_GetPipeIdByName(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeId = 0, PipeIdOut = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeIdByName"); -#endif - - ExpRtn = CFE_SUCCESS; - if((ActRtn = CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_CreatePipe, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); + START(); - UT_Report(__FILE__, __LINE__, - CFE_FAIL, "CFE_SB_GetPipeIdByName", - "Get pipe id by name"); - return; - } + SETUP(CFE_SB_CreatePipe(&PipeId, 4, "TestPipe1")); UT_SetDataBuffer( UT_KEY(OS_QueueGetIdByName), @@ -4016,29 +2169,13 @@ void Test_GetPipeIdByName(void) sizeof(CFE_SB.PipeTbl[0].SysQueueId), false); - ExpRtn = CFE_SUCCESS; - if((ActRtn = CFE_SB_GetPipeIdByName(&PipeIdOut, "TestPipe1")) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeIdByName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_GETPIPEIDBYNAME_EID) == false) - { - UT_Text("CFE_SB_GETPIPEIDBYNAME_EID not sent"); + ASSERT(CFE_SB_GetPipeIdByName(&PipeIdOut, "TestPipe1")); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEIDBYNAME_EID); - CFE_SB_DeletePipe(PipeId); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeIdByName", - "Get pipe id by name"); + REPORT(); } /* end Test_GetPipeIdByName */ /* @@ -4046,31 +2183,13 @@ void Test_GetPipeIdByName(void) */ void Test_SetPipeOpts_BadID(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - SetPipeOpts with bad ID"); -#endif + START(); - if((ActRtn = CFE_SB_SetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, 0)) != CFE_SB_BAD_ARGUMENT) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SetPipeOpts, exp=%ld, act=%ld", - (long) CFE_SB_BAD_ARGUMENT, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, 0), CFE_SB_BAD_ARGUMENT); - if (UT_EventIsInHistory(CFE_SB_SETPIPEOPTS_ID_ERR_EID) == false) - { - UT_Text("CFE_SB_SETPIPEOPTS_ID_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SETPIPEOPTS_ID_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SetPipeOpts", - "Set pipe opts with invalid ID test"); + REPORT(); } /* end Test_SetPipeOpts_BadID */ /* @@ -4078,55 +2197,27 @@ void Test_SetPipeOpts_BadID(void) */ void Test_SetPipeOpts_NotOwner(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeID = 0; uint8 PipeTblIdx = 0; uint32 OrigOwner = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - SetPipeOpts with bad ID"); -#endif - - if((ActRtn = CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")) != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_CreatePipe, act=%ld", - (long) ActRtn); - UT_Text(cMsg); + START(); - UT_Report(__FILE__, __LINE__, - CFE_FAIL, "CFE_SB_SetPipeOpts_NotOwner", - "Set pipe opts when not owner"); - return; - } + SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); PipeTblIdx = CFE_SB_GetPipeIdx(PipeID); OrigOwner = CFE_SB.PipeTbl[PipeTblIdx].AppId; CFE_SB.PipeTbl[PipeTblIdx].AppId = 0xFFFFFFFF; - if((ActRtn = CFE_SB_SetPipeOpts(PipeID, 0)) != CFE_SB_BAD_ARGUMENT) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SetPipeOpts, exp=%ld, act=%ld", - (long) CFE_SB_BAD_ARGUMENT, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SetPipeOpts(PipeID, 0), CFE_SB_BAD_ARGUMENT); CFE_SB.PipeTbl[PipeTblIdx].AppId = OrigOwner; - if (UT_EventIsInHistory(CFE_SB_SETPIPEOPTS_OWNER_ERR_EID) == false) - { - UT_Text("CFE_SB_SETPIPEOPTS_OWNER_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SETPIPEOPTS_OWNER_ERR_EID); - CFE_SB_DeletePipe(PipeID); + TEARDOWN(CFE_SB_DeletePipe(PipeID)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SetPipeOpts", - "Set pipe opts when not owner"); + REPORT(); } /* end Test_SetPipeOpts_NotOwner */ /* @@ -4134,47 +2225,19 @@ void Test_SetPipeOpts_NotOwner(void) */ void Test_SetPipeOpts(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeID = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - SetPipeOpts"); -#endif - - if((ActRtn = CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")) != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_CreatePipe, act=%ld", - (long) ActRtn); - UT_Text(cMsg); + START(); - UT_Report(__FILE__, __LINE__, - CFE_FAIL, "CFE_SB_SetPipeOpts", - "Set pipe opts"); - return; - } + SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); - if((ActRtn = CFE_SB_SetPipeOpts(PipeID, 0)) != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SetPipeOpts, act=%ld", - (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SetPipeOpts(PipeID, 0)); - if (UT_EventIsInHistory(CFE_SB_SETPIPEOPTS_EID) == false) - { - UT_Text("CFE_SB_SETPIPEOPTS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SETPIPEOPTS_EID); - CFE_SB_DeletePipe(PipeID); + TEARDOWN(CFE_SB_DeletePipe(PipeID)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SetPipeOpts", - "Set pipe opts"); + REPORT(); } /* end Test_SetPipeOpts */ /* @@ -4182,32 +2245,15 @@ void Test_SetPipeOpts(void) */ void Test_GetPipeOpts_BadID(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; uint8 Opts = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeOpts with bad ID"); -#endif + START(); - if((ActRtn = CFE_SB_GetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, &Opts)) != CFE_SB_BAD_ARGUMENT) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeOpts, exp=%ld, act=%ld", - (long) CFE_SB_BAD_ARGUMENT, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_GetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, &Opts), CFE_SB_BAD_ARGUMENT); - if (UT_EventIsInHistory(CFE_SB_GETPIPEOPTS_ID_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEOPTS_ID_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEOPTS_ID_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeOpts", - "Get pipe opts with invalid ID test"); + REPORT(); } /* end Test_GetPipeOpts_BadID */ /* @@ -4215,49 +2261,19 @@ void Test_GetPipeOpts_BadID(void) */ void Test_GetPipeOpts_BadPtr(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeID = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeOpts with bad ptr"); -#endif - - if((ActRtn = CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")) != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_CreatePipe, act=%ld", - (long) ActRtn); - UT_Text(cMsg); - - UT_Report(__FILE__, __LINE__, - CFE_FAIL, "CFE_SB_GetPipeOpts", - "Get pipe opts with bad ptr"); - return; - } - - if((ActRtn = CFE_SB_GetPipeOpts(PipeID, NULL)) != CFE_SB_BAD_ARGUMENT) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeOpts, exp=%ld, act=%ld", - (long) CFE_SB_BAD_ARGUMENT, (long) ActRtn); - UT_Text(cMsg); + START(); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); - if (UT_EventIsInHistory(CFE_SB_GETPIPEOPTS_PTR_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEOPTS_PTR_ERR_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeOpts(PipeID, NULL), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEOPTS_PTR_ERR_EID); - CFE_SB_DeletePipe(PipeID); + TEARDOWN(CFE_SB_DeletePipe(PipeID)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeOpts", - "Get pipe opts with bad ptr"); + REPORT(); } /* end Test_GetPipeOpts_BadPtr */ /* @@ -4265,60 +2281,28 @@ void Test_GetPipeOpts_BadPtr(void) */ void Test_GetPipeOpts(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeID = 0; uint8 Opts = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeOpts"); -#endif - - if((ActRtn = CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")) != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_CreatePipe, act=%ld", - (long) ActRtn); - UT_Text(cMsg); - - UT_Report(__FILE__, __LINE__, - CFE_FAIL, "CFE_SB_GetPipeOpts", - "Get pipe opts"); - return; - } - if((ActRtn = CFE_SB_GetPipeOpts(PipeID, &Opts)) != CFE_SUCCESS) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeOpts, act=%ld", - (long) ActRtn); - UT_Text(cMsg); + START(); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeID, 4, "TestPipe1")); - if (UT_EventIsInHistory(CFE_SB_GETPIPEOPTS_EID) == false) - { - UT_Text("CFE_SB_GETPIPEOPTS_EID not sent"); + ASSERT(CFE_SB_GetPipeOpts(PipeID, &Opts)); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEOPTS_EID); - CFE_SB_DeletePipe(PipeID); + TEARDOWN(CFE_SB_DeletePipe(PipeID)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeOpts", - "Get pipe opts"); + REPORT(); } /* end Test_GetPipeOpts */ - /* ** Function for calling SB subscribe API test functions */ void Test_Subscribe_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_Subscribe_API\n"); -#endif + STARTBLOCK(); Test_Subscribe_SubscribeEx(); Test_Subscribe_InvalidPipeId(); @@ -4334,9 +2318,7 @@ void Test_Subscribe_API(void) Test_Subscribe_SubscriptionReporting(); Test_Subscribe_InvalidPipeOwner(); -#ifdef UT_VERBOSE - UT_Text("End Test_Subscribe_API\n"); -#endif + ENDBLOCK(); } /* end Test_Subscribe_API */ /* @@ -4349,55 +2331,22 @@ void Test_Subscribe_SubscribeEx(void) CFE_SB_Qos_t Quality = {0, 0}; uint16 PipeDepth = 10; uint16 MsgLim = 8; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for SubscribeEx"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_SubscribeEx(MsgId, PipeId, Quality, MsgLim); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in SubscribeEx Test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SubscribeEx(MsgId, PipeId, Quality, MsgLim)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", "SubscribeEx test"); + REPORT(); } /* end Test_Subscribe_SubscribeEx */ /* @@ -4407,48 +2356,17 @@ void Test_Subscribe_InvalidPipeId(void) { CFE_SB_PipeId_t PipeId = 2; CFE_SB_MsgId_t MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid pipe ID subscribe test, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_SUB_INV_PIPE_EID) == false) - { - UT_Text("CFE_SB_SUB_INV_PIPE_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUB_INV_PIPE_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", "Invalid pipe ID test"); + REPORT(); } /* end Test_Subscribe_InvalidPipeId */ /* @@ -4459,51 +2377,21 @@ void Test_Subscribe_InvalidMsgId(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Message ID"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid message ID subscribe test, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUB_ARG_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_SUB_ARG_ERR_EID) == false) - { - UT_Text("CFE_SB_SUB_ARG_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Invalid message ID test"); + REPORT(); } /* end Test_Subscribe_InvalidMsgId */ /* @@ -4516,52 +2404,22 @@ void Test_Subscribe_MaxMsgLim(void) CFE_SB_Qos_t Quality = {0, 0}; uint16 PipeDepth = 10; uint16 MsgLim; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Maximum Message Limit"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); MsgLim = 0xffff; - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_SubscribeEx(MsgId, PipeId, Quality, MsgLim); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in maximum message limit subscribe test, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SubscribeEx(MsgId, PipeId, Quality, MsgLim)); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Maximum message limit test"); + REPORT(); } /* end Test_Subscribe_MaxMsgLim */ /* @@ -4572,64 +2430,22 @@ void Test_Subscribe_DuplicateSubscription(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Duplicate Subscription"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in first subscribe of duplicate " - "subscription test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); + ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); + ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in second subscribe of duplicate " - "subscription test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Duplicate subscription test"); + REPORT(); } /* end Test_Subscribe_DuplicateSubscription */ /* @@ -4641,51 +2457,20 @@ void Test_Subscribe_LocalSubscription(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; uint16 MsgLim = 4; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Local Subscription"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_SubscribeLocal(MsgId, PipeId, MsgLim); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in local subscription test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SubscribeLocal(MsgId, PipeId, MsgLim)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Local subscription test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + REPORT(); } /* end Test_Subscribe_LocalSubscription */ /* @@ -4698,14 +2483,8 @@ void Test_Subscribe_MaxDestCount(void) char PipeName[OS_MAX_API_NAME]; uint16 PipeDepth = 50; int32 i; - int32 Rtn[CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1]; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Maximum Destination Count"); -#endif + START(); SB_ResetUnitTest(); @@ -4713,75 +2492,33 @@ void Test_Subscribe_MaxDestCount(void) for (i = 0; i < CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1; i++) { snprintf(PipeName, OS_MAX_API_NAME, "TestPipe%ld", (long) i); - Rtn[i] = CFE_SB_CreatePipe(&PipeId[i], PipeDepth, &PipeName[0]); - ExpRtn = CFE_SUCCESS; - - if (Rtn[i] != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected error creating pipes in maximum destination " - "count test, i=%ld, exp=0x%lx, act=0x%lx", - (long) i, (unsigned long) ExpRtn, - (unsigned long) Rtn[i]); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; - } + SETUP(CFE_SB_CreatePipe(&PipeId[i], PipeDepth, &PipeName[0])); } /* Do subscriptions */ for (i = 0; i < CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1; i++) { - ActRtn = CFE_SB_Subscribe(MsgId, i); - if (i < CFE_PLATFORM_SB_MAX_DEST_PER_PKT) { - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(MsgId, i)); } else { - ExpRtn = CFE_SB_MAX_DESTS_MET; - } - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in maximum destination count test, " - "i=%ld, exp=0x%lx, act=0x%lx", - (long) i, (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - break; + ASSERT_EQ(CFE_SB_Subscribe(MsgId, i), CFE_SB_MAX_DESTS_MET); } } - ExpRtn = 3 * (CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1); - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3 * (CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1)); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); /* Delete pipes */ for (i = 0; i < CFE_PLATFORM_SB_MAX_DEST_PER_PKT + 1; i++) { - CFE_SB_DeletePipe(PipeId[i]); + TEARDOWN(CFE_SB_DeletePipe(PipeId[i])); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Maximum destination count test"); + REPORT(); } /* end Test_Subscribe_MaxDestCount */ /* @@ -4794,56 +2531,35 @@ void Test_Subscribe_MaxMsgIdCount(void) CFE_SB_PipeId_t PipeId2; uint16 PipeDepth = 50; int32 i; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Maximum Message ID Count"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); + SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); for (i = 0; i < CFE_PLATFORM_SB_MAX_MSG_IDS + 1; i++) { - ActRtn = CFE_SB_Subscribe(i, PipeId2); if (i < CFE_PLATFORM_SB_MAX_MSG_IDS) { - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(i, PipeId2)); } else { - ExpRtn = CFE_SB_MAX_MSGS_MET; - } - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in maximum message ID count test, " - "i=%ld, exp=0x%lx, act=0x%lx", - (long) i, (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; + ASSERT_EQ(CFE_SB_Subscribe(i, PipeId2), CFE_SB_MAX_MSGS_MET); } } - if (UT_EventIsInHistory(CFE_SB_MAX_MSGS_MET_EID) == false) - { - UT_Text("CFE_SB_MAX_MSGS_MET_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MAX_MSGS_MET_EID); - CFE_SB_DeletePipe(PipeId0); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Maximum message ID count test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + + REPORT(); } /* end Test_Subscribe_MaxMsgIdCount */ /* @@ -4858,59 +2574,40 @@ void Test_Subscribe_SendPrevSubs(void) CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID + 2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID + 3; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; CFE_SB_SendPrevSubs_t SendPrevSubsMsg; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Send Previous Subscriptions"); -#endif + 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(); - CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_Subscribe(MsgId0, PipeId0); - CFE_SB_Subscribe(MsgId1, PipeId0); - CFE_SB_Subscribe(MsgId2, PipeId0); - CFE_SB_Subscribe(MsgId0, PipeId1); - CFE_SB_Subscribe(MsgId1, PipeId1); - CFE_SB_Subscribe(MsgId2, PipeId1); - CFE_SB_Subscribe(MsgId0, PipeId2); + SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId2)); /* Set the last list header pointer to NULL to get branch path coverage */ CFE_SB.RoutingTbl[2].ListHeadPtr = NULL; - CFE_SB_SendPrevSubsCmd(&SendPrevSubsMsg); - ExpRtn = 19; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SendPrevSubsCmd(&SendPrevSubsMsg)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(19); - if (UT_EventIsInHistory(CFE_SB_PART_SUB_PKT_EID) == false) - { - UT_Text("CFE_SB_PART_SUB_PKT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PART_SUB_PKT_EID); - CFE_SB_DeletePipe(PipeId0); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Send previous subscriptions test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + + REPORT(); } /* end Test_Subscribe_SendPrevSubs */ /* @@ -4926,66 +2623,35 @@ void Test_Subscribe_FindGlobalMsgIdCnt(void) CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID + 3; uint16 PipeDepth = 50; uint16 MsgLim = 4; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Find Global Message ID Count"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_Subscribe(MsgId0, PipeId0); - CFE_SB_Subscribe(MsgId1, PipeId0); - CFE_SB_Subscribe(MsgId2, PipeId0); - CFE_SB_Subscribe(MsgId0, PipeId1); - CFE_SB_Subscribe(MsgId1, PipeId1); - CFE_SB_Subscribe(MsgId2, PipeId1); - CFE_SB_SubscribeLocal(MsgId0, PipeId2, MsgLim); + SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId1)); + SETUP(CFE_SB_SubscribeLocal(MsgId0, PipeId2, MsgLim)); /* Set the last list head pointer to NULL for branch path coverage */ CFE_SB.RoutingTbl[2].ListHeadPtr = NULL; - ActRtn = CFE_SB_FindGlobalMsgIdCnt(); - ExpRtn = 2; /* 2 unique msg ids; the third is set to skip */ - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in find global message ID count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_FindGlobalMsgIdCnt(), 2); /* 2 unique msg ids; the third is set to skip */ - ExpRtn = 17; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(17); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - CFE_SB_DeletePipe(PipeId0); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Find global message ID count test"); + REPORT(); } /* end Test_Subscribe_FindGlobalMsgIdCnt */ /* @@ -4995,49 +2661,18 @@ void Test_Subscribe_PipeNonexistent(void) { CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; CFE_SB_PipeId_t PipeId = 55; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Pipe Nonexistent"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe nonexistent test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_SUB_INV_PIPE_EID) == false) - { - UT_Text("CFE_SB_SUB_INV_PIPE_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUB_INV_PIPE_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Pipe nonexistent test"); + REPORT(); } /* end Test_Subscribe_PipeNonexistent */ /* @@ -5049,122 +2684,35 @@ void Test_Subscribe_SubscriptionReporting(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_Qos_t Quality; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test SubscribeFull, Subscription Reporting"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CreatePipe in subscription reporting " - "test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - /* Enable subscription reporting */ - CFE_SB_SetSubscriptionReporting(CFE_SB_ENABLE); + /* Enable subscription reporting */ + CFE_SB_SetSubscriptionReporting(CFE_SB_ENABLE); - /* Subscribe to message: GLOBAL */ - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); - ExpRtn = CFE_SUCCESS; + /* Subscribe to message: GLOBAL */ + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from Subscribe in subscription " - "reporting test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - /* Unsubscribe so that a local subscription can be tested */ - ActRtn = CFE_SB_Unsubscribe(MsgId, PipeId); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from Unsubscribe in subscription " - "reporting test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from Unsubscribe in subscription " - "reporting test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - /* Subscribe to message: LOCAL */ - ActRtn = CFE_SB_SubscribeFull(MsgId, PipeId, Quality, - CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, - CFE_SB_LOCAL); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from SubscribeFull in " - "subscription reporting test, exp=0x%lx, " - "act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - ExpRtn = 8; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RPT_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RPT_EID not sent"); - TestStat = CFE_FAIL; - } - } - } - } + /* Unsubscribe so that a local subscription can be tested */ + SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); - /* Disable subscription reporting */ - CFE_SB_SetSubscriptionReporting(CFE_SB_DISABLE); - } + /* Subscribe to message: LOCAL */ + ASSERT(CFE_SB_SubscribeFull(MsgId, PipeId, Quality, CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, CFE_SB_LOCAL)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Subscription reporting test"); + EVTCNT(8); + + EVTSENT(CFE_SB_SUBSCRIPTION_RPT_EID); + + /* Disable subscription reporting */ + CFE_SB_SetSubscriptionReporting(CFE_SB_DISABLE); + + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_Subscribe_SubscriptionReporting */ /* @@ -5176,27 +2724,11 @@ void Test_Subscribe_InvalidPipeOwner(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 10; int32 RealOwner; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe Owner"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "First return was unexpected in subscribe - non owner test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); /* Change owner of pipe through memory corruption */ RealOwner = CFE_SB.PipeTbl[PipeId].AppId; @@ -5204,30 +2736,16 @@ void Test_Subscribe_InvalidPipeOwner(void) /* Choose a value that is sure not to be owner */ CFE_SB.PipeTbl[PipeId].AppId = RealOwner + 1; CFE_SB_Subscribe(MsgId, PipeId); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUB_INV_CALLER_EID) == false) - { - UT_Text("CFE_SB_SUB_INV_CALLER_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUB_INV_CALLER_EID); /* Restore owner id and delete pipe since test is complete */ CFE_SB.PipeTbl[PipeId].AppId = RealOwner; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Invalid pipe owner test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_Subscribe_InvalidPipeOwner */ /* @@ -5235,9 +2753,7 @@ void Test_Subscribe_InvalidPipeOwner(void) */ void Test_Unsubscribe_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_Unsubscribe_API"); -#endif + STARTBLOCK(); Test_Unsubscribe_Basic(); Test_Unsubscribe_Local(); @@ -5249,9 +2765,7 @@ void Test_Unsubscribe_API(void) Test_Unsubscribe_MiddleDestWithMany(); Test_Unsubscribe_GetDestPtr(); -#ifdef UT_VERBOSE - UT_Text("End Test_Unsubscribe_API\n"); -#endif + ENDBLOCK(); } /* end Test_Unsubscribe_API */ /* @@ -5262,51 +2776,21 @@ void Test_Unsubscribe_Basic(void) CFE_SB_PipeId_t TestPipe; CFE_SB_MsgId_t MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID / 2 + 1; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe Basic"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in unsubscribe basic, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_Unsubscribe(MsgId, TestPipe)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", "Unsubscribe basic"); + TEARDOWN(CFE_SB_DeletePipe(TestPipe)); + REPORT(); } /* end Test_Unsubscribe_Basic */ /* @@ -5317,52 +2801,22 @@ void Test_Unsubscribe_Local(void) CFE_SB_PipeId_t TestPipe; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Local Unsubscribe"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_UnsubscribeLocal(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID, TestPipe); + SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in local unsubscribe test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_UnsubscribeLocal(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID, TestPipe)); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Local unsubscribe test"); + REPORT(); } /* end Test_Unsubscribe_Local */ /* @@ -5373,112 +2827,42 @@ void Test_Unsubscribe_InvalParam(void) CFE_SB_PipeId_t TestPipe; uint32 CallerId = 0xFFFFFFFF; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t SavedPipeId; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Param, Unsubscribe"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); + SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); /* Perform test using a bad message ID */ - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Unsubscribe(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid param (MsgId) unsubscribe " - "test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_Unsubscribe(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, TestPipe), CFE_SB_BAD_ARGUMENT); /* Get the caller's Application ID */ - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_ES_GetAppID(&CallerId); + ASSERT(CFE_ES_GetAppID(&CallerId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from GetAppID in unsubscribe test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - /* Perform test using a bad scope value */ - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_UnsubscribeFull(0, TestPipe, CFE_SB_LOCAL + 1, - CallerId); + /* Perform test using a bad scope value */ + ASSERT_EQ(CFE_SB_UnsubscribeFull(0, TestPipe, CFE_SB_LOCAL + 1, CallerId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid param (Scope) unsubscribe " - "test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else - { - /* Perform test using an invalid pipe ID for branch path coverage. - * This situation cannot happen in normal circumstances since the - * bad pipe ID is caught by CFE_SB_GetPipeIdx() before it gets to - * CFE_SB_ValidatePipeId() - */ - ExpRtn = CFE_SB_BAD_ARGUMENT; - SavedPipeId = CFE_SB.PipeTbl[0].PipeId; - CFE_SB.PipeTbl[0].PipeId = CFE_PLATFORM_SB_MAX_PIPES; - CFE_SB.PipeTbl[0].InUse = 1; - ActRtn = CFE_SB_Unsubscribe(0, CFE_PLATFORM_SB_MAX_PIPES); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid param (PipeId) " - "unsubscribe test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - /* We must restore the old value so CFE_SB_DeletePipe() works */ - CFE_SB.PipeTbl[0].PipeId = SavedPipeId; - - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - } - } + /* Perform test using an invalid pipe ID for branch path coverage. + * This situation cannot happen in normal circumstances since the + * bad pipe ID is caught by CFE_SB_GetPipeIdx() before it gets to + * CFE_SB_ValidatePipeId() + */ + SavedPipeId = CFE_SB.PipeTbl[0].PipeId; + CFE_SB.PipeTbl[0].PipeId = CFE_PLATFORM_SB_MAX_PIPES; + CFE_SB.PipeTbl[0].InUse = 1; + ASSERT_EQ(CFE_SB_Unsubscribe(0, CFE_PLATFORM_SB_MAX_PIPES), CFE_SB_BAD_ARGUMENT); - if (UT_EventIsInHistory(CFE_SB_UNSUB_ARG_ERR_EID) == false) - { - UT_Text("CFE_SB_UNSUB_ARG_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + /* We must restore the old value so CFE_SB_DeletePipe() works */ + CFE_SB.PipeTbl[0].PipeId = SavedPipeId; - CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Invalid param, unsubscribe test"); + EVTCNT(4); + + EVTSENT(CFE_SB_UNSUB_ARG_ERR_EID); + + TEARDOWN(CFE_SB_DeletePipe(TestPipe)); + + REPORT(); } /* end Test_Unsubscribe_InvalParam */ /* @@ -5490,68 +2874,28 @@ void Test_Unsubscribe_NoMatch(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_MsgRouteIdx_t Idx; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for No Match"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId + 1, TestPipe); + SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in no match test (bad MsgId), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Unsubscribe(MsgId + 1, TestPipe)); /* Get index into routing table */ Idx = CFE_SB_GetRoutingTblIdx(CFE_SB_ConvertMsgIdtoMsgKey(MsgId)); CFE_SB.RoutingTbl[CFE_SB_RouteIdxToValue(Idx)].ListHeadPtr->PipeId = 1; CFE_SB.RoutingTbl[CFE_SB_RouteIdxToValue(Idx)].ListHeadPtr->Next = NULL; - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in no match test (bad routing table), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Unsubscribe(MsgId, TestPipe)); - ExpRtn = 6; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(6); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_UNSUB_NO_SUBS_EID); - if (UT_EventIsInHistory(CFE_SB_UNSUB_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_UNSUB_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", "No match test"); + REPORT(); } /* end Test_Unsubscribe_NoMatch */ /* @@ -5562,51 +2906,22 @@ void Test_Unsubscribe_InvalidPipe(void) CFE_SB_PipeId_t TestPipe; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test Unsubscribe, Invalid Pipe"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe + 1); + SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid pipe test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, TestPipe + 1), CFE_SB_BAD_ARGUMENT); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(4); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_UNSUB_INV_PIPE_EID); - if (UT_EventIsInHistory(CFE_SB_UNSUB_INV_PIPE_EID) == false) - { - UT_Text("CFE_SB_UNSUB_INV_PIPE_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(TestPipe)); - CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", "Invalid pipe test"); + REPORT(); } /* end Test_Unsubscribe_InvalidPipe */ /* @@ -5618,71 +2933,30 @@ void Test_Unsubscribe_InvalidPipeOwner(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint32 RealOwner; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe Owner"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "First return was unexpected in unsubscribe - non owner " - "Test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* Change owner of pipe through memory corruption */ RealOwner = CFE_SB.PipeTbl[PipeId].AppId; /* Choose a value that is sure not be owner */ CFE_SB.PipeTbl[PipeId].AppId = RealOwner + 1; - ActRtn = CFE_SB_Unsubscribe(MsgId, PipeId); - ExpRtn = CFE_SB_BAD_ARGUMENT; + ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Second return was unexpected in unsubscribe - non owner " - "Test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + EVTSENT(CFE_SB_UNSUB_INV_CALLER_EID); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + CFE_SB.PipeTbl[PipeId].AppId = RealOwner; - if (UT_EventIsInHistory(CFE_SB_UNSUB_INV_CALLER_EID) == false) - { - UT_Text("CFE_SB_UNSUB_INV_CALLER_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB.PipeTbl[PipeId].AppId = RealOwner; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Invalid pipe owner test"); + REPORT(); } /* end Test_Unsubscribe_InvalidPipeOwner */ /* @@ -5696,58 +2970,28 @@ void Test_Unsubscribe_FirstDestWithMany(void) CFE_SB_PipeId_t TestPipe2; CFE_SB_PipeId_t TestPipe3; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe First Destination With Many"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2"); - CFE_SB_CreatePipe(&TestPipe3, PipeDepth, "TestPipe3"); - CFE_SB_Subscribe(MsgId, TestPipe1); - CFE_SB_Subscribe(MsgId, TestPipe2); - CFE_SB_Subscribe(MsgId, TestPipe3); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe1); + SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_CreatePipe(&TestPipe3, PipeDepth, "TestPipe3")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe1)); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe2)); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe3)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in unsubscribe first destination with " - "many, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Unsubscribe(MsgId, TestPipe1)); - ExpRtn = 10; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(10); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(TestPipe1)); + TEARDOWN(CFE_SB_DeletePipe(TestPipe2)); + TEARDOWN(CFE_SB_DeletePipe(TestPipe3)); - CFE_SB_DeletePipe(TestPipe1); - CFE_SB_DeletePipe(TestPipe2); - CFE_SB_DeletePipe(TestPipe3); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Unsubscribe first destination with many"); + REPORT(); } /* end Test_Unsubscribe_FirstDestWithMany */ /* @@ -5761,58 +3005,29 @@ void Test_Unsubscribe_MiddleDestWithMany(void) CFE_SB_PipeId_t TestPipe2; CFE_SB_PipeId_t TestPipe3; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe Middle Destination With Many"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2"); - CFE_SB_CreatePipe(&TestPipe3, PipeDepth, "TestPipe3"); - CFE_SB_Subscribe(MsgId, TestPipe1); - CFE_SB_Subscribe(MsgId, TestPipe2); - CFE_SB_Subscribe(MsgId, TestPipe3); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in unsubscribe middle destination with " - "many, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_CreatePipe(&TestPipe3, PipeDepth, "TestPipe3")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe1)); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe2)); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe3)); - ExpRtn = 10; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_Unsubscribe(MsgId, TestPipe2)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(10); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_DeletePipe(TestPipe1); - CFE_SB_DeletePipe(TestPipe2); - CFE_SB_DeletePipe(TestPipe3); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Unsubscribe middle destination with many"); + TEARDOWN(CFE_SB_DeletePipe(TestPipe1)); + TEARDOWN(CFE_SB_DeletePipe(TestPipe2)); + TEARDOWN(CFE_SB_DeletePipe(TestPipe3)); + + REPORT(); } /* end Test_Unsubscribe_MiddleDestWithMany */ /* @@ -5825,51 +3040,27 @@ void Test_Unsubscribe_GetDestPtr(void) CFE_SB_PipeId_t TestPipe1; CFE_SB_PipeId_t TestPipe2; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe, Get Destination Pointer"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2"); - CFE_SB_Subscribe(MsgId, TestPipe1); - CFE_SB_Subscribe(MsgId, TestPipe2); - CFE_SB_Unsubscribe(MsgId, TestPipe2); - if (CFE_SB_GetDestPtr(CFE_SB_ConvertMsgIdtoMsgKey(MsgId), TestPipe2) != NULL) - { - UT_Text("Unexpected return in unsubscribe, get destination pointer, " - "exp NULL"); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&TestPipe1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&TestPipe2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe1)); + SETUP(CFE_SB_Subscribe(MsgId, TestPipe2)); + SETUP(CFE_SB_Unsubscribe(MsgId, TestPipe2)); - ExpRtn = 7; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(CFE_SB_GetDestPtr(CFE_SB_ConvertMsgIdtoMsgKey(MsgId), TestPipe2) == NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(7); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_DeletePipe(TestPipe1); - CFE_SB_DeletePipe(TestPipe2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Get destination pointer"); + TEARDOWN(CFE_SB_DeletePipe(TestPipe1)); + TEARDOWN(CFE_SB_DeletePipe(TestPipe2)); + + REPORT(); } /* end Test_Unsubscribe_GetDestPtr */ /* @@ -5877,9 +3068,7 @@ void Test_Unsubscribe_GetDestPtr(void) */ void Test_SendMsg_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_SendMsg_API"); -#endif + STARTBLOCK(); Test_SendMsg_NullPtr(); Test_SendMsg_InvalidMsgId(); @@ -5901,9 +3090,7 @@ void Test_SendMsg_API(void) Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(); Test_SendMsg_NoSubscribers_ZeroCopy(); -#ifdef UT_VERBOSE - UT_Text("End Test_SendMsg_API\n"); -#endif + ENDBLOCK(); } /* end Test_SendMsg_API */ /* @@ -5911,48 +3098,16 @@ void Test_SendMsg_API(void) */ void Test_SendMsg_NullPtr(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Null Pointer"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_SendMsg(NULL); - ExpRtn = CFE_SB_BAD_ARGUMENT; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in null pointer Test, exp=0x%lx, " - "act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendMsg(NULL), CFE_SB_BAD_ARGUMENT); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_SEND_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_BAD_ARG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "Null pointer test"); + REPORT(); } /* end Test_SendMsg_NullPtr */ /* @@ -5962,63 +3117,31 @@ void Test_SendMsg_InvalidMsgId(void) { SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Message ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, sizeof(TlmPkt), true); - + CFE_SB_SetMsgId(TlmPktPtr, 0xFFFF); - + CCSDS_WR_APID(TlmPktPtr->Hdr, 0x7FF ); #ifdef MESSAGE_FORMAT_IS_CCSDS_VER_2 - + CCSDS_WR_SUBSYSTEM_ID(TlmPktPtr->SpacePacket.ApidQ, 0x7E ); - -#endif - - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid message test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } +#endif - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendMsg(TlmPktPtr), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_INV_MSGID_EID) == false) - { - UT_Text("CFE_SB_SEND_INV_MSGID_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_INV_MSGID_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "Invalid message ID test"); + REPORT(); } /* end Test_SendMsg_InvalidMsgId */ /* @@ -6029,49 +3152,19 @@ void Test_SendMsg_NoSubscribers(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for No Subscribers"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in no subscribers test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_SEND_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_NO_SUBS_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "No subscribers test"); + REPORT(); } /* end Test_SendMsg_NoSubscribers */ /* @@ -6082,50 +3175,19 @@ void Test_SendMsg_MaxMsgSizePlusOne(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Maximum Message Size Plus One"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1, false); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SB_MSG_TOO_BIG; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in maximum message size plus one test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendMsg(TlmPktPtr), CFE_SB_MSG_TOO_BIG); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_MSG_TOO_BIG_EID) == false) - { - UT_Text("CFE_SB_MSG_TOO_BIG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MSG_TOO_BIG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Maximum message size plus one test"); + REPORT(); } /* end Test_SendMsg_MaxMsgSizePlusOne */ /* @@ -6138,45 +3200,21 @@ void Test_SendMsg_BasicSend(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 2; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Basic Send"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in basic send test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "Basic send test"); + REPORT(); } /* end Test_SendMsg_BasicSend */ /* @@ -6190,180 +3228,57 @@ void Test_SendMsg_SequenceCount(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; uint32 PipeDepth = 10; - int32 TestStat = CFE_PASS; - int32 ExpRtn; - int32 ActRtn; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Telemetry Sequence Count"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CCSDS_WR_SEQ(TlmPktPtr->Hdr, 22); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT_TRUE(PtrToMsg != NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv 1 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv 1 in sequence count test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 1) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=1, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 1); - ActRtn = CFE_SB_PassMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_PassMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from pass in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT_TRUE(PtrToMsg != NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv 2 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv 2 in sequence count test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 22) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for pass in sequence count test, " - "exp=22, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 22); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send 2 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv 3 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv 3 in sequence count test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 2) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=2, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(PtrToMsg != NULL); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_Unsubscribe(MsgId, PipeId); /* should have no subscribers now */ + SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); /* should have no subscribers now */ - CFE_SB_SendMsg(TlmPktPtr); /* increment to 3 */ + SETUP(CFE_SB_SendMsg(TlmPktPtr)); /* increment to 3 */ - CFE_SB_Subscribe(MsgId, PipeId); /* resubscribe so we can receive a msg */ + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* resubscribe so we can receive a msg */ - CFE_SB_SendMsg(TlmPktPtr); /* increment to 4 */ + SETUP(CFE_SB_SendMsg(TlmPktPtr)); /* increment to 4 */ - CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); + SETUP(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 4) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=4, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CCSDS_RD_SEQ(PtrToMsg->Hdr), 4); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Telemetry sequence count test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SendMsg_SequenceCount */ /* @@ -6376,53 +3291,25 @@ void Test_SendMsg_QueuePutError(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 2; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for QueuePut Error"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId4Error, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId4Error); + SETUP(CFE_SB_CreatePipe(&PipeId4Error, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId4Error)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_ERROR); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in QueuePut error test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); - if (UT_EventIsInHistory(CFE_SB_Q_WR_ERR_EID) == false) - { - UT_Text("CFE_SB_Q_WR_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_Q_WR_ERR_EID); + + TEARDOWN(CFE_SB_DeletePipe(PipeId4Error)); - CFE_SB_DeletePipe(PipeId4Error); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "QueuePut error test"); + REPORT(); } /* end Test_SendMsg_QueuePutError */ /* @@ -6435,69 +3322,29 @@ void Test_SendMsg_PipeFull(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 1; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Pipe Full"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* This send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return1 in pipe full test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); /* Tell the QueuePut stub to return OS_QUEUE_FULL on its next call */ UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_QUEUE_FULL); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); /* Pipe overflow causes SendMsg to return CFE_SUCCESS */ - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return2 in pipe full test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); - if (UT_EventIsInHistory(CFE_SB_Q_FULL_ERR_EID) == false) - { - UT_Text("CFE_SB_Q_FULL_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_Q_FULL_ERR_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "Pipe full test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + REPORT(); } /* end Test_SendMsg_PipeFull */ /* @@ -6510,73 +3357,31 @@ void Test_SendMsg_MsgLimitExceeded(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Msg Limit Exceeded"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); /* Set maximum allowed messages on the pipe at one time to 1 */ CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1); /* First send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in message limit test1, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); /* This send should produce a MsgId to Pipe Limit Exceeded message, but * return success */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in message limit test2, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MSGID_LIM_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_MSGID_LIM_ERR_EID) == false) - { - UT_Text("CFE_SB_MSGID_LIM_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Msg Limit Exceeded test"); + REPORT(); } /* end Test_SendMsg_MsgLimitExceeded */ /* @@ -6589,58 +3394,28 @@ void Test_SendMsg_GetPoolBufErr(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for GetPoolBufErr"); -#endif + START(); SB_ResetUnitTest(); PipeDepth = 1; CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "GetPoolErrPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "GetPoolErrPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* Have GetPoolBuf stub return error on its next call (buf descriptor * allocation failed) */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, CFE_ES_ERR_MEM_BLOCK_SIZE); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SB_BUF_ALOC_ERR; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetPoolBufErr1 test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SendMsg(TlmPktPtr), CFE_SB_BUF_ALOC_ERR); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(4); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GET_BUF_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_GET_BUF_ERR_EID) == false) - { - UT_Text("CFE_SB_GET_BUF_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "GetPoolBufErr test"); + REPORT(); } /* end Test_SendMsg_GetPoolBufErr */ /* @@ -6651,13 +3426,8 @@ void Test_SendMsg_ZeroCopyGetPtr(void) { CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl; uint16 MsgSize = 10; - cpuaddr ExpRtn; - cpuaddr ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for ZeroCopyGetPtr"); -#endif + START(); SB_ResetUnitTest(); @@ -6665,67 +3435,22 @@ void Test_SendMsg_ZeroCopyGetPtr(void) * allocation failed) */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, CFE_ES_ERR_MEM_BLOCK_SIZE); - ActRtn = (cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl); - ExpRtn = (cpuaddr) NULL; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyGetPtr test (buffer " - "descriptor), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) == (cpuaddr) NULL); /* Have GetPoolBuf stub return error on its second call (actual buffer * allocation failed) */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 2, CFE_ES_ERR_MEM_BLOCK_SIZE); - ActRtn = (cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl); - ExpRtn = (cpuaddr) NULL; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyGetPtr test, (buffer " - "allocation) exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - + ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) == (cpuaddr) NULL); /* Have GetPoolBuf stub return error on its second call (null buffer * returned and error returning the memory to the buffer) */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 2, -1); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, 0); - ActRtn = (cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl); - ExpRtn = (cpuaddr) NULL; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyGetPtr test, (null buffer, put " - "buffer) exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) == (cpuaddr) NULL); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (get pool buffer), " - "exp=%ld, act=%ld", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); /* Increase the peak memory and buffers in use above the expected values in * order to exercise branch paths @@ -6734,60 +3459,15 @@ void Test_SendMsg_ZeroCopyGetPtr(void) sizeof(CFE_SB_BufferD_t)) * 5; CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 2; - ActRtn = (cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl); - ExpRtn = (cpuaddr) NULL; - - if (ActRtn == ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyGetPtr test, (branch paths) " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) != (cpuaddr) NULL); - ExpRtn = (MsgSize + sizeof(CFE_SB_BufferD_t)) * 5; - ActRtn = CFE_SB.StatTlmMsg.Payload.PeakMemInUse; + ASSERT_TRUE(CFE_SB.StatTlmMsg.Payload.PeakMemInUse == (MsgSize + sizeof(CFE_SB_BufferD_t)) * 5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected branch path taken in ZeroCopyGetPtr test " - "(memory in use), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 1; - ActRtn = CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected branch path taken in ZeroCopyGetPtr test " - "(buffers in use), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse == CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 1); - ExpRtn = 0; - ActRtn = (cpuaddr)UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (branch paths), " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "ZeroCopyGetPtr test"); + REPORT(); } /* end Test_SendMsg_ZeroCopyGetPtr */ /* @@ -6802,26 +3482,16 @@ void Test_SendMsg_ZeroCopySend(void) CFE_SB_MsgPtr_t ZeroCpyMsgPtr = NULL; uint32 PipeDepth = 10; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for CFE_SB_ZeroCopySend"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); - ZeroCpyMsgPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), - &ZeroCpyBufHndl); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyTestPipe")); - if (ZeroCpyMsgPtr == NULL) - { - UT_Text("Unexpected NULL pointer returned from ZeroCopyGetPtr"); - TestStat = CFE_FAIL; - } - else + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + + if(ASSERT_TRUE((ZeroCpyMsgPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), + &ZeroCpyBufHndl)) != NULL)) { CFE_SB_InitMsg(ZeroCpyMsgPtr, MsgId, sizeof(SB_UT_Test_Tlm_t), true); CCSDS_WR_SEQ(ZeroCpyMsgPtr->Hdr, 22); @@ -6829,83 +3499,24 @@ void Test_SendMsg_ZeroCopySend(void) /* Test response to a get pool information error */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBufInfo), 1, -1); - ActRtn = CFE_SB_ZeroCopySend(ZeroCpyMsgPtr, ZeroCpyBufHndl); - ExpRtn = CFE_SB_BUFFER_INVALID; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in zero copy send test (get " - "pool information), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_ZeroCopySend(ZeroCpyMsgPtr, ZeroCpyBufHndl), CFE_SB_BUFFER_INVALID); /* Test a successful zero copy send */ - ActRtn = CFE_SB_ZeroCopySend(ZeroCpyMsgPtr, ZeroCpyBufHndl); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in zero copy send test " - "(success),exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_ZeroCopySend(ZeroCpyMsgPtr, ZeroCpyBufHndl)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv in zero copy send test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(PtrToMsg != NULL); - if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv in zero copy send test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 1) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=1, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CCSDS_RD_SEQ(PtrToMsg->Hdr), 1); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "CFE_SB_ZeroCopySend test"); + REPORT(); } /* end Test_SendMsg_ZeroCopySend */ /* @@ -6921,17 +3532,14 @@ void Test_SendMsg_ZeroCopyPass(void) uint32 PipeDepth = 10; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 Seq = 22; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for CFE_SB_ZeroCopyPass"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyPassTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "ZeroCpyPassTestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + ZeroCpyMsgPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), &ZeroCpyBufHndl); @@ -6948,45 +3556,15 @@ void Test_SendMsg_ZeroCopyPass(void) /* Test response to a get pool information error */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBufInfo), 1, -1); - ActRtn = CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl); - ExpRtn = CFE_SB_BUFFER_INVALID; + ASSERT_EQ(CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl), CFE_SB_BUFFER_INVALID); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in zero copy pass test (get " - "pool information) exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } /* Test a successful zero copy pass */ - ActRtn = CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in zero copy pass test " - "(success), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from receive in zero copy pass test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } if (PtrToMsg == NULL) { @@ -7003,28 +3581,13 @@ void Test_SendMsg_ZeroCopyPass(void) TestStat = CFE_FAIL; } - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "CFE_SB_ZeroCopyPass test"); + REPORT(); } /* end Test_SendMsg_ZeroCopyPass */ /* @@ -7039,153 +3602,47 @@ void Test_SendMsg_ZeroCopyReleasePtr(void) CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl2 = 0; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl3 = 0; uint16 MsgSize = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for ZeroCopyReleasePtr"); -#endif + START(); SB_ResetUnitTest(); ZeroCpyMsgPtr1 = CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl1); ZeroCpyMsgPtr2 = CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl2); ZeroCpyMsgPtr3 = CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl3); - ActRtn = CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2); - ExpRtn = CFE_SUCCESS; - - /* Test successful release of the first buffer */ - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (success 1), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2)); /* Test response to an invalid buffer */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBufInfo), 1, -1); - ActRtn = CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2); - ExpRtn = CFE_SB_BUFFER_INVALID; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (get pool " - "information error), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2), CFE_SB_BUFFER_INVALID); /* Test response to a null message pointer */ - ActRtn = CFE_SB_ZeroCopyReleasePtr(NULL, ZeroCpyBufHndl2); - ExpRtn = CFE_SB_BUFFER_INVALID; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (null " - "message pointer error), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_ZeroCopyReleasePtr(NULL, ZeroCpyBufHndl2), CFE_SB_BUFFER_INVALID); /* Test response to an invalid message pointer */ - ActRtn = CFE_SB_ZeroCopyReleasePtr((CFE_SB_Msg_t *) 0x1234, - ZeroCpyBufHndl2); - ExpRtn = CFE_SB_BUFFER_INVALID; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (invalid " - "message pointer error), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_ZeroCopyReleasePtr((CFE_SB_Msg_t *) 0x1234, + ZeroCpyBufHndl2), CFE_SB_BUFFER_INVALID); /* Test path when return the descriptor to the pool fails in * CFE_SB_ZeroCopyReleaseDesc */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); - ActRtn = CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (return " - "descriptor to buffer error), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2)); /* Test path when return the buffer to the pool fails in * CFE_SB_ZeroCopyReleasePtr */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 2, -1); - ActRtn = CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (return buffer " - "to pool error), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr2, ZeroCpyBufHndl2)); /* Test successful release of the second buffer */ - ActRtn = CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr3, ZeroCpyBufHndl3); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (success 2), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr3, ZeroCpyBufHndl3)); /* Test successful release of the third buffer */ - ActRtn = CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr1, ZeroCpyBufHndl1); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in ZeroCopyReleasePtr test (success 3), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr1, ZeroCpyBufHndl1)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "ZeroCopyReleasePtr test"); + REPORT(); } /* end Test_SendMsg_ZeroCopyReleasePtr */ /* @@ -7199,56 +3656,27 @@ void Test_SendMsg_DisabledDestination(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; CFE_SB_DestinationD_t *DestPtr; int32 PipeDepth; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Send w/Disabled Destination"); -#endif + START(); SB_ResetUnitTest(); PipeDepth = 2; - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); DestPtr = CFE_SB_GetDestPtr(CFE_SB_ConvertMsgIdtoMsgKey(MsgId), PipeId); DestPtr->Active = CFE_SB_INACTIVE; - CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in disabled destination test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Disabled destination test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SendMsg_DisabledDestination */ /* @@ -7271,52 +3699,25 @@ void Test_SendMsg_SendWithMetadata(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPktBufDesc.TlmPkt; int32 PipeDepth; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Send with Metadata (SendMsgFull)"); -#endif + START(); memset(&TlmPktBufDesc, 0, sizeof(TlmPktBufDesc)); SB_ResetUnitTest(); PipeDepth = 2; - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPktBufDesc.TlmPkt, MsgId, sizeof(TlmPktBufDesc.TlmPkt), true); - ActRtn = CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_DO_NOT_INCREMENT, - CFE_SB_SEND_ZEROCOPY); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in send with metadata test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_DO_NOT_INCREMENT, + CFE_SB_SEND_ZEROCOPY)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Send with metadata test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + REPORT(); } /* end Test_SendMsg_SendWithMetadata */ /* @@ -7326,13 +3727,8 @@ void Test_SendMsg_InvalidMsgId_ZeroCopy(void) { SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Message ID (ZeroCopy)"); -#endif + START(); SB_ResetUnitTest(); TlmPktPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), @@ -7346,42 +3742,16 @@ void Test_SendMsg_InvalidMsgId_ZeroCopy(void) { CFE_SB_InitMsg(TlmPktPtr, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, sizeof(SB_UT_Test_Tlm_t), true); - ActRtn = CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, - CFE_SB_SEND_ZEROCOPY); - ExpRtn = CFE_SB_BAD_ARGUMENT; + ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, + CFE_SB_SEND_ZEROCOPY), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid message ID test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_INV_MSGID_EID) == false) - { - UT_Text("CFE_SB_SEND_INV_MSGID_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_INV_MSGID_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Invalid message ID test (ZeroCopy)"); + REPORT(); } /* end Test_SendMsg_InvalidMsgId_ZeroCopy */ /* @@ -7393,13 +3763,8 @@ void Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Maximum Message Size Plus One (ZeroCopy)"); -#endif + START(); SB_ResetUnitTest(); TlmPktPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), @@ -7412,42 +3777,16 @@ void Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy(void) else { CFE_SB_InitMsg(TlmPktPtr, MsgId, CFE_MISSION_SB_MAX_SB_MSG_SIZE + 1, false); - ActRtn = CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, - CFE_SB_SEND_ZEROCOPY); - ExpRtn = CFE_SB_MSG_TOO_BIG; + ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, + CFE_SB_SEND_ZEROCOPY), CFE_SB_MSG_TOO_BIG); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in maximum message size plus one " - "test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_MSG_TOO_BIG_EID) == false) - { - UT_Text("CFE_SB_MSG_TOO_BIG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MSG_TOO_BIG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Maximum message size plus one test (ZeroCopy)"); + REPORT(); } /* end Test_SendMsg_MaxMsgSizePlusOne_ZeroCopy */ /* @@ -7459,13 +3798,8 @@ void Test_SendMsg_NoSubscribers_ZeroCopy(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for No Subscribers (ZeroCopy)"); -#endif + START(); SB_ResetUnitTest(); TlmPktPtr = CFE_SB_ZeroCopyGetPtr(sizeof(SB_UT_Test_Tlm_t), @@ -7478,42 +3812,15 @@ void Test_SendMsg_NoSubscribers_ZeroCopy(void) else { CFE_SB_InitMsg(TlmPktPtr, MsgId, sizeof(SB_UT_Test_Tlm_t), true); - ActRtn = CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, - CFE_SB_SEND_ZEROCOPY); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in no subscribers test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, + CFE_SB_SEND_ZEROCOPY)); } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_SEND_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_NO_SUBS_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "No subscribers test (ZeroCopy)"); + REPORT(); } /* end Test_SendMsg_NoSubscribers_ZeroCopy */ /* @@ -7521,9 +3828,7 @@ void Test_SendMsg_NoSubscribers_ZeroCopy(void) */ void Test_RcvMsg_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_RcvMsg_API"); -#endif + STARTBLOCK(); Test_RcvMsg_InvalidPipeId(); Test_RcvMsg_InvalidTimeout(); @@ -7537,9 +3842,7 @@ void Test_RcvMsg_API(void) Test_RcvMsg_PendForever(); Test_RcvMsg_InvalidBufferPtr(); -#ifdef UT_VERBOSE - UT_Text("End Test_RcvMsg_API\n"); -#endif + ENDBLOCK(); } /* end Test_RcvMsg_API */ /* @@ -7549,49 +3852,20 @@ void Test_RcvMsg_InvalidPipeId(void) { CFE_SB_MsgPtr_t PtrToMsg; CFE_SB_PipeId_t InvalidPipeId = 20; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Rcv - Invalid PipeId Rcv"); -#endif + START(); SB_ResetUnitTest(); CFE_SB.PipeTbl[InvalidPipeId].InUse = CFE_SB_NOT_IN_USE; - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, InvalidPipeId, CFE_SB_POLL); - ExpRtn = CFE_SB_BAD_ARGUMENT; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid pipe ID test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, InvalidPipeId, CFE_SB_POLL), CFE_SB_BAD_ARGUMENT); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_BAD_PIPEID_EID) == false) - { - UT_Text("CFE_SB_BAD_PIPEID_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_BAD_PIPEID_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Invalid pipe ID test"); + REPORT(); } /* end Test_RcvMsg_InvalidPipeId */ /* @@ -7603,51 +3877,21 @@ void Test_RcvMsg_InvalidTimeout(void) CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; int32 TimeOut = -5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Rcv - Invalid Timeout"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut); - ExpRtn = CFE_SB_BAD_ARGUMENT; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid timeout test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_RCV_BAD_ARG_EID); - if (UT_EventIsInHistory(CFE_SB_RCV_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_RCV_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Invalid timeout test"); + REPORT(); } /* end Test_RcvMsg_InvalidTimeout */ /* @@ -7658,50 +3902,21 @@ void Test_RcvMsg_Poll(void) CFE_SB_MsgPtr_t PtrToMsg; CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Poll Receive"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_POLL); - ExpRtn = CFE_SB_NO_MESSAGE; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in poll receive test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_POLL), CFE_SB_NO_MESSAGE); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Poll receive test"); + REPORT(); } /* end Test_RcvMsg_Poll */ /* @@ -7711,51 +3926,21 @@ void Test_RcvMsg_GetLastSenderNull(void) { CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for GetLastSender Null Ptr"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_GetLastSenderId(NULL, PipeId); - ExpRtn = CFE_SB_BAD_ARGUMENT; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetLastSenderId null pointer test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_GetLastSenderId(NULL, PipeId), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_LSTSNDER_ERR1_EID); - if (UT_EventIsInHistory(CFE_SB_LSTSNDER_ERR1_EID) == false) - { - UT_Text("CFE_SB_LSTSNDER_ERR1_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId null pointer test"); + REPORT(); } /* end Test_RcvMsg_GetLastSenderNull */ /* @@ -7767,51 +3952,22 @@ void Test_RcvMsg_GetLastSenderInvalidPipe(void) CFE_SB_PipeId_t InvalidPipeId = 250; CFE_SB_SenderId_t *GLSPtr; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for GetLastSender Invalid Pipe"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_GetLastSenderId(&GLSPtr, InvalidPipeId); - ExpRtn = CFE_SB_BAD_ARGUMENT; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetLastSenderId invalid pipe test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, InvalidPipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_LSTSNDER_ERR2_EID) == false) - { - UT_Text("CFE_SB_LSTSNDER_ERR2_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_LSTSNDER_ERR2_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId invalid pipe test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_RcvMsg_GetLastSenderInvalidPipe */ /* @@ -7823,57 +3979,26 @@ void Test_RcvMsg_GetLastSenderInvalidCaller(void) CFE_SB_SenderId_t *GLSPtr; uint32 PipeDepth = 10; uint32 OrigPipeOwner; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for GetLastSender Invalid Caller"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); /* Change pipe owner ID to execute 'invalid caller' code */ OrigPipeOwner = CFE_SB.PipeTbl[PipeId].AppId; CFE_SB.PipeTbl[PipeId].AppId = OrigPipeOwner + 1; - ActRtn = CFE_SB_GetLastSenderId(&GLSPtr, PipeId); - ExpRtn = CFE_SB_BAD_ARGUMENT; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetLastSenderId invalid caller test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, PipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_GLS_INV_CALLER_EID) == false) - { - UT_Text("CFE_SB_GLS_INV_CALLER_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GLS_INV_CALLER_EID); /* Restore original pipe owner apid */ CFE_SB.PipeTbl[PipeId].AppId = OrigPipeOwner; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId invalid caller test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_RcvMsg_GetLastSenderInvalidCaller */ /* @@ -7884,45 +4009,19 @@ void Test_RcvMsg_GetLastSenderSuccess(void) CFE_SB_PipeId_t PipeId; CFE_SB_SenderId_t *GLSPtr; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for GetLastSender Success"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_GetLastSenderId(&GLSPtr, PipeId); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetLastSenderId Success Test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_GetLastSenderId(&GLSPtr, PipeId)); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId Success Test"); + REPORT(); } /* end Test_RcvMsg_GetLastSenderSuccess */ /* @@ -7934,52 +4033,22 @@ void Test_RcvMsg_Timeout(void) CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; int32 TimeOut = 200; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Timeout Rcv"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, OS_QUEUE_TIMEOUT); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut); - ExpRtn = CFE_SB_TIME_OUT; + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut), CFE_SB_TIME_OUT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in timeout receive test, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Timeout receive test"); + REPORT(); } /* end Test_RcvMsg_Timeout */ /* @@ -7990,51 +4059,21 @@ void Test_RcvMsg_PipeReadError(void) CFE_SB_MsgPtr_t PtrToMsg; CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Pipe Read Error"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, OS_ERROR); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SB_PIPE_RD_ERR; + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_PIPE_RD_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe read error test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(3); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_Q_RD_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_Q_RD_ERR_EID) == false) - { - UT_Text("CFE_SB_Q_RD_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Pipe read error test"); + REPORT(); } /* end Test_RcvMsg_PipeReadError */ /* @@ -8049,77 +4088,30 @@ void Test_RcvMsg_PendForever(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; CFE_SB_PipeD_t *PipeDscPtr; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Pend Forever"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_Subscribe(MsgId, PipeId); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in pend forever test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + SETUP(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from receive in pend forever test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - if (PtrToMsg != NULL) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Received Msg 0x%x", (unsigned int)CFE_SB_GetMsgId(PtrToMsg)); -#ifdef UT_VERBOSE - UT_Text(cMsg); -#endif - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(PtrToMsg != NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); PipeDscPtr = CFE_SB_GetPipePtr(PipeId); PipeDscPtr->ToTrashBuff = PipeDscPtr->CurrentBuff; PipeDscPtr->CurrentBuff = NULL; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Pend forever test"); + + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_RcvMsg_PendForever */ /* @@ -8130,16 +4122,11 @@ void Test_CleanupApp_API(void) CFE_SB_PipeId_t PipeId; CFE_SB_ZeroCopyHandle_t ZeroCpyBufHndl = 0; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for CleanupApp"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); CFE_SB_ZeroCopyGetPtr(PipeDepth, &ZeroCpyBufHndl); CFE_SB_ZeroCopyGetPtr(PipeDepth, &ZeroCpyBufHndl); @@ -8147,53 +4134,25 @@ void Test_CleanupApp_API(void) CFE_SB.PipeTbl[1].InUse = CFE_SB_IN_USE; CFE_SB.PipeTbl[1].AppId = 1; - if (CFE_SB.ZeroCopyTail == NULL) - { - UT_Text("Unexpected ZeroCopyTail UT_GetNumEventsSent, exp = not NULL"); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CFE_SB.ZeroCopyTail != NULL); /* Attempt with a bad application ID first in order to get full branch path * coverage in CFE_SB_ZeroCopyReleaseAppId */ CFE_SB_CleanUpApp(1); - /* Attempt again with a valid application ID */ - CFE_SB_CleanUpApp(0); - - if (CFE_SB.ZeroCopyTail != NULL) - { - UT_Text("Unexpected ZeroCopyTail UT_GetNumEventsSent, exp = NULL"); - TestStat = CFE_FAIL; - } + /* Attempt again with a valid application ID */ + CFE_SB_CleanUpApp(0); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(CFE_SB.ZeroCopyTail == NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from UT_GetNumEventsSent, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_DELETED_EID) == false) - { - UT_Text("CFE_SB_PIPE_DELETED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_DELETED_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CleanupApp_API", "CleanupApp test"); + REPORT(); } /* end Test_CleanupApp_API */ /* @@ -8203,51 +4162,21 @@ void Test_RcvMsg_InvalidBufferPtr(void) { CFE_SB_PipeId_t PipeId; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Rcv - Invalid Buffer Pointer"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_RcvMsg(NULL, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SB_BAD_ARGUMENT; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid buffer pointer test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RcvMsg(NULL, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_RCV_BAD_ARG_EID); - if (UT_EventIsInHistory(CFE_SB_RCV_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_RCV_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Invalid buffer pointer test"); + REPORT(); } /* end Test_RcvMsg_InvalidBufferPtr */ /* @@ -8255,9 +4184,7 @@ void Test_RcvMsg_InvalidBufferPtr(void) */ void Test_SB_Utils(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test for SB Utils"); -#endif + STARTBLOCK(); Test_CFE_SB_InitMsg(); Test_CFE_SB_MsgHdrSize(); @@ -8270,9 +4197,8 @@ void Test_SB_Utils(void) Test_CFE_SB_SetGetCmdCode(); Test_CFE_SB_ChecksumUtils(); Test_CFE_SB_ValidateMsgId(); -#ifdef UT_VERBOSE - UT_Text("End Test for SB Utils\n"); -#endif + + ENDBLOCK(); } /* end Test_SB_Utils */ /* @@ -8280,15 +4206,12 @@ void Test_SB_Utils(void) */ void Test_CFE_SB_InitMsg(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_InitMsg"); -#endif + STARTBLOCK(); Test_CFE_SB_InitMsg_True(); Test_CFE_SB_InitMsg_False(); -#ifdef UT_VERBOSE - UT_Text("End Test_CFE_SB_InitMsg\n"); -#endif + + ENDBLOCK(); } /* end Test_CFE_SB_InitMsg */ /* @@ -8296,29 +4219,25 @@ void Test_CFE_SB_InitMsg(void) */ void Test_CFE_SB_InitMsg_True(void) { - int result; SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; -#ifdef UT_VERBOSE - UT_Text("Begin SB_TestInitMsg_True"); -#endif + START(); SB_ResetUnitTest(); /* Set entire cmd packet to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); CFE_SB_InitMsg(SBCmdPtr, CFE_SB_CMD_MID, sizeof(SBCmd), true); - result = SBCmd.Cmd32Param1 == 0 && + ASSERT_TRUE(SBCmd.Cmd32Param1 == 0 && SBCmd.Cmd16Param1 == 0 && SBCmd.Cmd16Param2 == 0 && SBCmd.Cmd8Param1 == 0 && SBCmd.Cmd8Param2 == 0 && SBCmd.Cmd8Param3 == 0 && - SBCmd.Cmd8Param4 == 0; - UT_Report(__FILE__, __LINE__, - result, "SB_TestInitMsg_True", - "Clear message content"); + SBCmd.Cmd8Param4 == 0); + + REPORT(); } /* end Test_CFE_SB_InitMsg_True */ /* @@ -8326,29 +4245,26 @@ void Test_CFE_SB_InitMsg_True(void) */ void Test_CFE_SB_InitMsg_False(void) { - int result; SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; -#ifdef UT_VERBOSE - UT_Text("Begin SB_TestInitMsg_False"); -#endif + START(); SB_ResetUnitTest(); /* Set entire cmd packet to all f's */ memset(SBCmdPtr, 0xff, sizeof(SBCmd)); - result = SBCmd.Cmd32Param1 == 0xffffffff && + ASSERT_TRUE(SBCmd.Cmd32Param1 == 0xffffffff && SBCmd.Cmd16Param1 == 0xffff && SBCmd.Cmd16Param2 == 0xffff && SBCmd.Cmd8Param1 == 0xff && SBCmd.Cmd8Param2 == 0xff && SBCmd.Cmd8Param3 == 0xff && - SBCmd.Cmd8Param4 == 0xff; + SBCmd.Cmd8Param4 == 0xff); + CFE_SB_InitMsg(SBCmdPtr, CFE_SB_CMD_MID, sizeof(SBCmd), false); - UT_Report(__FILE__, __LINE__, - result, "SB_TestInitMsg_False", - "Leave message content"); + + REPORT(); } /* end Test_CFE_SB_InitMsg_False */ /* @@ -8356,122 +4272,87 @@ void Test_CFE_SB_InitMsg_False(void) */ void Test_CFE_SB_MsgHdrSize(void) { - int32 TestStat; - uint16 ExpectedSize; - uint16 ActualSize; 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; - + PktPtr = (CCSDS_PriHdr_t*)MsgPtr; - -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_MsgHdrSize"); -#endif /* Test for cmds w/sec hdr */ SB_ResetUnitTest(); msgId = SB_UT_CMD_MID; - ExpectedSize = sizeof(CFE_SB_CmdHdr_t); - - CFE_SB_InitMsg(MsgPtr, msgId, sizeof(testCmd), 0); - - + + /* Set this to Command Type */ CCSDS_WR_TYPE(*PktPtr, 1); /* No sec hdr */ CCSDS_WR_SHDR(*PktPtr, 1); - TestStat = CFE_PASS; + ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CFE_SB_CmdHdr_t)); - ActualSize = CFE_SB_MsgHdrSize(MsgPtr); - if (ActualSize != ExpectedSize) - { - TestStat = CFE_FAIL; - } - - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_MsgHdrSize", - "Commands with secondary header"); + REPORT(); /* Test for cmds wo/sec hdr */ + + START(); SB_ResetUnitTest(); - TestStat = CFE_PASS; CFE_SB_InitMsg(MsgPtr, SB_UT_TLM_MID, sizeof(testCmd), 0); - + /* Set this to Command Type */ CCSDS_WR_TYPE(*PktPtr, 1); /* No sec hdr */ CCSDS_WR_SHDR(*PktPtr, 0); - ExpectedSize = sizeof(CCSDS_PriHdr_t); - ActualSize = CFE_SB_MsgHdrSize(MsgPtr); - if (ActualSize != ExpectedSize) - { - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CCSDS_PriHdr_t)); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_MsgHdrSize", - "Commands without secondary header"); + REPORT(); - - MsgPtr = (CFE_SB_MsgPtr_t)&testTlm; - PktPtr = (CCSDS_PriHdr_t*)MsgPtr; + START(); /* Test for tlm w/sec hdr */ SB_ResetUnitTest(); - TestStat = CFE_PASS; + + MsgPtr = (CFE_SB_MsgPtr_t)&testTlm; + PktPtr = (CCSDS_PriHdr_t*)MsgPtr; + CFE_SB_SetMsgId(MsgPtr, SB_UT_TLM_MID); /* Set this to Tlm Type */ CCSDS_WR_TYPE(*PktPtr, 0); CCSDS_WR_SHDR(*PktPtr, 1); - - ExpectedSize = sizeof(CFE_SB_TlmHdr_t); - ActualSize = CFE_SB_MsgHdrSize(MsgPtr); - if (ActualSize != ExpectedSize) - { - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CFE_SB_TlmHdr_t)); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_MsgHdrSize", - "Telemetry with secondary header"); + REPORT(); + START(); /* Test for tlm wo/sec hdr */ SB_ResetUnitTest(); - TestStat = CFE_PASS; + CFE_SB_SetMsgId(MsgPtr, SB_UT_TLM_MID); /* Set this to Telemetry Type */ CCSDS_WR_TYPE(*PktPtr, 0); CCSDS_WR_SHDR(*PktPtr, 0); - - ExpectedSize = sizeof(CCSDS_PriHdr_t); - ActualSize = CFE_SB_MsgHdrSize(MsgPtr); - if (ActualSize != ExpectedSize) - { - TestStat = CFE_FAIL; - } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_MsgHdrSize", - "Telemetry without secondary header"); + ASSERT_EQ(CFE_SB_MsgHdrSize(MsgPtr), sizeof(CCSDS_PriHdr_t)); + + REPORT(); } /* end Test_CFE_SB_MsgHdrSize */ /* @@ -8485,14 +4366,11 @@ void Test_CFE_SB_GetUserData(void) 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 TestStat; uint8 *ActualAdrReturned; uint8 *ExpAdrReturned; CFE_SB_MsgId_t msgId; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_GetUserData"); -#endif + START(); /* Test address returned for cmd pkts w/sec hdr */ SB_ResetUnitTest(); @@ -8501,11 +4379,11 @@ void Test_CFE_SB_GetUserData(void) 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); ActualAdrReturned = CFE_SB_GetUserData(SBCmdPtr); - + if (ActualAdrReturned != ExpAdrReturned) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -8516,9 +4394,7 @@ void Test_CFE_SB_GetUserData(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_GetUserData", - "Command packet with secondary header test"); + REPORT(); /* Test address returned for cmd pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -8538,16 +4414,14 @@ void Test_CFE_SB_GetUserData(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_GetUserData", - "Command packet without secondary header test"); + REPORT(); /* 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) @@ -8560,9 +4434,7 @@ void Test_CFE_SB_GetUserData(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_GetUserData", - "Telemetry packets with secondary header test"); + REPORT(); /* Test address returned for tlm pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -8582,9 +4454,7 @@ void Test_CFE_SB_GetUserData(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_GetUserData", - "Telemetry packets without secondary header test"); + REPORT(); } /* end Test_CFE_SB_GetUserData */ /* @@ -8595,12 +4465,9 @@ void Test_CFE_SB_SetGetMsgId(void) SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; CFE_SB_MsgId_t MsgIdReturned; - uint32 TestStat; uint32 i; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_SetGetMsgId"); -#endif + START(); /* Test setting and getting the message ID of a message */ SB_ResetUnitTest(); @@ -8621,9 +4488,7 @@ void Test_CFE_SB_SetGetMsgId(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetMsgId", - "Get the set message ID test"); + REPORT(); /* Test setting and getting the message ID of a message looping through * all values @@ -8631,20 +4496,19 @@ void Test_CFE_SB_SetGetMsgId(void) SB_ResetUnitTest(); TestStat = CFE_PASS; - + /* Looping through every value from 0 to 0xffff */ for (i = 0; i <= 0xFFFF; i++) { CFE_SB_SetMsgId(SBCmdPtr, i); - + if (CFE_SB_GetMsgId(SBCmdPtr) != i) { break; } } - UT_Report(__FILE__, __LINE__, - i == 0x10000, "Test_CFE_SB_SetGetMsgId", "Loop test"); + REPORT(); } /* end Test_CFE_SB_SetGetMsgId */ /* @@ -8658,27 +4522,25 @@ void Test_CFE_SB_SetGetUserDataLength(void) 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, TestStat; + int32 SetSize; uint16 SizeReturned; int16 ActualPktLenField; int16 ExpPktLenField; CFE_SB_MsgId_t msgId; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_SetGetUserDataLength"); -#endif + 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); - + for (SetSize = 0; SetSize < 0x10000; SetSize++) { CFE_SB_SetUserDataLength(SBCmdPtr, SetSize); @@ -8700,19 +4562,17 @@ void Test_CFE_SB_SetGetUserDataLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetUserDataLength", - "Command packet with secondary header test"); + REPORT(); /* Loop through all pkt length values for cmd pkts wo/sec hdr */ SB_ResetUnitTest(); TestStat = CFE_PASS; - + msgId = SB_UT_TLM_MID; CFE_SB_SetMsgId(SBNoSecHdrPktPtr, msgId); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); - + for (SetSize = 0; SetSize < 0x10000; SetSize++) { CFE_SB_SetUserDataLength(SBNoSecHdrPktPtr, SetSize); @@ -8733,24 +4593,22 @@ void Test_CFE_SB_SetGetUserDataLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetUserDataLength", - "Command packet without secondary header test"); + REPORT(); /* Loop through all pkt length values for tlm pkts w/sec hdr */ SB_ResetUnitTest(); TestStat = CFE_PASS; msgId = SB_UT_TLM_MID; - + CFE_SB_InitMsg(SBTlmPtr, msgId, sizeof(SB_UT_Test_Tlm_t), true); - + for (SetSize = 0; SetSize < 0x10000; SetSize++) { CFE_SB_SetUserDataLength(SBTlmPtr, SetSize); SizeReturned = CFE_SB_GetUserDataLength(SBTlmPtr); ActualPktLenField = UT_GetActualPktLenField(SBTlmPtr); - + ExpPktLenField = sizeof(CCSDS_TelemetryPacket_t) + SetSize - sizeof(CCSDS_PriHdr_t) - 1; /* SecHdrSize + data - 1 */ if (SizeReturned != SetSize || @@ -8766,20 +4624,18 @@ void Test_CFE_SB_SetGetUserDataLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetUserDataLength", - "Telemetry packet with secondary header test"); + REPORT(); /* Loop through all pkt length values for tlm pkts wo/sec hdr */ SB_ResetUnitTest(); TestStat = CFE_PASS; msgId = SB_UT_TLM_MID; - + CFE_SB_SetMsgId(SBNoSecHdrPktPtr, msgId); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); - + for (SetSize = 0; SetSize < 0x10000; SetSize++) { CFE_SB_SetUserDataLength(SBNoSecHdrPktPtr, SetSize); @@ -8800,9 +4656,7 @@ void Test_CFE_SB_SetGetUserDataLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetUserDataLength", - "Telemetry packet without secondary header test"); + REPORT(); } /* end Test_CFE_SB_SetGetUserDataLength */ /* @@ -8816,14 +4670,12 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) 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, TestStat; + int32 SetSize; uint16 TotalMsgSizeReturned; int16 ActualPktLenField; int16 ExpPktLenField; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_SetGetTotalMsgLength"); -#endif + START(); /* CCSDS pkt length field = TotalPktSize - 7 */ @@ -8852,9 +4704,7 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetTotalMsgLength", - "Command packet with secondary header test"); + REPORT(); /* Loop through all pkt length values for cmd pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -8881,9 +4731,7 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetTotalMsgLength", - "Command packet without secondary header test"); + REPORT(); /* Loop through all pkt length values for tlm pkts w/sec hdr */ SB_ResetUnitTest(); @@ -8910,9 +4758,7 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetTotalMsgLength", - "Telemetry packet with secondary header test"); + REPORT(); /* Loop through all pkt length values for tlm pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -8939,9 +4785,7 @@ void Test_CFE_SB_SetGetTotalMsgLength(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetTotalMsgLength", - "Telemetry packet without secondary header test"); + REPORT(); } /* end Test_CFE_SB_SetGetTotalMsgLength */ /* @@ -8956,12 +4800,10 @@ void Test_CFE_SB_SetGetMsgTime(void) SB_UT_TstPktWoSecHdr_t SBNoSecHdrPkt; CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; CFE_TIME_SysTime_t SetTime, GetTime; - int32 RtnFromSet, TestStat; + int32 RtnFromSet; CFE_SB_MsgId_t msgId; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_SetGetMsgTime"); -#endif + START(); /* Begin test for cmd pkts w/sec hdr */ SB_ResetUnitTest(); @@ -8972,7 +4814,7 @@ void Test_CFE_SB_SetGetMsgTime(void) /* Set MsgId */ CFE_SB_SetMsgId(SBCmdPtr, SB_UT_CMD_MID); - + SetTime.Seconds = 0x4321; SetTime.Subseconds = 0x8765; @@ -9005,9 +4847,7 @@ void Test_CFE_SB_SetGetMsgTime(void) UT_DisplayPkt(SBCmdPtr, sizeof(SBCmd)); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetMsgTime", - "Command packet with secondary header test"); + REPORT(); /* Begin test for cmd pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -9019,7 +4859,7 @@ void Test_CFE_SB_SetGetMsgTime(void) /* Set MsgId */ CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); CCSDS_WR_SHDR(*(CCSDS_PriHdr_t*)SBNoSecHdrPktPtr, 0); - + SetTime.Seconds = 0x4321; SetTime.Subseconds = 0x8765; @@ -9052,9 +4892,7 @@ void Test_CFE_SB_SetGetMsgTime(void) UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SB_UT_TstPktWoSecHdr_t)); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetMsgTime", - "Command packet without secondary header test"); + REPORT(); /* Begin test for tlm pkts w/sec hdr */ SB_ResetUnitTest(); @@ -9062,7 +4900,7 @@ void Test_CFE_SB_SetGetMsgTime(void) /* Set MsgId to all f's */ memset(SBTlmPtr, 0xff, sizeof(SBTlm)); - + msgId = SB_UT_TLM_MID; /* Set MsgId to 0x0805 */ @@ -9101,9 +4939,7 @@ void Test_CFE_SB_SetGetMsgTime(void) UT_DisplayPkt(SBTlmPtr, sizeof(SBTlm)); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetMsgTime", - "Telemetry packet with secondary header test"); + REPORT(); /* Begin test for tlm pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -9146,9 +4982,7 @@ void Test_CFE_SB_SetGetMsgTime(void) UT_DisplayPkt(SBNoSecHdrPktPtr, sizeof(SBNoSecHdrPkt)); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetMsgTime", - "Telemetry packet without secondary header test"); + REPORT(); } /* end Test_CFE_SB_SetGetMsgTime */ /* @@ -9160,11 +4994,8 @@ void Test_CFE_SB_TimeStampMsg(void) CFE_SB_MsgPtr_t SBTlmPtr = (CFE_SB_MsgPtr_t) &SBTlm; CFE_TIME_SysTime_t GetTime; uint32 ExpSecs; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_TimeStampMsg"); -#endif + START(); /* Begin test for tlm pkts w/sec hdr */ SB_ResetUnitTest(); @@ -9207,9 +5038,7 @@ void Test_CFE_SB_TimeStampMsg(void) UT_DisplayPkt(SBTlmPtr, sizeof(SB_UT_Test_Tlm_t)); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetMsgTime", - "Telemetry packet with secondary header test"); + REPORT(); } /* end Test_CFE_SB_TimeStampMsg */ /* @@ -9223,16 +5052,14 @@ void Test_CFE_SB_SetGetCmdCode(void) 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 TestStat, RtnFromSet, ExpRtnFrmSet; + int32 RtnFromSet, ExpRtnFrmSet; uint16 CmdCodeSet, CmdCodeReturned; uint8 ActualCmdCodeField; int16 ExpCmdCode; CCSDS_PriHdr_t *PktPtr; CFE_SB_MsgId_t msgId; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_SetGetCmdCode"); -#endif + START(); /* Loop through all cmd code values(plus a few invalid) for cmd * pkts w/sec hdr @@ -9248,13 +5075,13 @@ void Test_CFE_SB_SetGetCmdCode(void) CFE_SB_InitMsg(SBCmdPtr, msgId, sizeof(SB_UT_Test_Cmd_t), true); PktPtr = (CCSDS_PriHdr_t*)SBCmdPtr; - + CCSDS_WR_SHDR(*PktPtr,1); - + for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) { RtnFromSet = CFE_SB_SetCmdCode(SBCmdPtr, CmdCodeSet); - + ExpRtnFrmSet = CFE_SUCCESS; CmdCodeReturned = CFE_SB_GetCmdCode(SBCmdPtr); ActualCmdCodeField = UT_GetActualCmdCodeField(SBCmdPtr); @@ -9279,9 +5106,7 @@ void Test_CFE_SB_SetGetCmdCode(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetCmdCode", - "Command packet with secondary header test"); + REPORT(); /* Loop through all cmd code values (plus a few invalid) for cmd * pkts wo/sec hdr @@ -9294,11 +5119,11 @@ void Test_CFE_SB_SetGetCmdCode(void) /* Set MsgId */ CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); - + PktPtr = (CCSDS_PriHdr_t*)SBNoSecHdrPktPtr; - + CCSDS_WR_SHDR(*PktPtr,0); - + for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) { RtnFromSet = CFE_SB_SetCmdCode(SBNoSecHdrPktPtr, CmdCodeSet); @@ -9324,9 +5149,7 @@ void Test_CFE_SB_SetGetCmdCode(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetCmdCode", - "Command packet without secondary header test"); + REPORT(); /* Loop through all cmd code values (plus a few invalid) for tlm * pkts w/sec hdr @@ -9341,9 +5164,9 @@ void Test_CFE_SB_SetGetCmdCode(void) 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); @@ -9369,9 +5192,7 @@ void Test_CFE_SB_SetGetCmdCode(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetCmdCode", - "Telemetry packet with secondary header test"); + REPORT(); /* Loop through all cmd code values (plus a few invalid) for tlm * pkts wo/sec hdr @@ -9386,9 +5207,9 @@ void Test_CFE_SB_SetGetCmdCode(void) CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); PktPtr = (CCSDS_PriHdr_t*)SBNoSecHdrPktPtr; - + CCSDS_WR_SHDR(*PktPtr,0); - + for (CmdCodeSet = 0; CmdCodeSet < 0x100; CmdCodeSet++) { RtnFromSet = CFE_SB_SetCmdCode(SBNoSecHdrPktPtr, CmdCodeSet); @@ -9414,9 +5235,7 @@ void Test_CFE_SB_SetGetCmdCode(void) } } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_SetGetCmdCode", - "Telemetry packet without secondary header test"); + REPORT(); } /* end Test_CFE_SB_SetGetCmdCode */ /* @@ -9433,11 +5252,8 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_MsgPtr_t SBNoSecHdrPktPtr = (CFE_SB_MsgPtr_t) &SBNoSecHdrPkt; uint16 RtnFrmGet, ExpRtnFrmGet; bool RtnFrmValidate, ExpRtnFrmVal; - int32 TestStat; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_ChecksumUtils"); -#endif + START(); /* Begin test for cmd pkts w/sec hdr */ SB_ResetUnitTest(); @@ -9447,11 +5263,11 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_InitMsg(SBCmdPtr, 0x1805, sizeof(SBCmd), true); CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1805 ); - + /* Set checksum field */ - + CFE_SB_GenerateChecksum(SBCmdPtr); - + RtnFrmGet = CFE_SB_GetChecksum(SBCmdPtr); #ifndef MESSAGE_FORMAT_IS_CCSDS_VER_2 ExpRtnFrmGet = 0x2f; @@ -9479,7 +5295,7 @@ void Test_CFE_SB_ChecksumUtils(void) * return false */ CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1806 ); - + RtnFrmValidate = CFE_SB_ValidateChecksum(SBCmdPtr); ExpRtnFrmVal = false; @@ -9493,9 +5309,7 @@ void Test_CFE_SB_ChecksumUtils(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_ChecksumUtils", - "Command packet with secondary header test"); + REPORT(); /* Begin test for cmd pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -9505,9 +5319,9 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_InitMsg(SBNoSecHdrPktPtr, 0x1005, sizeof(SBNoSecHdrPkt), true); - + CCSDS_WR_SHDR( SBNoSecHdrPktPtr->Hdr, 0 ); - + /* Set checksum field */ CFE_SB_GenerateChecksum(SBNoSecHdrPktPtr); RtnFrmGet = CFE_SB_GetChecksum(SBNoSecHdrPktPtr); @@ -9533,7 +5347,7 @@ void Test_CFE_SB_ChecksumUtils(void) * return false */ CFE_SB_SetMsgId(SBNoSecHdrPktPtr, SB_UT_TLM_MID); - + CCSDS_WR_SHDR( SBCmdPtr->Hdr, 0 ); RtnFrmValidate = CFE_SB_ValidateChecksum(SBNoSecHdrPktPtr); ExpRtnFrmVal = false; @@ -9548,9 +5362,7 @@ void Test_CFE_SB_ChecksumUtils(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_ChecksumUtils", - "Command packet without secondary header test"); + REPORT(); /* Begin test for tlm pkts w/sec hdr */ SB_ResetUnitTest(); @@ -9596,9 +5408,7 @@ void Test_CFE_SB_ChecksumUtils(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_ChecksumUtils", - "Telemetry packet with secondary header test"); + REPORT(); /* Begin test for tlm pkts wo/sec hdr */ SB_ResetUnitTest(); @@ -9646,40 +5456,33 @@ void Test_CFE_SB_ChecksumUtils(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_ChecksumUtils", - "Telemetry packet without secondary header test"); + REPORT(); } /* end Test_CFE_SB_ChecksumUtils */ - /* ** Test validating a msg id */ void Test_CFE_SB_ValidateMsgId(void) { - CFE_SB_MsgId_t MsgId; - uint32 ActualReturn; + + START(); SB_ResetUnitTest(); - + /* Validate Msg Id */ MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; - ActualReturn = CFE_SB_ValidateMsgId(MsgId); + CFE_SB_ValidateMsgId(MsgId); + + REPORT(); + + START(); - UT_Report(__FILE__, __LINE__, - ActualReturn == CFE_SUCCESS, - "CFE_SB_ValidateMsgId", - "Testing validation for a valid MsgId"); - /* Test for invalid msg id */ MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; - ActualReturn = CFE_SB_ValidateMsgId(MsgId); - - UT_Report(__FILE__, __LINE__, - ActualReturn == CFE_SB_FAILED, - "CFE_SB_ValidateMsgId", - "Testing validation for an invalid MsgId"); + CFE_SB_ValidateMsgId(MsgId); + + REPORT(); } /* @@ -9687,6 +5490,8 @@ void Test_CFE_SB_ValidateMsgId(void) */ void Test_SB_SpecialCases(void) { + STARTBLOCK(); + Test_OS_MutSem_ErrLogic(); Test_ReqToSendEvent_ErrLogic(); Test_PutDestBlk_ErrLogic(); @@ -9697,8 +5502,9 @@ void Test_SB_SpecialCases(void) Test_RcvMsg_UnsubResubPath(); Test_MessageString(); Test_SB_IdxPushPop(); -} /* end Test_SB_SpecialCases */ + ENDBLOCK(); +} /* end Test_SB_SpecialCases */ /* ** Test msg key idx push pop @@ -9706,52 +5512,25 @@ void Test_SB_SpecialCases(void) void Test_SB_IdxPushPop() { int32 i; - int32 ExpRtn; - int32 ActRtn; CFE_SB_MsgRouteIdx_t Idx; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test Test_SB_IdxPushPop"); -#endif - + + START(); + SB_ResetUnitTest(); CFE_SB_InitIdxStack(); - + for (i = 0; i < CFE_PLATFORM_SB_MAX_MSG_IDS; i++) { /* Subscribe to maximum number of messages */ Idx = CFE_SB_RouteIdxPop_Unsync(); - ActRtn = CFE_SB_RouteIdxToValue(Idx); - ExpRtn = i; - if (ExpRtn != ActRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Pop ExpRtn (%d) != ActRtn(%d)", - (int)ExpRtn, (int)ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RouteIdxToValue(Idx), i); } - + Idx = CFE_SB_RouteIdxPop_Unsync(); - ActRtn = CFE_SB_RouteIdxToValue(Idx); - ExpRtn = CFE_SB_RouteIdxToValue(CFE_SB_INVALID_ROUTE_IDX); - - if (ExpRtn != ActRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Pop ExpRtn (%d) != ActRtn(%d)", - (int)ExpRtn, (int)ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_IdxPop_Unsync", - "Popped all subscription indexes"); + 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 @@ -9765,34 +5544,11 @@ void Test_SB_IdxPushPop() { /* Un-subscribe from all messages */ CFE_SB_RouteIdxPush_Unsync(CFE_SB_ValueToRouteIdx(i)); - ActRtn = CFE_SUCCESS; - ExpRtn = CFE_SUCCESS; - if (ExpRtn != ActRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Push ExpRtn (%d) != ActRtn(%d)", - (int)ExpRtn, (int)ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } } - + CFE_SB_RouteIdxPush_Unsync(CFE_SB_ValueToRouteIdx(i)); - ActRtn = CFE_SUCCESS; - ExpRtn = CFE_SUCCESS; - - if (ExpRtn != ActRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Push ExpRtn (%d) != ActRtn(%d)", - (int)ExpRtn, (int)ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_IdxPush_Unsync", - "Pushed all un-subscription indexes"); + + REPORT(); } /* end Test_SB_IdxPushPop */ @@ -9804,47 +5560,24 @@ void Test_OS_MutSem_ErrLogic(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test Shared Semaphore Give/Take Failure"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, CFE_OS_SEM_FAILURE); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 2, CFE_OS_SEM_FAILURE); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_(Un)LockSharedData", - "Semaphore give/take failure test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_OS_MutSemTake_ErrLogic */ /* @@ -9854,13 +5587,8 @@ void Test_ReqToSendEvent_ErrLogic(void) { uint32 TaskId = 13; uint32 Bit = 5; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test ReqToSendEvent Error"); -#endif + START(); SB_ResetUnitTest(); @@ -9868,48 +5596,16 @@ void Test_ReqToSendEvent_ErrLogic(void) * the specified task */ CFE_SB.StopRecurseFlags[TaskId] = 0x0000; - ExpRtn = CFE_SB_GRANTED; - ActRtn = CFE_SB_RequestToSendEvent(TaskId, Bit); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn when bit not set, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RequestToSendEvent(TaskId, Bit), CFE_SB_GRANTED); /* Call the function a second time; the result should indicate that the * bit is already set */ - ExpRtn = CFE_SB_DENIED; - ActRtn = CFE_SB_RequestToSendEvent(TaskId, Bit); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn when bit set, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_RequestToSendEvent(TaskId, Bit), CFE_SB_DENIED); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_RequestToSendEvent", - "Request to send event error test"); + REPORT(); } /* end Test_ReqToSendEvent_ErrLogic */ /* @@ -9918,42 +5614,14 @@ void Test_ReqToSendEvent_ErrLogic(void) */ void Test_PutDestBlk_ErrLogic(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test PutDestBlk Error"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_PutDestinationBlk(NULL); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_PutDestinationBlk(NULL), CFE_SB_BAD_ARGUMENT); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_PutDestinationBlk", - "PutDestBlk error test"); + REPORT(); } /* end Test_PutDestBlk_ErrLogic */ /* @@ -9961,44 +5629,16 @@ void Test_PutDestBlk_ErrLogic(void) */ void Test_CFE_SB_GetPipeIdx(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test GetPipeIdx"); -#endif + START(); SB_ResetUnitTest(); CFE_SB.PipeTbl[0].PipeId = 0; CFE_SB.PipeTbl[0].InUse = CFE_SB_NOT_IN_USE; - ExpRtn = CFE_SB_INVALID_PIPE; - ActRtn = CFE_SB_GetPipeIdx(0); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_GetPipeIdx(0), CFE_SB_INVALID_PIPE); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeIdx", - "GetPipeIdx branch path coverage test"); + REPORT(); } /* end Test_CFE_SB_GetPipeIdx */ /* @@ -10006,139 +5646,55 @@ void Test_CFE_SB_GetPipeIdx(void) */ void Test_CFE_SB_Buffers(void) { - int32 ExpRtn = sizeof(CFE_SB_BufferD_t) * 4; - int32 ActRtn; - int32 TestStat = CFE_PASS; + int32 ExpRtn; + CFE_SB_BufferD_t *bd; -#ifdef UT_VERBOSE - UT_Text("Begin Test GetBufferFromPool"); -#endif + START(); SB_ResetUnitTest(); CFE_SB.StatTlmMsg.Payload.MemInUse = 0; - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = ExpRtn; + CFE_SB.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_BufferD_t) * 4; bd = CFE_SB_GetBufferFromPool(0, 0); - ActRtn = CFE_SB.StatTlmMsg.Payload.PeakMemInUse; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected PeakmemInUse value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.PeakMemInUse, sizeof(CFE_SB_BufferD_t) * 4); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetBufferFromPool", - "GetBufferFromPool branch path coverage test"); + START(); - TestStat = CFE_PASS; ExpRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_ReturnBufferToPool(bd); - ActRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected SBBuffersInUse value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.SBBuffersInUse, ExpRtn); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ReturnBufferToPool", - "ReturnBufferToPool branch path coverage test"); + START(); - TestStat = CFE_PASS; - ExpRtn = 0; bd->UseCount = 0; CFE_SB_DecrBufUseCnt(bd); - ActRtn = bd->UseCount; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected UseCount value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(bd->UseCount, 0); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_DecrBufUseCnt", - "DecrBufUseCnt branch path coverage test"); + START(); - TestStat = CFE_PASS; - ExpRtn = 0; UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB.StatTlmMsg.Payload.MemInUse = 0; CFE_SB_PutDestinationBlk((CFE_SB_DestinationD_t *) bd); - ActRtn = CFE_SB.StatTlmMsg.Payload.MemInUse; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected MemInUse value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.MemInUse, 0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_PutDestinationBlk", - "PutDestinationBlk branch path coverage test"); + REPORT(); } /* end Test_CFE_SB_Buffers */ /* @@ -10148,83 +5704,35 @@ void Test_CFE_SB_BadPipeInfo(void) { CFE_SB_PipeId_t PipeId; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; CFE_SB_Qos_t CFE_SB_Default_Qos; -#ifdef UT_VERBOSE - UT_Text("Begin Test BadPipeInfo"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1")); /* Set the pipe ID to an erroneous value and attempt to delete the pipe */ CFE_SB.PipeTbl[0].PipeId = 1; CFE_SB.PipeTbl[0].InUse = 1; - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_DeletePipeFull(0, 0); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_DeletePipeFull(0, 0), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_DeletePipeFull", - "DeletePipeFull bad pipe information branch path coverage test"); + START(); /* Reset the pipe ID and delete the pipe */ CFE_SB.PipeTbl[0].PipeId = 0; - TestStat = CFE_PASS; - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_SubscribeFull(0 ,0, CFE_SB_Default_Qos, - CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, 2); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SubscribeFull(0 ,0, CFE_SB_Default_Qos, + CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, 2), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - CFE_SB_DeletePipe(PipeId); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SubscribeFull", - "SubscribeFull bad pipe information branch path coverage test"); + REPORT(); } /* end Test_CFE_SB_BadPipeInfo */ /* @@ -10239,13 +5747,8 @@ void Test_SB_SendMsgPaths(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; int32 PipeDepth = 2; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for SendMsgFull paths"); -#endif + START(); /* Test inhibiting sending a "no subscriptions for a message ID" message */ SB_ResetUnitTest(); @@ -10255,11 +5758,7 @@ void Test_SB_SendMsgPaths(void) CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_SEND_NO_SUBS_EID_BIT); CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID) == true) - { - UT_Text("CFE_SB_SEND_NO_SUBS_EID sent"); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID)); CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter = 0; CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_GET_BUF_ERR_EID_BIT); @@ -10267,37 +5766,11 @@ void Test_SB_SendMsgPaths(void) CFE_SB.MsgMap[CFE_SB_MsgKeyToValue(CFE_SB_ConvertMsgIdtoMsgKey(MsgId))] = CFE_SB_INVALID_ROUTE_IDX; UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 1, CFE_ES_ERR_MEM_BLOCK_SIZE); CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 0; - ActRtn = CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected MsgSendErrorCounter in send no subs test, " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_GET_BUF_ERR_EID) == true) - { - UT_Text("CFE_SB_GET_BUF_ERR_EID sent"); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB.HKTlmMsg.Payload.MsgSendErrorCounter, 0); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_GET_BUF_ERR_EID)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (send no subs), " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); CFE_SB.StopRecurseFlags[1] = 0; @@ -10305,212 +5778,103 @@ void Test_SB_SendMsgPaths(void) MsgId = SB_UT_CMD_MID; SB_ResetUnitTest(); CFE_SB.SenderReporting = 0; - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in cmd as tlm test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (cmd as tlm), " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - CFE_SB_DeletePipe(PipeId); + 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); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); /* Set maximum allowed messages on the pipe at one time to 1 */ - CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1); + SETUP(CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1)); /* First send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe message limit test 1, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_MSGID_LIM_ERR_EID_BIT); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] = 0; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe message limit test 2, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_MSGID_LIM_ERR_EID)); - if (UT_EventIsInHistory(CFE_SB_MSGID_LIM_ERR_EID) == true) - { - UT_Text("CFE_SB_MSGID_LIM_ERR_EID sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); + REPORT(); + + START(); /* Test inhibiting sending a "pipe full" message */ SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* This send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return1 in pipe full test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); /* Tell the QueuePut stub to return OS_QUEUE_FULL on its next call */ UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_QUEUE_FULL); CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_FULL_ERR_EID_BIT); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] = 0; - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return2 in pipe full test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_Q_FULL_ERR_EID_BIT)); - if (UT_EventIsInHistory(CFE_SB_Q_FULL_ERR_EID_BIT) == true) - { - UT_Text("CFE_SB_Q_FULL_ERR_EID_BIT sent"); - TestStat = CFE_FAIL; - } + EVTCNT(3); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (pipe full), " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - CFE_SB_DeletePipe(PipeId); + START(); /* Test inhibiting sending a "pipe write error" message */ SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_ERROR); CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_WR_ERR_EID_BIT); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] = 0; - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in n pipe write error error test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_Q_WR_ERR_EID)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (pipe write " - "error), exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (UT_EventIsInHistory(CFE_SB_Q_WR_ERR_EID) == true) - { - UT_Text("CFE_SB_Q_WR_ERR_EID sent"); - TestStat = CFE_FAIL; - } + REPORT(); - CFE_SB_DeletePipe(PipeId); - + START(); /* Setup Test skipping sending to a pipe when the pipe option is set to ignore */ SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "SkipPipe"); - CFE_SB_Subscribe(MsgId, PipeId); - CFE_SB_SetPipeOpts(PipeId, CFE_SB_PIPEOPTS_IGNOREMINE); - + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SkipPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + SETUP(CFE_SB_SetPipeOpts(PipeId, CFE_SB_PIPEOPTS_IGNOREMINE)); + /* Test skipping this pipe and the send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return1 in pipe ignore test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - CFE_SB_SetPipeOpts(PipeId, 0); - CFE_SB_DeletePipe(PipeId); - - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendMsgFull", - "Send message paths test"); + TEARDOWN(CFE_SB_SetPipeOpts(PipeId, 0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SB_SendMsgPaths */ /* @@ -10525,77 +5889,27 @@ void Test_RcvMsg_UnsubResubPath(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe/Resubscribe Path"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_Subscribe(MsgId, PipeId); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in unsub/resub path test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - CFE_SB_Unsubscribe(MsgId, PipeId); - CFE_SB_Subscribe(MsgId, PipeId); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + SETUP(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from receive in unsub/resub path test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (PtrToMsg != NULL) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Received Msg 0x%x", - (unsigned int) CFE_SB_GetMsgId(PtrToMsg)); -#ifdef UT_VERBOSE - UT_Text(cMsg); -#endif - } + ASSERT_TRUE(PtrToMsg != NULL); - ExpRtn = 6; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(6); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_RcvMsg", "Unsubscribe/resubscribe path test"); + REPORT(); } /* end Test_RcvMsg_UnsubResubPath */ /* @@ -10670,5 +5984,3 @@ void Test_MessageString(void) "CFE_SB_MessageStringGet", "Destination size < source string size"); } /* end Test_MessageString */ - - diff --git a/fsw/cfe-core/unit-test/sb_UT.h b/fsw/cfe-core/unit-test/sb_UT.h index b07154e30..5ac4d5f0a 100644 --- a/fsw/cfe-core/unit-test/sb_UT.h +++ b/fsw/cfe-core/unit-test/sb_UT.h @@ -48,12 +48,6 @@ #include "common_types.h" #include "ut_support.h" -/* -** Macro definitions -*/ -#define CFE_FAIL 0 -#define CFE_PASS 1 - /* ** Structures */ diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index f1a363716..33ce8126e 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -693,3 +693,145 @@ 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) +{ +#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; +} + +void UT_REPORT_impl(const char *FileName, int LineNum, const char *TestName) +{ + UT_Report(FileName, LineNum, TestStat, TestName, "Report"); +} + +bool UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + char cMsg[UT_MAX_MESSAGE_LENGTH]; + + if(FnRet != CFE_SUCCESS) + { + 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; + } + return true; +} + +bool UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + char cMsg[UT_MAX_MESSAGE_LENGTH]; + + 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; +} + +bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, + 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; +} + +bool 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; +} + +bool 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; +} + +bool UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet) +{ + 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; +} + +void UT_ENDBLOCK_impl(const char *FileName, int LineNum, const char *TestName) +{ +#ifdef VERBOSE + snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) End Block", TestName, FileName, LineNum); + UT_Text(); +#endif /* VERBOSE */ +} diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 1c8d8b1bd..25afc12df 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -687,4 +687,261 @@ 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. +** +** \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. +** +** \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. +** +** \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__) + +/** \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); + +/*****************************************************************************/ +/** +** \brief Checks the successful execution of a setup function. +** +** \par Description +** Many tests require a number of steps of setup to configure CFE such +** that the actual test can be performed. Failure of any setup steps +** result in a text message and the test being considered failed. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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) + +/** \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); + +/*****************************************************************************/ +/** +** \brief Asserts the nominal execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the nominal execution of the +** function; the expectation is that it will return CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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) + +/** \brief Function to be called by the ASSERT_EQ() macro */ +bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, + const char *FnName, int32 FnRet, const char *ExpName, int32 Exp); + +/*****************************************************************************/ +/** +** \brief Asserts the expected execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the execution of the function +** and comparing the return status against the expected return status specified, +** when the return status expected is not CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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) + +/** \brief Function to be called by the ASSERT_EQ() macro */ +bool UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, + const char *ExpName, bool Exp); + +/*****************************************************************************/ +/** +** \brief Asserts the expected execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the execution of the function +** and comparing the return status against the expected return status specified, +** when the return status expected is not CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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) + +/** \brief Function to be called by the EVTCNT() macro */ +bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp); + +/*****************************************************************************/ +/** +** \brief Ensures that the test generated the expected number of events. +** +** \par Description +** Most tests will generate a number of events, and the number generated +** should be checked via this macro. If the number of events is different, +** the test is considered to have failed and an error is reported. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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) + +/** \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); + +/*****************************************************************************/ +/** +** \brief Ensures that the test generated the expected event. +** +** \par Description +** Most tests will generate a number of events, and this function and macro check whether an +** event was generated. If not, the test is considered to have failed and an error is reported. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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) + +/** \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); +/*****************************************************************************/ +/** +** \brief Checks the successful execution of a teardown function. +** +** \par Description +** Many tests require a number of steps of setup to configure CFE such that the actual test +** can be performed, and undoing that configuration is the role of the teardown steps. Failure +** of any teardown steps result in a text message and the test being considered failed. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \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__) + #endif /* __UT_STUBS_H_ */ From cc11de4f8d12de3a5f914ac4f460e835ba7580a5 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Fri, 8 May 2020 13:51:57 -0700 Subject: [PATCH 2/2] missed one MID change --- fsw/cfe-core/unit-test/sb_UT.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index 5fc734a52..3498caaa3 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -2893,7 +2893,7 @@ void Test_Unsubscribe_Local(void) SETUP(CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe")); SETUP(CFE_SB_Subscribe(MsgId, TestPipe)); - ASSERT(CFE_SB_UnsubscribeLocal(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID, TestPipe)); + ASSERT(CFE_SB_UnsubscribeLocal(SB_UT_LAST_VALID_MID, TestPipe)); EVTCNT(5);