diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index b7c327072..3498caaa3 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -126,196 +126,118 @@ 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 */ void Test_SB_CCSDSSecHdr_Macros(void) { - CCSDS_CommandPacket_t NoParamPkt; - - uint32 ExpRtn; - uint32 ActRtn; - uint32 TestStat = CFE_PASS; + CFE_SB_CmdHdr_t NoParamPkt; -#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 */ /* @@ -324,172 +246,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 */ /* @@ -509,9 +353,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(); @@ -522,9 +364,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 */ /* @@ -532,44 +372,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; - } - - 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_AppInit", "ES_RegisterApp failure"); + REPORT(); } /* end Test_SB_AppInit_ESRegFail */ /* @@ -577,43 +390,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; - } - - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - 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 */ /* @@ -621,15 +408,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(); @@ -645,33 +427,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(); + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - 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; - } - - ExpRtn = 7; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(7); - 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 */ /* @@ -679,13 +441,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(); @@ -693,40 +449,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; - } + EVTCNT(1); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTSENT(CFE_SB_CR_PIPE_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; - } - - 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 */ /* @@ -735,50 +464,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 */ /* @@ -787,50 +486,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; - } - - 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_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 2 failure"); + REPORT(); } /* end Test_SB_AppInit_Sub2Fail */ /* @@ -839,45 +508,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(); - UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 4, ForcedRtnVal); - ExpRtn = ForcedRtnVal; - ActRtn = CFE_SB_AppInit(); + SB_ResetUnitTest(); + UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 3, ForcedRtnVal); - 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 = 7; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(7); - 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 */ /* @@ -886,45 +530,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 = 7; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(7); - 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 */ /* @@ -932,16 +551,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 */ /* @@ -950,44 +565,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 = 10; - 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(10); - 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 */ /* @@ -996,32 +589,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 = 7; - 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(7); - 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 */ /* @@ -1029,9 +607,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(); @@ -1069,9 +645,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 */ /* @@ -1080,40 +654,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_NOOP_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; 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 */ /* @@ -1122,40 +676,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_RESET_COUNTERS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; 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 */ /* @@ -1164,46 +698,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_SEND_SB_STATS_CC); - CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; - 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; - } + CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; + CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_SND_STATS_EID) == false) - { - UT_Text("CFE_SB_SND_STATS_EID not sent"); - 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); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send SB Stats command test"); + EVTSENT(CFE_SB_SND_STATS_EID); + + REPORT(); } /* end Test_SB_Cmds_Stats */ /* @@ -1213,13 +723,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -1229,61 +734,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 = 12; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(12); - 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 */ /* @@ -1292,44 +761,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_ValueToMsgId(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 */ /* @@ -1338,13 +787,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -1356,28 +800,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 */ /* @@ -1385,50 +815,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 */ /* @@ -1438,83 +836,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 = 11; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(11); - 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 */ /* @@ -1527,13 +873,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -1543,41 +884,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 */ /* @@ -1586,13 +909,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -1602,27 +920,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 */ /* @@ -1630,50 +933,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; - } - - 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_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 */ /* @@ -1681,50 +951,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 */ /* @@ -1737,62 +974,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 */ /* @@ -1811,13 +1015,8 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6; 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_ValueToMsgId(CFE_SB_CMD_MID), @@ -1826,55 +1025,34 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_SEND_MAP_INFO_CC); 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); - 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; - } + /* Create some map info */ + 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; - 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 */ /* @@ -1883,13 +1061,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -1899,27 +1072,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 */ /* @@ -1927,50 +1085,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 */ /* @@ -1978,50 +1103,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; - } - - 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_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 */ /* @@ -2040,77 +1132,39 @@ void Test_SB_Cmds_MapInfoWriteFail(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID6; 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 */ /* @@ -2122,17 +1176,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2140,41 +1189,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 */ /* @@ -2187,18 +1215,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2206,42 +1229,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 */ /* @@ -2250,13 +1250,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -2266,28 +1261,14 @@ void Test_SB_Cmds_EnRouteInvParam(void) EnDisRouteCmd.Payload.MsgId = SB_UT_LAST_VALID_MID; 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 */ /* @@ -2296,13 +1277,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -2312,28 +1288,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 */ /* @@ -2343,13 +1305,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -2359,28 +1316,14 @@ void Test_SB_Cmds_EnRouteInvParam3(void) EnDisRouteCmd.Payload.MsgId = SB_UT_ALTERNATE_INVALID_MID; 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 */ /* @@ -2392,17 +1335,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2411,40 +1349,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 */ /* @@ -2456,18 +1372,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnDisRouteCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &EnDisRouteCmd, @@ -2475,42 +1386,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 */ /* @@ -2519,13 +1407,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -2535,28 +1418,14 @@ void Test_SB_Cmds_DisRouteInvParam(void) EnDisRouteCmd.Payload.MsgId = SB_UT_LAST_VALID_MID; 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 */ /* @@ -2565,13 +1434,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -2581,28 +1445,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 */ /* @@ -2612,13 +1462,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_ValueToMsgId(CFE_SB_CMD_MID), @@ -2628,28 +1473,14 @@ void Test_SB_Cmds_DisRouteInvParam3(void) EnDisRouteCmd.Payload.MsgId = SB_UT_ALTERNATE_INVALID_MID; 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 */ /* @@ -2658,13 +1489,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_ValueToMsgId(CFE_SB_SEND_HK_MID), @@ -2672,27 +1498,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 */ /* @@ -2709,20 +1520,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_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), sizeof(CFE_SB_SendPrevSubs_t), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_SEND_PREV_SUBS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; - 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 */ @@ -2739,102 +1545,43 @@ void Test_SB_Cmds_SendPrevSubs(void) if (i != CFE_SB_ALLSUBS_TLM_MID) { NumEvts += 2; - ActRtn = CFE_SB_Subscribe(CFE_SB_ValueToMsgId(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; - } + SETUP(CFE_SB_Subscribe(CFE_SB_ValueToMsgId(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(); - 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; - } + NumEvts += 8; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */ + EVTCNT(NumEvts); /* 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(CFE_SB_ValueToMsgId(i), PipeId1); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(i, PipeId1)); 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; - } } - 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=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim)); + CFE_SB_ProcessCmdPipePkt(); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + NumEvts += 8; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */ - if (UT_EventIsInHistory(CFE_SB_SEND_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_SEND_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(NumEvts); - if (UT_EventIsInHistory(CFE_SB_FULL_SUB_PKT_EID) == false) - { - UT_Text("CFE_SB_FULL_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); - if (UT_EventIsInHistory(CFE_SB_PART_SUB_PKT_EID) == false) - { - UT_Text("CFE_SB_PART_SUB_PKT_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", - "Send previous subscriptions test"); + REPORT(); } /* end Test_SB_Cmds_SendPrevSubs */ /* @@ -2843,13 +1590,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_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), @@ -2858,21 +1600,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 */ /* @@ -2881,13 +1612,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_ValueToMsgId(CFE_SB_SUB_RPT_CTRL_MID), @@ -2896,21 +1622,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 */ /* @@ -2919,13 +1634,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(NoParamCmd), true); @@ -2960,27 +1670,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 */ /* @@ -2992,9 +1687,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_ValueToMsgId(CFE_SB_CMD_MID), sizeof(EnableRouteCmd) - 1, true); @@ -3003,27 +1695,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 */ /* @@ -3033,39 +1710,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 */ /* @@ -3073,17 +1730,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 */ /* @@ -3091,9 +1744,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); @@ -3107,9 +1758,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); @@ -3123,9 +1772,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(); @@ -3139,9 +1786,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(); @@ -3149,9 +1794,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 */ /* @@ -3160,52 +1803,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 */ /* @@ -3214,64 +1827,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; - } - - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + 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")); - 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 */ /* @@ -3280,63 +1854,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 */ /* @@ -3346,62 +1881,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 */ /* @@ -3413,12 +1925,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(); @@ -3427,55 +1935,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); + + ASSERT_EQ(PipeId, FirstPipeId); - if (status == CFE_SUCCESS) - { - UT_Text("Second call to CFE_SB_CreatePipe() passed unexpectedly"); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (PipeId != FirstPipeId) - { - UT_Text("Second call to CFE_SB_CreatePipe() modified the PipeId"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CR_PIPE_NAME_TAKEN_EID); /* Call to CFE_SB_DeletePipe with the first pipe id created should work fine */ - status = CFE_SB_DeletePipe(PipeId); - - if (status != CFE_SUCCESS) - { - UT_Text("Failed to delete pipe"); - TestStat = CFE_FAIL; - } + 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(); @@ -3483,9 +1967,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 */ /* @@ -3495,55 +1977,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; - } - - 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; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); + 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(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 */ /* @@ -3557,59 +2003,23 @@ void Test_DeletePipe_WithSubs(void) CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID3; CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID4; 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; - } + 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)); - 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; - } - - 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 */ /* @@ -3618,48 +2028,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 */ /* @@ -3670,71 +2050,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; + ASSERT_EQ(CFE_SB_DeletePipe(PipedId), 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; - } - - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - - 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(2); - 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 */ /* @@ -3743,53 +2080,23 @@ void Test_DeletePipe_InvalidPipeOwner(void) void Test_DeletePipe_WithAppid(void) { CFE_SB_PipeId_t PipedId; - CFE_SB_MsgId_t MsgId0 = SB_UT_CMD_MID1; - CFE_SB_MsgId_t MsgId1 = SB_UT_CMD_MID2; - CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID3; - CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID4; - 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 + 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_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; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID1, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID2, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID3, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID4, PipedId)); - ExpRtn = 14; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_DeletePipeWithAppId(PipedId, AppId)); - 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(14); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", "With app ID test"); + REPORT(); } /* end Test_DeletePipe_WithAppid */ /* @@ -3797,9 +2104,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(); @@ -3808,9 +2113,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 */ /* @@ -3818,17 +2121,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 */ /* @@ -3836,33 +2135,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 + START(); - 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; - } - - 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 */ /* @@ -3870,36 +2149,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 */ /* @@ -3907,8 +2166,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; @@ -3916,52 +2173,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 */ /* @@ -3969,17 +2196,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 */ /* @@ -3987,52 +2210,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"); + START(); - TestStat = CFE_FAIL; - } - - 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 */ /* @@ -4040,34 +2229,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 */ /* @@ -4075,26 +2244,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), @@ -4102,29 +2255,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 */ /* @@ -4132,31 +2269,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 - - 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; - } - - if (UT_EventIsInHistory(CFE_SB_SETPIPEOPTS_ID_ERR_EID) == false) - { - UT_Text("CFE_SB_SETPIPEOPTS_ID_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + START(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SetPipeOpts", - "Set pipe opts with invalid ID test"); + ASSERT_EQ(CFE_SB_SetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, 0), CFE_SB_BAD_ARGUMENT); + + EVTSENT(CFE_SB_SETPIPEOPTS_ID_ERR_EID); + + REPORT(); } /* end Test_SetPipeOpts_BadID */ /* @@ -4164,55 +2283,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 */ /* @@ -4220,47 +2311,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 */ /* @@ -4268,32 +2331,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 */ /* @@ -4301,49 +2347,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 */ /* @@ -4351,60 +2367,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(); @@ -4420,9 +2404,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 */ /* @@ -4435,55 +2417,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); - - 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; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - 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 */ /* @@ -4493,48 +2442,17 @@ void Test_Subscribe_InvalidPipeId(void) { CFE_SB_PipeId_t PipeId = 2; CFE_SB_MsgId_t MsgId = SB_UT_ALTERNATE_INVALID_MID; - 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 */ /* @@ -4545,51 +2463,21 @@ void Test_Subscribe_InvalidMsgId(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_ALTERNATE_INVALID_MID; 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 */ /* @@ -4602,52 +2490,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 */ /* @@ -4658,64 +2516,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); - - 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; - } + ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); + ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); - 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 */ /* @@ -4727,51 +2543,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); - - 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; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - 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 */ /* @@ -4784,14 +2569,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(); @@ -4799,75 +2578,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 */ /* @@ -4880,56 +2617,34 @@ 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(CFE_SB_ValueToMsgId(i), PipeId2); - if (i < CFE_PLATFORM_SB_MAX_MSG_IDS) { - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(CFE_SB_ValueToMsgId(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(CFE_SB_ValueToMsgId(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 */ /* @@ -4944,59 +2659,40 @@ void Test_Subscribe_SendPrevSubs(void) CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3; 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 */ /* @@ -5012,66 +2708,35 @@ void Test_Subscribe_FindGlobalMsgIdCnt(void) CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID3; 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 */ /* @@ -5081,49 +2746,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 */ /* @@ -5135,122 +2769,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 */ /* @@ -5262,27 +2809,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; @@ -5290,30 +2821,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 */ /* @@ -5321,9 +2838,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(); @@ -5335,9 +2850,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 */ /* @@ -5348,51 +2861,21 @@ void Test_Unsubscribe_Basic(void) CFE_SB_PipeId_t TestPipe; CFE_SB_MsgId_t MsgId = SB_UT_INTERMEDIATE_VALID_MID; 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 */ /* @@ -5403,52 +2886,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(SB_UT_LAST_VALID_MID, 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(SB_UT_LAST_VALID_MID, 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 */ /* @@ -5459,112 +2912,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(SB_UT_ALTERNATE_INVALID_MID, 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(SB_UT_ALTERNATE_INVALID_MID, 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(SB_UT_FIRST_VALID_MID, TestPipe, CFE_SB_LOCAL + 1, - CallerId); + /* Perform test using a bad scope value */ + ASSERT_EQ(CFE_SB_UnsubscribeFull(SB_UT_FIRST_VALID_MID, 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(SB_UT_FIRST_VALID_MID, 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(SB_UT_FIRST_VALID_MID, 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 */ /* @@ -5576,68 +2959,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(SB_UT_TLM_MID1, 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(SB_UT_TLM_MID1, 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 */ /* @@ -5648,51 +2991,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 */ /* @@ -5704,71 +3018,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; - - 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; - } - - 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; - } + CFE_SB.PipeTbl[PipeId].AppId = RealOwner + 1; + ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - if (UT_EventIsInHistory(CFE_SB_UNSUB_INV_CALLER_EID) == false) - { - UT_Text("CFE_SB_UNSUB_INV_CALLER_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(4); + + EVTSENT(CFE_SB_UNSUB_INV_CALLER_EID); CFE_SB.PipeTbl[PipeId].AppId = RealOwner; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Invalid pipe owner test"); + + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_Unsubscribe_InvalidPipeOwner */ /* @@ -5782,58 +3055,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 */ /* @@ -5847,58 +3090,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 */ /* @@ -5911,51 +3125,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 */ /* @@ -5963,9 +3153,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(); @@ -5987,9 +3175,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 */ /* @@ -5997,48 +3183,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; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendMsg(NULL), 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_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 */ /* @@ -6048,63 +3202,29 @@ 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, SB_UT_ALTERNATE_INVALID_MID, sizeof(TlmPkt), true); - CFE_SB_SetMsgId(TlmPktPtr, CFE_SB_INVALID_MSG_ID); - - + 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 */ /* @@ -6115,49 +3235,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 */ /* @@ -6168,50 +3258,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 */ /* @@ -6224,45 +3283,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 */ /* @@ -6276,180 +3311,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; - } - - 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 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(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_PassMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT_TRUE(PtrToMsg != NULL); - 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_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 1); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_PassMsg(TlmPktPtr)); - 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(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT_TRUE(PtrToMsg != NULL); - 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_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 22); - 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(CFE_SB_SendMsg(TlmPktPtr)); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - 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_TRUE(PtrToMsg != NULL); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 2); - CFE_SB_Unsubscribe(MsgId, PipeId); /* should have no subscribers now */ + EVTCNT(3); - CFE_SB_SendMsg(TlmPktPtr); /* increment to 3 */ + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_Subscribe(MsgId, PipeId); /* resubscribe so we can receive a msg */ + SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); /* should have no subscribers now */ - CFE_SB_SendMsg(TlmPktPtr); /* increment to 4 */ + SETUP(CFE_SB_SendMsg(TlmPktPtr)); /* increment to 3 */ - CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* resubscribe so we can receive a msg */ - 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; - } + SETUP(CFE_SB_SendMsg(TlmPktPtr)); /* increment to 4 */ - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Telemetry sequence count test"); + SETUP(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); + + ASSERT_EQ(CCSDS_RD_SEQ(PtrToMsg->Hdr), 4); + + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SendMsg_SequenceCount */ /* @@ -6462,53 +3374,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); - CFE_SB_DeletePipe(PipeId4Error); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "QueuePut error test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId4Error)); + + REPORT(); } /* end Test_SendMsg_QueuePutError */ /* @@ -6521,69 +3405,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 */ /* @@ -6596,73 +3440,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; - - 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; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - 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 */ /* @@ -6675,58 +3477,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 */ /* @@ -6737,13 +3509,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(); @@ -6751,67 +3518,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; - } - - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) == (cpuaddr) NULL); - 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 @@ -6820,60 +3542,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 */ /* @@ -6888,26 +3565,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); @@ -6915,83 +3582,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; + ASSERT(CFE_SB_ZeroCopySend(ZeroCpyMsgPtr, ZeroCpyBufHndl)); - 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_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 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 */ /* @@ -7007,17 +3615,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); @@ -7034,45 +3639,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; - - 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; - - 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; - } + ASSERT_EQ(CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl), CFE_SB_BUFFER_INVALID); - 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 receive in zero copy pass test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + /* Test a successful zero copy pass */ + ASSERT(CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl)); + + + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); + if (PtrToMsg == NULL) { @@ -7089,28 +3664,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 */ /* @@ -7125,153 +3685,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; - } + ASSERT(CFE_SB_ZeroCopyReleasePtr(ZeroCpyMsgPtr1, ZeroCpyBufHndl1)); - 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, "Test_SendMsg_API", - "ZeroCopyReleasePtr test"); + REPORT(); } /* end Test_SendMsg_ZeroCopyReleasePtr */ /* @@ -7285,56 +3739,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; - } + 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; - } + 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", - "Disabled destination test"); + REPORT(); } /* end Test_SendMsg_DisabledDestination */ /* @@ -7357,52 +3782,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 */ /* @@ -7412,13 +3810,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), @@ -7432,42 +3825,16 @@ void Test_SendMsg_InvalidMsgId_ZeroCopy(void) { CFE_SB_InitMsg(TlmPktPtr, SB_UT_ALTERNATE_INVALID_MID, 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 */ /* @@ -7479,13 +3846,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), @@ -7498,42 +3860,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 */ /* @@ -7545,13 +3881,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), @@ -7564,42 +3895,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(); - - 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_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 */ /* @@ -7607,9 +3911,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(); @@ -7624,9 +3926,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 */ /* @@ -7636,49 +3936,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 */ /* @@ -7690,51 +3961,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 */ /* @@ -7745,50 +3986,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 */ /* @@ -7798,51 +4010,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 */ /* @@ -7854,51 +4036,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 */ /* @@ -7910,57 +4063,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 */ @@ -7969,46 +4091,18 @@ void Test_RcvMsg_GetLastSenderNoValidSender(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 No Valid Sender"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_GetLastSenderId(&GLSPtr, PipeId); - ExpRtn = CFE_SB_NO_MSG_RECV; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetLastSenderId No Valid Sender 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")); + ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, PipeId), CFE_SB_NO_MSG_RECV); - 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; - } - - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId No Valid Sender test"); + EVTCNT(1); + + TEARDOwN(CFE_SB_DeletePipe(PipeId)); + REPORT(); } /* end Test_RcvMsg_GetLastSenderNoValidSender */ @@ -8023,49 +4117,22 @@ void Test_RcvMsg_GetLastSenderSuccess(void) CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; CFE_SB_MsgPtr_t PtrToMsg; 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"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, SB_UT_TLM_MID, sizeof(TlmPkt), true); - CFE_SB_Subscribe(SB_UT_TLM_MID, PipeId); - CFE_SB_SendMsg(TlmPktPtr); - CFE_SB_RcvMsg(&PtrToMsg, PipeId,CFE_SB_PEND_FOREVER); - ActRtn = CFE_SB_GetLastSenderId(&GLSPtr, PipeId); - ExpRtn = CFE_SUCCESS; - - 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; - } + SETUP(CFE_SB_Subscribe(SB_UT_TLM_MID, PipeId)); + SETUP(CFE_SB_SendMsg(TlmPktPtr)); + SETUP(CFE_SB_RcvMsg(&PtrToMsg, PipeId,CFE_SB_PEND_FOREVER)); + ASSERT(CFE_SB_GetLastSenderId(&GLSPtr, PipeId)); - 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_RcvMsg_API", - "GetLastSenderId Success Test"); + REPORT(); } /* end Test_RcvMsg_GetLastSenderSuccess */ /* @@ -8077,52 +4144,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; - - 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; - } + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut), CFE_SB_TIME_OUT); - 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 */ /* @@ -8133,51 +4170,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; - - 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; - } + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER), CFE_SB_PIPE_RD_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_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 */ /* @@ -8192,78 +4199,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; - - 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; - } + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + SETUP(CFE_SB_SendMsg(TlmPktPtr)); - if (PtrToMsg != NULL) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Received Msg 0x%x", - (unsigned int)CFE_SB_MsgIdToValue(CFE_SB_GetMsgId(PtrToMsg))); -#ifdef UT_VERBOSE - UT_Text(cMsg); -#endif - } - - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); + + 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 */ /* @@ -8274,16 +4233,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); @@ -8291,11 +4245,7 @@ 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 @@ -8305,39 +4255,15 @@ void Test_CleanupApp_API(void) /* 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; - } - - 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 */ /* @@ -8347,51 +4273,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 */ /* @@ -8399,9 +4295,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(); @@ -8414,9 +4308,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 */ /* @@ -8424,15 +4317,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 */ /* @@ -8440,29 +4330,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_ValueToMsgId(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 */ /* @@ -8470,29 +4356,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_ValueToMsgId(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 */ /* @@ -8500,122 +4383,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 */ /* @@ -8629,14 +4477,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(); @@ -8645,11 +4490,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, @@ -8660,9 +4505,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(); @@ -8682,16 +4525,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) @@ -8704,9 +4545,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(); @@ -8726,9 +4565,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 */ /* @@ -8740,12 +4577,9 @@ void Test_CFE_SB_SetGetMsgId(void) CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; CFE_SB_MsgId_t MsgIdReturned; CFE_SB_MsgId_t MsgIdSet; - 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(); @@ -8767,9 +4601,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 @@ -8777,7 +4609,7 @@ 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++) { @@ -8791,8 +4623,7 @@ void Test_CFE_SB_SetGetMsgId(void) } } - UT_Report(__FILE__, __LINE__, - i == 0x10000, "Test_CFE_SB_SetGetMsgId", "Loop test"); + REPORT(); } /* end Test_CFE_SB_SetGetMsgId */ /* @@ -8806,27 +4637,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); @@ -8848,19 +4677,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); @@ -8881,24 +4708,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 || @@ -8914,20 +4739,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); @@ -8948,9 +4771,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 */ /* @@ -8964,14 +4785,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 */ @@ -9000,9 +4819,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(); @@ -9029,9 +4846,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(); @@ -9058,9 +4873,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(); @@ -9087,9 +4900,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 */ /* @@ -9104,12 +4915,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(); @@ -9120,7 +4929,7 @@ void Test_CFE_SB_SetGetMsgTime(void) /* Set MsgId */ CFE_SB_SetMsgId(SBCmdPtr, SB_UT_CMD_MID); - + SetTime.Seconds = 0x4321; SetTime.Subseconds = 0x8765; @@ -9153,9 +4962,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(); @@ -9167,7 +4974,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; @@ -9200,9 +5007,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(); @@ -9210,7 +5015,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 */ @@ -9249,9 +5054,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(); @@ -9294,9 +5097,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 */ /* @@ -9308,11 +5109,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(); @@ -9355,9 +5153,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 */ /* @@ -9371,16 +5167,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 @@ -9396,13 +5190,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); @@ -9427,9 +5221,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 @@ -9442,11 +5234,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); @@ -9472,9 +5264,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 @@ -9489,9 +5279,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); @@ -9517,9 +5307,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 @@ -9534,9 +5322,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); @@ -9562,9 +5350,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 */ /* @@ -9581,11 +5367,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(); @@ -9595,11 +5378,11 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_InitMsg(SBCmdPtr, CFE_SB_ValueToMsgId(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; @@ -9627,7 +5410,7 @@ void Test_CFE_SB_ChecksumUtils(void) * return false */ CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1806 ); - + RtnFrmValidate = CFE_SB_ValidateChecksum(SBCmdPtr); ExpRtnFrmVal = false; @@ -9641,9 +5424,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(); @@ -9653,9 +5434,9 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_InitMsg(SBNoSecHdrPktPtr, CFE_SB_ValueToMsgId(0x1005), sizeof(SBNoSecHdrPkt), true); - + CCSDS_WR_SHDR( SBNoSecHdrPktPtr->Hdr, 0 ); - + /* Set checksum field */ CFE_SB_GenerateChecksum(SBNoSecHdrPktPtr); RtnFrmGet = CFE_SB_GetChecksum(SBNoSecHdrPktPtr); @@ -9681,7 +5462,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; @@ -9696,9 +5477,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(); @@ -9744,9 +5523,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(); @@ -9794,40 +5571,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 = SB_UT_LAST_VALID_MID; - 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 = SB_UT_ALTERNATE_INVALID_MID; - 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(); } /* @@ -9835,6 +5605,8 @@ void Test_CFE_SB_ValidateMsgId(void) */ void Test_SB_SpecialCases(void) { + STARTBLOCK(); + Test_OS_MutSem_ErrLogic(); Test_ReqToSendEvent_ErrLogic(); Test_PutDestBlk_ErrLogic(); @@ -9845,8 +5617,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 @@ -9854,52 +5627,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 @@ -9913,34 +5659,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 */ @@ -9952,47 +5675,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, OS_SEM_FAILURE); - UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 2, OS_SEM_FAILURE); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, CFE_OS_SEM_FAILURE); + UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 2, CFE_OS_SEM_FAILURE); + 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 */ /* @@ -10002,13 +5702,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(); @@ -10016,48 +5711,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; - } - - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_RequestToSendEvent(TaskId, Bit), CFE_SB_DENIED); - 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 */ /* @@ -10066,87 +5729,31 @@ 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 */ /* ** Test internal function to get the pipe table index for the given pipe ID */ void Test_CFE_SB_GetPipeIdx(void) -{ - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test GetPipeIdx"); -#endif - - 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; - } +{ + START(); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + SB_ResetUnitTest(); + CFE_SB.PipeTbl[0].PipeId = 0; + CFE_SB.PipeTbl[0].InUse = CFE_SB_NOT_IN_USE; + ASSERT_EQ(CFE_SB_GetPipeIdx(0), CFE_SB_INVALID_PIPE); - 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 */ /* @@ -10154,139 +5761,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(SB_UT_FIRST_VALID_MID, 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 */ /* @@ -10296,83 +5819,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(SB_UT_FIRST_VALID_MID ,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(SB_UT_FIRST_VALID_MID ,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 */ /* @@ -10387,13 +5862,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(); @@ -10403,11 +5873,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); @@ -10415,37 +5881,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; @@ -10453,212 +5893,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)); + + REPORT(); - CFE_SB_DeletePipe(PipeId); + 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 */ /* @@ -10673,77 +6004,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_MsgIdToValue(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 */ /* @@ -10818,5 +6099,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 417396188..0b7f014a2 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 */