From bc0d2dcb94818fe0e0f5a825e764b95d3e7ec5f5 Mon Sep 17 00:00:00 2001 From: Chris Knight Date: Fri, 24 Apr 2020 09:04:38 -0700 Subject: [PATCH] fix #491 - UT macros --- fsw/cfe-core/unit-test/sb_UT.c | 6822 +++++---------------------- fsw/cfe-core/unit-test/ut_support.c | 16 + fsw/cfe-core/unit-test/ut_support.h | 52 +- 3 files changed, 1239 insertions(+), 5651 deletions(-) diff --git a/fsw/cfe-core/unit-test/sb_UT.c b/fsw/cfe-core/unit-test/sb_UT.c index a3c92f342..f64ee89d1 100644 --- a/fsw/cfe-core/unit-test/sb_UT.c +++ b/fsw/cfe-core/unit-test/sb_UT.c @@ -66,12 +66,11 @@ 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 @@ -82,34 +81,30 @@ void Test_SB_Macros(void) Test_SB_CCSDSPriHdr_Macros(); Test_SB_CCSDSSecHdr_Macros(); - + ENDBLOCK(); } /* end Test_SB_Macros */ - /* **Test_SB_CCSDSSecHdr_Macros */ void Test_SB_CCSDSSecHdr_Macros(void) { CFE_SB_CmdHdr_t NoParamPkt; - + uint32 ExpRtn; uint32 ActRtn; - uint32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Test_SB_CCSDSSecHdr_Macros Test"); -#endif + START(); SB_ResetUnitTest(); ExpRtn = 0x01; - + CCSDS_CLR_CMDSEC_HDR(NoParamPkt.Sec); - + CCSDS_WR_FC(NoParamPkt.Sec, 1); ActRtn = CCSDS_RD_FC(NoParamPkt.Sec); - + if (ActRtn != ExpRtn) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -120,12 +115,12 @@ void Test_SB_CCSDSSecHdr_Macros(void) TestStat = CFE_FAIL; } - + SB_ResetUnitTest(); ExpRtn = 0xFF; - + CCSDS_CLR_CMDSEC_HDR(NoParamPkt.Sec); - + CCSDS_WR_CHECKSUM(NoParamPkt.Sec, 0xFF); ActRtn = CCSDS_RD_CHECKSUM(NoParamPkt.Sec); @@ -138,17 +133,17 @@ void Test_SB_CCSDSSecHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + #ifdef MESSAGE_FORMAT_IS_CCSDS_VER_2 - + 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, @@ -158,15 +153,15 @@ void Test_SB_CCSDSSecHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + 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, @@ -176,15 +171,15 @@ void Test_SB_CCSDSSecHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + 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, @@ -194,15 +189,15 @@ void Test_SB_CCSDSSecHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + 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, @@ -212,15 +207,15 @@ void Test_SB_CCSDSSecHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + 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, @@ -230,15 +225,15 @@ void Test_SB_CCSDSSecHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + 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, @@ -249,9 +244,8 @@ void Test_SB_CCSDSSecHdr_Macros(void) TestStat = CFE_FAIL; } #endif - - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SB_CCSDSSecHdr_Macros", "CCSDS Secondary Header Macro Test"); + + REPORT(); } /* end Test_SB_CCSDSSecHdr_Macros */ /* @@ -260,24 +254,20 @@ 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, @@ -288,15 +278,14 @@ void Test_SB_CCSDSPriHdr_Macros(void) TestStat = CFE_FAIL; } - SB_ResetUnitTest(); ExpRtn = 0x07FF; - + 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, @@ -307,16 +296,16 @@ void Test_SB_CCSDSPriHdr_Macros(void) TestStat = CFE_FAIL; } - + SB_ResetUnitTest(); ExpRtn = 1; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - + CCSDS_WR_SHDR(Msg.Hdr, 1); - + ActRtn = CCSDS_RD_SHDR(Msg.Hdr); - + if (ActRtn != ExpRtn) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -326,17 +315,17 @@ void Test_SB_CCSDSPriHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - - + + SB_ResetUnitTest(); ExpRtn = 1; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - + CCSDS_WR_TYPE(Msg.Hdr, 1); - + ActRtn = CCSDS_RD_TYPE(Msg.Hdr); - + if (ActRtn != ExpRtn) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -346,16 +335,16 @@ void Test_SB_CCSDSPriHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + SB_ResetUnitTest(); ExpRtn = 1; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - + CCSDS_WR_VERS(Msg.Hdr, 1); - + ActRtn = CCSDS_RD_VERS(Msg.Hdr); - + if (ActRtn != ExpRtn) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -365,16 +354,16 @@ void Test_SB_CCSDSPriHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + SB_ResetUnitTest(); ExpRtn = 0x3FFF; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - + CCSDS_WR_SEQ(Msg.Hdr, 0x3FFF); - + ActRtn = CCSDS_RD_SEQ(Msg.Hdr); - + if (ActRtn != ExpRtn) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -384,16 +373,16 @@ void Test_SB_CCSDSPriHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - + SB_ResetUnitTest(); ExpRtn = 0x03; - + CCSDS_CLR_PRI_HDR(Msg.Hdr); - + CCSDS_WR_SEQFLG(Msg.Hdr, 0x03); - + ActRtn = CCSDS_RD_SEQFLG(Msg.Hdr); - + if (ActRtn != ExpRtn) { snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, @@ -403,17 +392,17 @@ void Test_SB_CCSDSPriHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - - + + 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, @@ -423,9 +412,8 @@ void Test_SB_CCSDSPriHdr_Macros(void) UT_Text(cMsg); TestStat = CFE_FAIL; } - - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SB_CCSDS_Macros", "CCSDS Macro Test"); + + REPORT(); } /* end Test_SB_CCSDSPriHdr_Macros */ /* @@ -445,9 +433,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(); @@ -458,9 +444,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 */ /* @@ -504,15 +488,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(); @@ -528,33 +507,13 @@ void Test_SB_AppInit_EVSSendEvtFail(void) * (The others use SendEventWithAppID which is a different counter). */ UT_SetDeferredRetcode(UT_KEY(CFE_EVS_SendEvent), 1, ForcedRtnVal); - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ForcedRtnVal) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from AppInit in EVSSendEvtFail test, " - "exp=0x%lx, act= 0x%lx", - (unsigned long) ForcedRtnVal, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act= %ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(CFE_SB.CmdPipe)); - CFE_SB_DeletePipe(CFE_SB.CmdPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "EVS SendEvent failure"); + REPORT(); } /* end Test_SB_AppInit_EVSSendEvtFail */ /* @@ -562,13 +521,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(); @@ -576,40 +529,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(); - - 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; - } + ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_PIPE_CR_ERR); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_CR_PIPE_ERR_EID) == false) - { - UT_Text("CFE_SB_CR_PIPE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CR_PIPE_ERR_EID); - CFE_SB_DeletePipe(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "Create pipe failure"); + REPORT(); } /* end Test_SB_AppInit_CrPipeFail */ /* @@ -618,50 +544,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 */ /* @@ -670,50 +566,20 @@ void Test_SB_AppInit_Sub1Fail(void) void Test_SB_AppInit_Sub2Fail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Subscription 2 Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 2, -1); - ExpRtn = CFE_SB_BUF_ALOC_ERR; - ActRtn = CFE_SB_AppInit(); + ASSERT_EQ(CFE_SB_AppInit(), CFE_SB_BUF_ALOC_ERR); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in Sub2 test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - - 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 */ /* @@ -722,45 +588,19 @@ void Test_SB_AppInit_Sub2Fail(void) void Test_SB_AppInit_GetPoolFail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; int32 ForcedRtnVal = -1; -#ifdef UT_VERBOSE - UT_Text("Start of GetPool Failure Test"); -#endif + START(); - SB_ResetUnitTest(); + SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBuf), 3, ForcedRtnVal); - ExpRtn = ForcedRtnVal; - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in GetPool test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "GetPool failure"); + REPORT(); } /* end Test_SB_AppInit_GetPoolFail */ /* @@ -769,45 +609,20 @@ void Test_SB_AppInit_GetPoolFail(void) void Test_SB_AppInit_PutPoolFail(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; int32 ForcedRtnVal = -1; -#ifdef UT_VERBOSE - UT_Text("Start of PutPool Failure Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, ForcedRtnVal); - ExpRtn = ForcedRtnVal; - ActRtn = CFE_SB_AppInit(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CFE_SB_AppInit in PutPool Test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_AppInit(), ForcedRtnVal); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_AppInit", "PutPool Failure"); + REPORT(); } /* end Test_SB_AppInit_PutPoolFail */ /* @@ -815,16 +630,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 */ /* @@ -833,44 +644,22 @@ void Test_SB_MainRoutine(void) void Test_SB_Main_RcvErr(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Main Loop, Rcv Error Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_QueueGet), 1, -1); CFE_SB_TaskMain(); - ExpRtn = 8; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(8); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_INIT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_Q_RD_ERR_EID) == false) - { - UT_Text("CFE_SB_Q_RD_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_Q_RD_ERR_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_TaskMain", "Rcv Error failure"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SB_Main_RcvErr */ /* @@ -879,32 +668,17 @@ void Test_SB_Main_RcvErr(void) void Test_SB_Main_InitErr(void) { CFE_SB_PipeId_t PipeId = 0; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Start of Main Loop, Init Error Test"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_TaskMain(); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(5); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_TaskMain", "Init Error failure"); + REPORT(); } /* end Test_SB_Main_InitErr */ /* @@ -912,9 +686,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(); @@ -952,9 +724,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 */ /* @@ -963,40 +733,20 @@ void Test_SB_Cmds(void) void Test_SB_Cmds_Noop(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - No-op"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_NOOP_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_CMD0_RCVD_EID) == false) - { - UT_Text("CFE_SB_CMD0_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CMD0_RCVD_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "No-op command test"); + REPORT(); } /* end Test_SB_Cmds_Noop */ /* @@ -1005,40 +755,20 @@ void Test_SB_Cmds_Noop(void) void Test_SB_Cmds_RstCtrs(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat= CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Reset Counters"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_RESET_COUNTERS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_CMD1_RCVD_EID) == false) - { - UT_Text("CFE_SB_CMD1_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_CMD1_RCVD_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Reset Counters command test"); + REPORT(); } /* Test_SB_Cmds_RstCtrs */ /* @@ -1047,46 +777,22 @@ void Test_SB_Cmds_RstCtrs(void) void Test_SB_Cmds_Stats(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send SB Stats"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, sizeof(NoParamCmd), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_SEND_SB_STATS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_SND_STATS_EID) == false) - { - UT_Text("CFE_SB_SND_STATS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_STATS_EID); - if (UT_EventIsInHistory(CFE_SB_SND_STATS_EID) == false) - { - UT_Text("CFE_SB_SND_STATS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_STATS_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send SB Stats command test"); + REPORT(); } /* end Test_SB_Cmds_Stats */ /* @@ -1096,13 +802,8 @@ void Test_SB_Cmds_RoutingInfoDef(void) { CFE_SB_PipeId_t PipeId = 0; CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info, Using Default Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1112,61 +813,25 @@ void Test_SB_Cmds_RoutingInfoDef(void) strncpy((char *)WriteFileCmd.Payload.Filename, "", sizeof(WriteFileCmd.Payload.Filename)); /* Make some routing info by calling CFE_SB_AppInit */ - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_AppInit(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_AppInit, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_AppInit()); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 9; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(9); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_CMD1_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_EID); - if (UT_EventIsInHistory(CFE_SB_INIT_EID) == false) - { - UT_Text("CFE_SB_INIT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Routing Info command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoDef */ /* @@ -1175,44 +840,24 @@ void Test_SB_Cmds_RoutingInfoDef(void) void Test_SB_Cmds_RoutingInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info2, Using Specified " - "Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, sizeof(WriteFileCmd), true); - CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, - CFE_SB_SEND_ROUTING_INFO_CC); + SETUP(CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &WriteFileCmd, + CFE_SB_SEND_ROUTING_INFO_CC)); strncpy((char *)WriteFileCmd.Payload.Filename, "RoutingTstFile", sizeof(WriteFileCmd.Payload.Filename)); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &WriteFileCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SND_RTG_EID) == false) - { - UT_Text("CFE_SB_SND_RTG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SND_RTG_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Send Routing Info2 command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoSpec */ /* @@ -1221,13 +866,8 @@ void Test_SB_Cmds_RoutingInfoSpec(void) void Test_SB_Cmds_RoutingInfoCreateFail(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Routing Info3, File Create Fails"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1239,28 +879,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 */ /* @@ -1268,50 +894,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 */ /* @@ -1321,83 +915,30 @@ 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; - } - ExpRtn = 9; - 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(9); - 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_INIT_EID) == false) - { - UT_Text("CFE_SB_INIT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_INIT_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_FILEWRITE_ERR_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendRtgInfo", - "Send Routing Info5 command test"); + REPORT(); } /* end Test_SB_Cmds_RoutingInfoWriteFail */ /* @@ -1410,13 +951,8 @@ void Test_SB_Cmds_PipeInfoDef(void) CFE_SB_PipeId_t PipeId2; CFE_SB_PipeId_t PipeId3; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info, Using Default Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1426,41 +962,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 */ /* @@ -1469,13 +987,8 @@ void Test_SB_Cmds_PipeInfoDef(void) void Test_SB_Cmds_PipeInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Pipe Info2, Using Specified Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1485,27 +998,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 */ /* @@ -1513,50 +1011,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"); + ASSERT_EQ(CFE_SB_SendPipeInfo("PipeTstFile"), CFE_SB_FILE_IO_ERR); - 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(); - - 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 */ /* @@ -1564,50 +1029,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 */ /* @@ -1620,62 +1052,26 @@ 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"); 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; - } - - ExpRtn = 4; - 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(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_FILEWRITE_ERR_EID) == false) - { - UT_Text("CFE_SB_FILEWRITE_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_FILEWRITE_ERR_EID); 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 */ /* @@ -1694,13 +1090,8 @@ void Test_SB_Cmds_MapInfoDef(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID + 5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID + 6; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info, Using Default Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1722,42 +1113,19 @@ void Test_SB_Cmds_MapInfoDef(void) 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; - } + EVTCNT(18); - 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); - 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); 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"); + REPORT(); } /* end Test_SB_Cmds_MapInfoDef */ /* @@ -1766,13 +1134,8 @@ void Test_SB_Cmds_MapInfoDef(void) void Test_SB_Cmds_MapInfoSpec(void) { CFE_SB_WriteFileInfoCmd_t WriteFileCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info2, Using Specified Filename"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&WriteFileCmd, CFE_SB_CMD_MID, @@ -1782,27 +1145,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 */ /* @@ -1810,50 +1158,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 */ /* @@ -1861,50 +1176,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 */ /* @@ -1923,13 +1205,8 @@ void Test_SB_Cmds_MapInfoWriteFail(void) CFE_SB_MsgId_t MsgId4 = SB_UT_TLM_MID + 5; CFE_SB_MsgId_t MsgId5 = SB_UT_TLM_MID + 6; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Map Info5, Second FileWrite Fails"); -#endif + START(); SB_ResetUnitTest(); @@ -1945,55 +1222,22 @@ void Test_SB_Cmds_MapInfoWriteFail(void) CFE_SB_Subscribe(MsgId4, PipeId3); 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 */ /* @@ -2005,13 +1249,8 @@ 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"); @@ -2023,41 +1262,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 */ /* @@ -2070,13 +1288,8 @@ 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"); @@ -2089,42 +1302,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 */ /* @@ -2133,13 +1323,8 @@ void Test_SB_Cmds_EnRouteNonExist(void) void Test_SB_Cmds_EnRouteInvParam(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2149,28 +1334,14 @@ void Test_SB_Cmds_EnRouteInvParam(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; EnDisRouteCmd.Payload.Pipe = 3; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_ENBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, invalid pipe ID test"); + REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam */ /* @@ -2179,13 +1350,8 @@ void Test_SB_Cmds_EnRouteInvParam(void) void Test_SB_Cmds_EnRouteInvParam2(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Invalid Msg ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2195,28 +1361,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 */ /* @@ -2226,13 +1378,8 @@ void Test_SB_Cmds_EnRouteInvParam2(void) void Test_SB_Cmds_EnRouteInvParam3(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Enable Route, Msg ID Too Large"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2242,28 +1389,14 @@ void Test_SB_Cmds_EnRouteInvParam3(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; EnDisRouteCmd.Payload.Pipe = 0; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_ENBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_ENBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_ENBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Enable Route, msg ID too large test"); + REPORT(); } /* end Test_SB_Cmds_EnRouteInvParam3 */ /* @@ -2275,13 +1408,8 @@ 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"); @@ -2294,40 +1422,17 @@ 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"); + REPORT(); } /* end Test_SB_Cmds_DisRouteValParam */ /* @@ -2339,13 +1444,8 @@ 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"); @@ -2358,42 +1458,21 @@ 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; - } + EVTCNT(5); - 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_RTE1_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE1_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE1_EID); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, non-existent route test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + + REPORT(); } /* end Test_SB_Cmds_DisRouteNonExist */ /* @@ -2402,13 +1481,8 @@ void Test_SB_Cmds_DisRouteNonExist(void) void Test_SB_Cmds_DisRouteInvParam(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2418,28 +1492,14 @@ void Test_SB_Cmds_DisRouteInvParam(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; EnDisRouteCmd.Payload.Pipe = 3; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, invalid pipe ID test"); + REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam */ /* @@ -2448,13 +1508,8 @@ void Test_SB_Cmds_DisRouteInvParam(void) void Test_SB_Cmds_DisRouteInvParam2(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Invalid Param2"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2464,28 +1519,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 */ /* @@ -2495,13 +1536,8 @@ void Test_SB_Cmds_DisRouteInvParam2(void) void Test_SB_Cmds_DisRouteInvParam3(void) { CFE_SB_RouteCmd_t EnDisRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Disable Route, Msg ID Too Large"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&EnDisRouteCmd, CFE_SB_CMD_MID, @@ -2511,28 +1547,14 @@ void Test_SB_Cmds_DisRouteInvParam3(void) EnDisRouteCmd.Payload.MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; EnDisRouteCmd.Payload.Pipe = 0; CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &EnDisRouteCmd; + CFE_SB_ProcessCmdPipePkt(); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_DSBL_RTE3_EID) == false) - { - UT_Text("CFE_SB_DSBL_RTE3_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_DSBL_RTE3_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ProcessCmdPipePkt", - "Disable Route, msg ID too large test"); + REPORT(); } /* end Test_SB_Cmds_DisRouteInvParam3 */ /* @@ -2541,13 +1563,8 @@ void Test_SB_Cmds_DisRouteInvParam3(void) void Test_SB_Cmds_SendHK(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Housekeeping Info"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_SEND_HK_MID, @@ -2555,27 +1572,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 */ /* @@ -2592,20 +1594,15 @@ void Test_SB_Cmds_SendPrevSubs(void) uint16 PipeDepth = 50; int32 i; int32 NumEvts; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Send Previous Subscriptions"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, sizeof(CFE_SB_SendPrevSubs_t), true); CFE_SB_SetCmdCode((CFE_SB_MsgPtr_t) &NoParamCmd, CFE_SB_SEND_PREV_SUBS_CC); CFE_SB.CmdPipePktPtr = (CFE_SB_MsgPtr_t) &NoParamCmd; - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); NumEvts = 2; /* one for each pipe create */ /* Two full pkts to be sent plus five entries in a partial pkt, skipping MSGID 0x0D */ @@ -2622,102 +1619,43 @@ void Test_SB_Cmds_SendPrevSubs(void) if (i != CFE_SB_ALLSUBS_TLM_MID) { NumEvts += 2; - ActRtn = CFE_SB_Subscribe(i, PipeId1); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return subscribing in SendPrevSubs Test, " - "i=%d, exp=0x%lx, act=0x%lx", - (int) i, (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_Subscribe(i, PipeId1)); } } - CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim); + SETUP(CFE_SB_SubscribeLocal(MsgId, PipeId2, MsgLim)); + CFE_SB_ProcessCmdPipePkt(); - NumEvts += 8; /* +2 for the subscribe, +6 for the SEND_PREV_SUBS_CC */ - ExpRtn = NumEvts; - ActRtn = UT_GetNumEventsSent(); - 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(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 */ /* @@ -2726,13 +1664,8 @@ void Test_SB_Cmds_SendPrevSubs(void) void Test_SB_Cmds_SubRptOn(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Subscription Reporting On"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, @@ -2741,21 +1674,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 */ /* @@ -2764,13 +1686,8 @@ void Test_SB_Cmds_SubRptOn(void) void Test_SB_Cmds_SubRptOff(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Subscription Reporting Off"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, @@ -2779,21 +1696,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 */ /* @@ -2802,13 +1708,8 @@ void Test_SB_Cmds_SubRptOff(void) void Test_SB_Cmds_UnexpCmdCode(void) { CFE_SB_CmdHdr_t NoParamCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - Unexpected Command Code"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&NoParamCmd, CFE_SB_CMD_MID, sizeof(NoParamCmd), true); @@ -2817,27 +1718,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 */ /* @@ -2849,9 +1735,6 @@ void Test_SB_Cmds_BadCmdLength(void) * Just choosing "EnableRoute" command here as it has a non-empty payload */ CFE_SB_EnableRoute_t EnableRouteCmd; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; SB_ResetUnitTest(); CFE_SB_InitMsg(&EnableRouteCmd, CFE_SB_CMD_MID, sizeof(EnableRouteCmd) - 1, true); @@ -2860,27 +1743,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 */ /* @@ -2890,39 +1758,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 */ /* @@ -2930,17 +1778,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 */ /* @@ -2948,9 +1792,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); @@ -2964,9 +1806,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); @@ -2980,9 +1820,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(); @@ -2996,9 +1834,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(); @@ -3006,9 +1842,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 */ /* @@ -3017,52 +1851,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 */ /* @@ -3071,60 +1875,21 @@ 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"); + REPORT(); CFE_SB_DeletePipe(PipeIdReturned[0]); CFE_SB_DeletePipe(PipeIdReturned[1]); @@ -3137,63 +1902,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 */ /* @@ -3203,62 +1929,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 */ /* @@ -3270,12 +1973,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(); @@ -3284,55 +1983,31 @@ void Test_CreatePipe_SamePipeName(void) UT_SetDeferredRetcode(UT_KEY(OS_QueueCreate), 2, OS_ERR_NAME_TAKEN); /* First call to CFE_SB_CreatePipe() should succeed */ - status = CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName)); - if (status == CFE_SUCCESS) - { - FirstPipeId = PipeId; - } - else - { - UT_Text("First call to CFE_SB_CreatePipe() failed"); - TestStat = CFE_FAIL; - } + FirstPipeId = PipeId; /* Second call to CFE_SB_CreatePipe with same PipeName should fail */ - status = CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName); + ASSERT_EQ(CFE_SB_CreatePipe(&PipeId, PipeDepth, PipeName), CFE_SB_PIPE_CR_ERR); - if (status == CFE_SUCCESS) - { - UT_Text("Second call to CFE_SB_CreatePipe() passed unexpectedly"); - TestStat = CFE_FAIL; - } + ASSERT_EQ(PipeId, FirstPipeId); - if (PipeId != FirstPipeId) - { - UT_Text("Second call to CFE_SB_CreatePipe() modified the PipeId"); - TestStat = CFE_FAIL; - } + EVTCNT(2); - /* Call to CFE_SB_DeletePipe with the first pipe id created should work fine */ - status = CFE_SB_DeletePipe(PipeId); + EVTSENT(CFE_SB_CR_PIPE_NAME_TAKEN_EID); - if (status != CFE_SUCCESS) - { - UT_Text("Failed to delete pipe"); - TestStat = CFE_FAIL; - } + /* Call to CFE_SB_DeletePipe with the first pipe id created should work fine */ + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CreatePipe_API", "Same pipe name test"); + REPORT(); } - /* ** Function for calling SB delete pipe API test functions */ void Test_DeletePipe_API(void) { -#ifdef UT_VERBOSE - UT_Text("Begin Test_DeletePipe_API"); -#endif + STARTBLOCK(); Test_DeletePipe_NoSubs(); Test_DeletePipe_WithSubs(); @@ -3340,9 +2015,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 */ /* @@ -3352,55 +2025,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 */ /* @@ -3414,59 +2051,23 @@ void Test_DeletePipe_WithSubs(void) CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID + 3; CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID + 4; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test With Subscriptions"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId0, PipedId); - CFE_SB_Subscribe(MsgId1, PipedId); - CFE_SB_Subscribe(MsgId2, PipedId); - CFE_SB_Subscribe(MsgId3, PipedId); - ActRtn = CFE_SB_DeletePipe(PipedId); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in delete pipe test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 14; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId0, PipedId)); + SETUP(CFE_SB_Subscribe(MsgId1, PipedId)); + SETUP(CFE_SB_Subscribe(MsgId2, PipedId)); + SETUP(CFE_SB_Subscribe(MsgId3, PipedId)); + ASSERT(CFE_SB_DeletePipe(PipedId)); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTCNT(14); - if (UT_EventIsInHistory(CFE_SB_PIPE_DELETED_EID) == false) - { - UT_Text("CFE_SB_PIPE_DELETED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); + EVTSENT(CFE_SB_PIPE_DELETED_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_DeletePipe_API", - "With subscriptions test"); + REPORT(); } /* end Test_DeletePipe_WithSubs */ /* @@ -3475,48 +2076,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 */ /* @@ -3527,71 +2098,28 @@ void Test_DeletePipe_InvalidPipeOwner(void) CFE_SB_PipeId_t PipedId; uint32 RealOwner; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe Owner"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from CreatePipe in DeletePipe, " - "invalid owner test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipedId, PipeDepth, "TestPipe")); /* Change owner of pipe through memory corruption */ RealOwner = CFE_SB.PipeTbl[PipedId].AppId; /* Choose a value that is sure not to be owner */ CFE_SB.PipeTbl[PipedId].AppId = RealOwner + 1; - ActRtn = CFE_SB_DeletePipe(PipedId); - ExpRtn = CFE_SB_BAD_ARGUMENT; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from DeletePipe in DeletePipe, " - "invalid owner test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_DeletePipe(PipedId), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - - 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 */ /* @@ -3600,53 +2128,23 @@ void Test_DeletePipe_InvalidPipeOwner(void) void Test_DeletePipe_WithAppid(void) { CFE_SB_PipeId_t PipedId; - CFE_SB_MsgId_t MsgId0 = SB_UT_CMD_MID + 1; - CFE_SB_MsgId_t MsgId1 = SB_UT_CMD_MID + 2; - CFE_SB_MsgId_t MsgId2 = SB_UT_CMD_MID + 3; - CFE_SB_MsgId_t MsgId3 = SB_UT_CMD_MID + 4; - uint32 AppId = 0; + uint32 AppId = 0; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test DeletePipeWithAppId API"); -#endif + 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_MID + 1, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 2, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 3, PipedId)); + SETUP(CFE_SB_Subscribe(SB_UT_CMD_MID + 4, PipedId)); - 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 */ /* @@ -3654,9 +2152,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(); @@ -3665,9 +2161,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 */ /* @@ -3675,17 +2169,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 */ /* @@ -3693,33 +2183,13 @@ void Test_GetPipeName_API(void) */ void Test_GetPipeName_NullPtr(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeName with null ptr"); -#endif - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeName(NULL, OS_MAX_API_NAME, 0)) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } + START(); - if (UT_EventIsInHistory(CFE_SB_GETPIPENAME_NULL_PTR_EID) == false) - { - UT_Text("CFE_SB_GETPIPENAME_NULL_PTR_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeName(NULL, OS_MAX_API_NAME, 0), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPENAME_NULL_PTR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeName_NullPtr", - "Get pipe name with null ptr"); + REPORT(); } /* end Test_GetPipeName_NullPtr */ /* @@ -3727,36 +2197,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 */ /* @@ -3764,8 +2214,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; @@ -3773,52 +2221,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 */ /* @@ -3826,17 +2244,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 */ /* @@ -3844,52 +2258,18 @@ void Test_GetPipeIdByName_API(void) */ void Test_GetPipeIdByName_NullPtrs(void) { - int32 ExpRtn = 0, ActRtn = 0; - int32 TestStat = CFE_PASS; CFE_SB_PipeId_t PipeIDOut = 0; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - GetPipeIdByName with null ptrs"); -#endif - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeIdByName(&PipeIDOut, NULL)) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeIdByName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - - TestStat = CFE_FAIL; - } - - if (UT_EventIsInHistory(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEIDBYNAME_EID not sent"); - - TestStat = CFE_FAIL; - } + START(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - if((ActRtn = CFE_SB_GetPipeIdByName(NULL, "invalid")) != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_GetPipeIdByName, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); + ASSERT_EQ(CFE_SB_GetPipeIdByName(&PipeIDOut, NULL), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID); - if (UT_EventIsInHistory(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID) == false) - { - UT_Text("CFE_SB_GETPIPEIDBYNAME_EID not sent"); + ASSERT_EQ(CFE_SB_GetPipeIdByName(NULL, "invalid"), CFE_SB_BAD_ARGUMENT); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GETPIPEIDBYNAME_NULL_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetPipeIdByName_NullPtrs", - "Get pipe id by name with null ptrs"); + REPORT(); } /* end Test_GetPipeIdByName_NullPtrs */ /* @@ -3897,34 +2277,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 */ /* @@ -3932,26 +2292,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), @@ -3959,29 +2303,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 */ /* @@ -3989,31 +2317,13 @@ void Test_GetPipeIdByName(void) */ void Test_SetPipeOpts_BadID(void) { - int32 ActRtn = 0; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Cmd - SetPipeOpts with bad ID"); -#endif + START(); - if((ActRtn = CFE_SB_SetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, 0)) != CFE_SB_BAD_ARGUMENT) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from CFE_SB_SetPipeOpts, exp=%ld, act=%ld", - (long) CFE_SB_BAD_ARGUMENT, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_SetPipeOpts(CFE_PLATFORM_SB_MAX_PIPES, 0), CFE_SB_BAD_ARGUMENT); - if (UT_EventIsInHistory(CFE_SB_SETPIPEOPTS_ID_ERR_EID) == false) - { - UT_Text("CFE_SB_SETPIPEOPTS_ID_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SETPIPEOPTS_ID_ERR_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SetPipeOpts", - "Set pipe opts with invalid ID test"); + REPORT(); } /* end Test_SetPipeOpts_BadID */ /* @@ -4021,55 +2331,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 */ /* @@ -4077,47 +2359,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 */ /* @@ -4125,32 +2379,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 */ /* @@ -4158,49 +2395,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 */ /* @@ -4208,60 +2415,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(); @@ -4277,9 +2452,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 */ /* @@ -4292,55 +2465,21 @@ 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; - } + ASSERT(CFE_SB_SubscribeEx(MsgId, PipeId, Quality, MsgLim)); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", "SubscribeEx test"); + REPORT(); } /* end Test_Subscribe_SubscribeEx */ /* @@ -4350,48 +2489,17 @@ void Test_Subscribe_InvalidPipeId(void) { CFE_SB_PipeId_t PipeId = 2; CFE_SB_MsgId_t MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe ID"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid pipe ID subscribe test, " - "exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_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 */ /* @@ -4402,51 +2510,19 @@ void Test_Subscribe_InvalidMsgId(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Message ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); + ASSERT_EQ(CFE_SB_Subscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - 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; - } - - 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_ARG_ERR_EID) == false) - { - UT_Text("CFE_SB_SUB_ARG_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUB_ARG_ERR_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Invalid message ID test"); + REPORT(); } /* end Test_Subscribe_InvalidMsgId */ /* @@ -4459,52 +2535,20 @@ 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"); 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(); - - 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", - "Maximum message limit test"); + REPORT(); } /* end Test_Subscribe_MaxMsgLim */ /* @@ -4515,64 +2559,21 @@ 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); + ASSERT(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; - } + ASSERT(CFE_SB_Subscribe(MsgId, PipeId)); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Subscribe(MsgId, PipeId); + EVTCNT(5); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in second subscribe of duplicate " - "subscription test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - - 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; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Duplicate subscription test"); + REPORT(); } /* end Test_Subscribe_DuplicateSubscription */ /* @@ -4584,51 +2585,19 @@ 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; - } - - 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"); + REPORT(); } /* end Test_Subscribe_LocalSubscription */ /* @@ -4641,14 +2610,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(); @@ -4656,65 +2619,25 @@ 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++) @@ -4722,9 +2645,7 @@ void Test_Subscribe_MaxDestCount(void) CFE_SB_DeletePipe(PipeId[i]); } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Maximum destination count test"); + REPORT(); } /* end Test_Subscribe_MaxDestCount */ /* @@ -4737,56 +2658,35 @@ void Test_Subscribe_MaxMsgIdCount(void) CFE_SB_PipeId_t PipeId2; uint16 PipeDepth = 50; int32 i; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Maximum Message ID Count"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); + SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); for (i = 0; i < CFE_PLATFORM_SB_MAX_MSG_IDS + 1; i++) { - ActRtn = CFE_SB_Subscribe(i, PipeId2); if (i < CFE_PLATFORM_SB_MAX_MSG_IDS) { - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(i, PipeId2)); } else { - ExpRtn = CFE_SB_MAX_MSGS_MET; - } - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in maximum message ID count test, " - "i=%ld, exp=0x%lx, act=0x%lx", - (long) i, (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; + ASSERT_EQ(CFE_SB_Subscribe(i, PipeId2), CFE_SB_MAX_MSGS_MET); } } - if (UT_EventIsInHistory(CFE_SB_MAX_MSGS_MET_EID) == false) - { - UT_Text("CFE_SB_MAX_MSGS_MET_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MAX_MSGS_MET_EID); - CFE_SB_DeletePipe(PipeId0); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Maximum message ID count test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + + REPORT(); } /* end Test_Subscribe_MaxMsgIdCount */ /* @@ -4801,59 +2701,40 @@ void Test_Subscribe_SendPrevSubs(void) CFE_SB_MsgId_t MsgId1 = SB_UT_TLM_MID + 2; CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID + 3; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; CFE_SB_SendPrevSubs_t SendPrevSubsMsg; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Send Previous Subscriptions"); -#endif + START(); /* note that the message is not currently used or required, * but creating one and initializing it for completeness, in * case that changes in the future */ memset(&SendPrevSubsMsg, 0, sizeof(SendPrevSubsMsg)); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_Subscribe(MsgId0, PipeId0); - CFE_SB_Subscribe(MsgId1, PipeId0); - CFE_SB_Subscribe(MsgId2, PipeId0); - CFE_SB_Subscribe(MsgId0, PipeId1); - CFE_SB_Subscribe(MsgId1, PipeId1); - CFE_SB_Subscribe(MsgId2, PipeId1); - CFE_SB_Subscribe(MsgId0, PipeId2); + SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId2)); /* Set the last list header pointer to NULL to get branch path coverage */ CFE_SB.RoutingTbl[2].ListHeadPtr = NULL; - CFE_SB_SendPrevSubsCmd(&SendPrevSubsMsg); - ExpRtn = 19; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SendPrevSubsCmd(&SendPrevSubsMsg)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(19); - if (UT_EventIsInHistory(CFE_SB_PART_SUB_PKT_EID) == false) - { - UT_Text("CFE_SB_PART_SUB_PKT_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PART_SUB_PKT_EID); - CFE_SB_DeletePipe(PipeId0); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Send previous subscriptions test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); + + REPORT(); } /* end Test_Subscribe_SendPrevSubs */ /* @@ -4869,66 +2750,35 @@ void Test_Subscribe_FindGlobalMsgIdCnt(void) CFE_SB_MsgId_t MsgId2 = SB_UT_TLM_MID + 3; uint16 PipeDepth = 50; uint16 MsgLim = 4; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Find Global Message ID Count"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0"); - CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1"); - CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2"); - CFE_SB_Subscribe(MsgId0, PipeId0); - CFE_SB_Subscribe(MsgId1, PipeId0); - CFE_SB_Subscribe(MsgId2, PipeId0); - CFE_SB_Subscribe(MsgId0, PipeId1); - CFE_SB_Subscribe(MsgId1, PipeId1); - CFE_SB_Subscribe(MsgId2, PipeId1); - CFE_SB_SubscribeLocal(MsgId0, PipeId2, MsgLim); + SETUP(CFE_SB_CreatePipe(&PipeId0, PipeDepth, "TestPipe0")); + SETUP(CFE_SB_CreatePipe(&PipeId1, PipeDepth, "TestPipe1")); + SETUP(CFE_SB_CreatePipe(&PipeId2, PipeDepth, "TestPipe2")); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId0)); + SETUP(CFE_SB_Subscribe(MsgId0, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId1, PipeId1)); + SETUP(CFE_SB_Subscribe(MsgId2, PipeId1)); + SETUP(CFE_SB_SubscribeLocal(MsgId0, PipeId2, MsgLim)); /* Set the last list head pointer to NULL for branch path coverage */ CFE_SB.RoutingTbl[2].ListHeadPtr = NULL; - ActRtn = CFE_SB_FindGlobalMsgIdCnt(); - ExpRtn = 2; /* 2 unique msg ids; the third is set to skip */ - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in find global message ID count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_FindGlobalMsgIdCnt(), 2); /* 2 unique msg ids; the third is set to skip */ - ExpRtn = 17; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(17); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_PIPE_ADDED_EID); - if (UT_EventIsInHistory(CFE_SB_PIPE_ADDED_EID) == false) - { - UT_Text("CFE_SB_PIPE_ADDED_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId1)); + TEARDOWN(CFE_SB_DeletePipe(PipeId2)); - CFE_SB_DeletePipe(PipeId0); - CFE_SB_DeletePipe(PipeId1); - CFE_SB_DeletePipe(PipeId2); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Subscribe_API", - "Find global message ID count test"); + REPORT(); } /* end Test_Subscribe_FindGlobalMsgIdCnt */ /* @@ -4938,49 +2788,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 */ /* @@ -4992,122 +2811,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 */ /* @@ -5119,27 +2851,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; @@ -5147,30 +2863,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 */ /* @@ -5178,9 +2880,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(); @@ -5192,9 +2892,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 */ /* @@ -5205,51 +2903,20 @@ void Test_Unsubscribe_Basic(void) CFE_SB_PipeId_t TestPipe; CFE_SB_MsgId_t MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID / 2 + 1; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe Basic"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in unsubscribe basic, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Unsubscribe(MsgId, TestPipe)); - 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_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"); + REPORT(); } /* end Test_Unsubscribe_Basic */ /* @@ -5260,52 +2927,20 @@ void Test_Unsubscribe_Local(void) CFE_SB_PipeId_t TestPipe; CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Local Unsubscribe"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_UnsubscribeLocal(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in local unsubscribe test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_UnsubscribeLocal(CFE_PLATFORM_SB_HIGHEST_VALID_MSGID, TestPipe)); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); - - 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_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", - "Local unsubscribe test"); + REPORT(); } /* end Test_Unsubscribe_Local */ /* @@ -5363,68 +2998,26 @@ void Test_Unsubscribe_NoMatch(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; CFE_SB_MsgRouteIdx_t Idx; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for No Match"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_CreatePipe(&TestPipe, PipeDepth, "TestPipe"); CFE_SB_Subscribe(MsgId, TestPipe); - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId + 1, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in no match test (bad MsgId), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Unsubscribe(MsgId + 1, TestPipe)); /* Get index into routing table */ Idx = CFE_SB_GetRoutingTblIdx(CFE_SB_ConvertMsgIdtoMsgKey(MsgId)); CFE_SB.RoutingTbl[CFE_SB_RouteIdxToValue(Idx)].ListHeadPtr->PipeId = 1; CFE_SB.RoutingTbl[CFE_SB_RouteIdxToValue(Idx)].ListHeadPtr->Next = NULL; - ExpRtn = CFE_SUCCESS; - ActRtn = CFE_SB_Unsubscribe(MsgId, TestPipe); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in no match test (bad routing table), " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_Unsubscribe(MsgId, TestPipe)); - ExpRtn = 6; - ActRtn = UT_GetNumEventsSent(); - - 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(6); - if (UT_EventIsInHistory(CFE_SB_UNSUB_NO_SUBS_EID) == false) - { - UT_Text("CFE_SB_UNSUB_NO_SUBS_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_UNSUB_NO_SUBS_EID); CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", "No match test"); + REPORT(); } /* end Test_Unsubscribe_NoMatch */ /* @@ -5435,51 +3028,20 @@ 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); - - 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; - } - - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, TestPipe + 1), 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(4); - if (UT_EventIsInHistory(CFE_SB_UNSUB_INV_PIPE_EID) == false) - { - UT_Text("CFE_SB_UNSUB_INV_PIPE_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_UNSUB_INV_PIPE_EID); CFE_SB_DeletePipe(TestPipe); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", "Invalid pipe test"); + REPORT(); } /* end Test_Unsubscribe_InvalidPipe */ /* @@ -5491,71 +3053,30 @@ void Test_Unsubscribe_InvalidPipeOwner(void) CFE_SB_MsgId_t MsgId = SB_UT_TLM_MID; uint32 RealOwner; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Pipe Owner"); -#endif + START(); SB_ResetUnitTest(); - ActRtn = CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "First return was unexpected in unsubscribe - non owner " - "Test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* Change owner of pipe through memory corruption */ RealOwner = CFE_SB.PipeTbl[PipeId].AppId; /* Choose a value that is sure not be owner */ CFE_SB.PipeTbl[PipeId].AppId = RealOwner + 1; - ActRtn = CFE_SB_Unsubscribe(MsgId, PipeId); - ExpRtn = CFE_SB_BAD_ARGUMENT; + ASSERT_EQ(CFE_SB_Unsubscribe(MsgId, PipeId), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Second return was unexpected in unsubscribe - non owner " - "Test, exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + EVTSENT(CFE_SB_UNSUB_INV_CALLER_EID); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + CFE_SB.PipeTbl[PipeId].AppId = RealOwner; - if (UT_EventIsInHistory(CFE_SB_UNSUB_INV_CALLER_EID) == false) - { - UT_Text("CFE_SB_UNSUB_INV_CALLER_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB.PipeTbl[PipeId].AppId = RealOwner; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_Unsubscribe_API", - "Invalid pipe owner test"); + REPORT(); } /* end Test_Unsubscribe_InvalidPipeOwner */ /* @@ -5569,58 +3090,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 */ /* @@ -5634,58 +3125,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 */ /* @@ -5698,51 +3160,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 */ /* @@ -5750,9 +3188,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(); @@ -5774,9 +3210,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 */ /* @@ -5784,48 +3218,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 */ /* @@ -5835,63 +3237,31 @@ void Test_SendMsg_InvalidMsgId(void) { SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Invalid Message ID"); -#endif + START(); SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, sizeof(TlmPkt), true); - + CFE_SB_SetMsgId(TlmPktPtr, 0xFFFF); - + CCSDS_WR_APID(TlmPktPtr->Hdr, 0x7FF ); #ifdef MESSAGE_FORMAT_IS_CCSDS_VER_2 - + CCSDS_WR_SUBSYSTEM_ID(TlmPktPtr->SpacePacket.ApidQ, 0x7E ); - -#endif - - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - - ExpRtn = CFE_SB_BAD_ARGUMENT; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid message test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } +#endif - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SendMsg(TlmPktPtr), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_INV_MSGID_EID) == false) - { - UT_Text("CFE_SB_SEND_INV_MSGID_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_INV_MSGID_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "Invalid message ID test"); + REPORT(); } /* end Test_SendMsg_InvalidMsgId */ /* @@ -5902,49 +3272,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 */ /* @@ -5955,50 +3295,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 */ /* @@ -6011,45 +3320,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 */ /* @@ -6063,180 +3348,57 @@ void Test_SendMsg_SequenceCount(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; uint32 PipeDepth = 10; - int32 TestStat = CFE_PASS; - int32 ExpRtn; - int32 ActRtn; -#ifdef UT_VERBOSE - UT_Text("Begin Test for Telemetry Sequence Count"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SeqCntTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CCSDS_WR_SEQ(TlmPktPtr->Hdr, 22); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT_TRUE(PtrToMsg != NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv 1 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv 1 in sequence count test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 1) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=1, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 1); - ActRtn = CFE_SB_PassMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_PassMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from pass in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT_TRUE(PtrToMsg != NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv 2 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv 2 in sequence count test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 22) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for pass in sequence count test, " - "exp=22, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 22); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send 2 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from rcv 3 in sequence count test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - else if (PtrToMsg == NULL) - { - UT_Text("Unexpected NULL return from rcv 3 in sequence count test"); - TestStat = CFE_FAIL; - } - else if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 2) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=2, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(PtrToMsg != NULL); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(CCSDS_RD_SEQ(PtrToMsg->Hdr) == 2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_Unsubscribe(MsgId, PipeId); /* should have no subscribers now */ + SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); /* should have no subscribers now */ - CFE_SB_SendMsg(TlmPktPtr); /* increment to 3 */ + SETUP(CFE_SB_SendMsg(TlmPktPtr)); /* increment to 3 */ - CFE_SB_Subscribe(MsgId, PipeId); /* resubscribe so we can receive a msg */ + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* resubscribe so we can receive a msg */ - CFE_SB_SendMsg(TlmPktPtr); /* increment to 4 */ + SETUP(CFE_SB_SendMsg(TlmPktPtr)); /* increment to 4 */ - CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); + SETUP(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (CCSDS_RD_SEQ(PtrToMsg->Hdr) != 4) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected sequence count for send in sequence count test, " - "exp=4, act=%d", - CCSDS_RD_SEQ(PtrToMsg->Hdr)); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CCSDS_RD_SEQ(PtrToMsg->Hdr), 4); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Telemetry sequence count test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SendMsg_SequenceCount */ /* @@ -6249,53 +3411,23 @@ 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); 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; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - 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; - } - 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"); + REPORT(); } /* end Test_SendMsg_QueuePutError */ /* @@ -6308,69 +3440,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; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - 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; - } + EVTCNT(5); - ExpRtn = 5; - ActRtn = UT_GetNumEventsSent(); + EVTSENT(CFE_SB_Q_FULL_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_Q_FULL_ERR_EID) == false) - { - UT_Text("CFE_SB_Q_FULL_ERR_EID not sent"); - TestStat = CFE_FAIL; - } - - 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 */ /* @@ -6383,13 +3475,8 @@ 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); @@ -6399,57 +3486,21 @@ void Test_SendMsg_MsgLimitExceeded(void) CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1); /* First 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 return in message limit test1, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } /* 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(); - 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_MSGID_LIM_ERR_EID) == false) - { - UT_Text("CFE_SB_MSGID_LIM_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_MSGID_LIM_ERR_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Msg Limit Exceeded test"); + REPORT(); } /* end Test_SendMsg_MsgLimitExceeded */ /* @@ -6462,13 +3513,8 @@ 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; @@ -6480,40 +3526,15 @@ void Test_SendMsg_GetPoolBufErr(void) * 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; + ASSERT_EQ(CFE_SB_SendMsg(TlmPktPtr), 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; - } - 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_GET_BUF_ERR_EID) == false) - { - UT_Text("CFE_SB_GET_BUF_ERR_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_GET_BUF_ERR_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", "GetPoolBufErr test"); + REPORT(); } /* end Test_SendMsg_GetPoolBufErr */ /* @@ -6524,13 +3545,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(); @@ -6538,67 +3554,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 @@ -6607,60 +3578,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; + ASSERT_TRUE((cpuaddr) CFE_SB_ZeroCopyGetPtr(MsgSize, &ZeroCpyBufHndl) != (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; - } - - ExpRtn = (MsgSize + sizeof(CFE_SB_BufferD_t)) * 5; - ActRtn = CFE_SB.StatTlmMsg.Payload.PeakMemInUse; - - 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; - } + ASSERT_TRUE(CFE_SB.StatTlmMsg.Payload.PeakMemInUse == (MsgSize + sizeof(CFE_SB_BufferD_t)) * 5); - ExpRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 1; - ActRtn = CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse; + ASSERT_TRUE(CFE_SB.StatTlmMsg.Payload.PeakSBBuffersInUse == CFE_SB.StatTlmMsg.Payload.SBBuffersInUse + 1); - 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; - } - - 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 */ /* @@ -6675,26 +3601,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); @@ -6702,83 +3618,23 @@ 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; + ASSERT_TRUE(PtrToMsg != NULL); - 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_EQ(CCSDS_RD_SEQ(PtrToMsg->Hdr), 1); - 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; - } + EVTCNT(3); - 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; - } - - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "CFE_SB_ZeroCopySend test"); + REPORT(); } /* end Test_SendMsg_ZeroCopySend */ /* @@ -6794,17 +3650,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); @@ -6821,45 +3674,15 @@ void Test_SendMsg_ZeroCopyPass(void) /* Test response to a get pool information error */ UT_SetDeferredRetcode(UT_KEY(CFE_ES_GetPoolBufInfo), 1, -1); - ActRtn = CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl); - ExpRtn = CFE_SB_BUFFER_INVALID; + ASSERT_EQ(CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl), CFE_SB_BUFFER_INVALID); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in zero copy pass test (get " - "pool information) exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } /* Test a successful zero copy pass */ - ActRtn = CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_ZeroCopyPass(ZeroCpyMsgPtr, ZeroCpyBufHndl)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in zero copy pass test " - "(success), exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from receive in zero copy pass test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } if (PtrToMsg == NULL) { @@ -6876,28 +3699,12 @@ 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; - } - - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "CFE_SB_ZeroCopyPass test"); + REPORT(); } /* end Test_SendMsg_ZeroCopyPass */ /* @@ -6912,153 +3719,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; - } + */ + UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 2, -1); + 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 */ /* @@ -7072,56 +3773,26 @@ 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; - } - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Disabled destination test"); + REPORT(); } /* end Test_SendMsg_DisabledDestination */ /* @@ -7144,13 +3815,8 @@ 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(); @@ -7159,36 +3825,14 @@ void Test_SendMsg_SendWithMetadata(void) 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; - } + ASSERT(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_DO_NOT_INCREMENT, + CFE_SB_SEND_ZEROCOPY)); - 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); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Send with metadata test"); + REPORT(); } /* end Test_SendMsg_SendWithMetadata */ @@ -7199,13 +3843,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), @@ -7219,42 +3858,16 @@ void Test_SendMsg_InvalidMsgId_ZeroCopy(void) { CFE_SB_InitMsg(TlmPktPtr, CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1, sizeof(SB_UT_Test_Tlm_t), true); - ActRtn = CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, - CFE_SB_SEND_ZEROCOPY); - ExpRtn = CFE_SB_BAD_ARGUMENT; + ASSERT_EQ(CFE_SB_SendMsgFull(TlmPktPtr, CFE_SB_INCREMENT_TLM, + CFE_SB_SEND_ZEROCOPY), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in invalid message ID test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } } - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(1); - if (UT_EventIsInHistory(CFE_SB_SEND_INV_MSGID_EID) == false) - { - UT_Text("CFE_SB_SEND_INV_MSGID_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SEND_INV_MSGID_EID); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_SendMsg_API", - "Invalid message ID test (ZeroCopy)"); + REPORT(); } /* end Test_SendMsg_InvalidMsgId_ZeroCopy */ /* @@ -7266,13 +3879,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), @@ -7285,42 +3893,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 */ /* @@ -7332,13 +3914,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), @@ -7351,42 +3928,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 */ /* @@ -7394,9 +3944,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(); @@ -7410,9 +3958,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 */ /* @@ -7422,49 +3968,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 */ /* @@ -7476,51 +3993,20 @@ 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; - - 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(); - 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(2); - if (UT_EventIsInHistory(CFE_SB_RCV_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_RCV_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_RCV_BAD_ARG_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Invalid timeout test"); + REPORT(); } /* end Test_RcvMsg_InvalidTimeout */ /* @@ -7531,50 +4017,20 @@ 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; - - 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(); - 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_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_RcvMsg_API", "Poll receive test"); + REPORT(); } /* end Test_RcvMsg_Poll */ /* @@ -7584,51 +4040,20 @@ 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; - - 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(); - 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_ERR1_EID) == false) - { - UT_Text("CFE_SB_LSTSNDER_ERR1_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_LSTSNDER_ERR1_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId null pointer test"); + REPORT(); } /* end Test_RcvMsg_GetLastSenderNull */ /* @@ -7640,51 +4065,21 @@ 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"); + REPORT(); } /* end Test_RcvMsg_GetLastSenderInvalidPipe */ /* @@ -7696,57 +4091,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; - } + ASSERT_EQ(CFE_SB_GetLastSenderId(&GLSPtr, PipeId), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(2); - if (UT_EventIsInHistory(CFE_SB_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 */ /* @@ -7757,45 +4121,19 @@ void Test_RcvMsg_GetLastSenderSuccess(void) CFE_SB_PipeId_t PipeId; CFE_SB_SenderId_t *GLSPtr; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test for GetLastSender Success"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); - ActRtn = CFE_SB_GetLastSenderId(&GLSPtr, PipeId); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in GetLastSenderId Success Test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_GetLastSenderId(&GLSPtr, PipeId)); - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(1); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", - "GetLastSenderId Success Test"); + REPORT(); } /* end Test_RcvMsg_GetLastSenderSuccess */ /* @@ -7807,52 +4145,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"); 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; - } - - ExpRtn = 1; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_RcvMsg(&PtrToMsg, PipeId, TimeOut), CFE_SB_TIME_OUT); - 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_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_RcvMsg_API", "Timeout receive test"); + REPORT(); } /* end Test_RcvMsg_Timeout */ /* @@ -7863,51 +4171,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"); 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(); - 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_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, "Test_RcvMsg_API", "Pipe read error test"); + REPORT(); } /* end Test_RcvMsg_PipeReadError */ /* @@ -7922,77 +4200,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"); 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; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - 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; - } - if (PtrToMsg != NULL) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Received Msg 0x%x", (unsigned int)CFE_SB_GetMsgId(PtrToMsg)); -#ifdef UT_VERBOSE - UT_Text(cMsg); -#endif - } + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(PtrToMsg != NULL); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); PipeDscPtr = CFE_SB_GetPipePtr(PipeId); PipeDscPtr->ToTrashBuff = PipeDscPtr->CurrentBuff; PipeDscPtr->CurrentBuff = NULL; - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Pend forever test"); + + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + REPORT(); } /* end Test_RcvMsg_PendForever */ /* @@ -8003,16 +4234,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); @@ -8020,11 +4246,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 @@ -8034,39 +4256,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 */ /* @@ -8076,51 +4274,20 @@ 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; - - 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(); - 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(2); - if (UT_EventIsInHistory(CFE_SB_RCV_BAD_ARG_EID) == false) - { - UT_Text("CFE_SB_RCV_BAD_ARG_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_RCV_BAD_ARG_EID); CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "Test_RcvMsg_API", "Invalid buffer pointer test"); + REPORT(); } /* end Test_RcvMsg_InvalidBufferPtr */ /* @@ -8128,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(); @@ -8143,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 */ /* @@ -8153,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 */ /* @@ -8169,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_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 */ /* @@ -8199,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_CMD_MID, sizeof(SBCmd), false); - UT_Report(__FILE__, __LINE__, - result, "SB_TestInitMsg_False", - "Leave message content"); + + REPORT(); } /* end Test_CFE_SB_InitMsg_False */ /* @@ -8229,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 */ /* @@ -8358,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(); @@ -8374,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, @@ -8389,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(); @@ -8411,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) @@ -8433,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(); @@ -8455,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 */ /* @@ -8468,12 +4576,9 @@ void Test_CFE_SB_SetGetMsgId(void) SB_UT_Test_Cmd_t SBCmd; CFE_SB_MsgPtr_t SBCmdPtr = (CFE_SB_MsgPtr_t) &SBCmd; CFE_SB_MsgId_t MsgIdReturned; - uint32 TestStat; uint32 i; -#ifdef UT_VERBOSE - UT_Text("Begin Test_CFE_SB_SetGetMsgId"); -#endif + START(); /* Test setting and getting the message ID of a message */ SB_ResetUnitTest(); @@ -8494,9 +4599,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 @@ -8504,20 +4607,19 @@ void Test_CFE_SB_SetGetMsgId(void) SB_ResetUnitTest(); TestStat = CFE_PASS; - + /* Looping through every value from 0 to 0xffff */ for (i = 0; i <= 0xFFFF; i++) { CFE_SB_SetMsgId(SBCmdPtr, i); - + if (CFE_SB_GetMsgId(SBCmdPtr) != i) { break; } } - UT_Report(__FILE__, __LINE__, - i == 0x10000, "Test_CFE_SB_SetGetMsgId", "Loop test"); + REPORT(); } /* end Test_CFE_SB_SetGetMsgId */ /* @@ -8531,27 +4633,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); @@ -8573,19 +4673,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); @@ -8606,24 +4704,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 || @@ -8639,20 +4735,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); @@ -8673,9 +4767,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 */ /* @@ -8689,14 +4781,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 */ @@ -8725,9 +4815,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(); @@ -8754,9 +4842,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(); @@ -8783,9 +4869,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(); @@ -8812,9 +4896,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 */ /* @@ -8829,12 +4911,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(); @@ -8845,7 +4925,7 @@ void Test_CFE_SB_SetGetMsgTime(void) /* Set MsgId */ CFE_SB_SetMsgId(SBCmdPtr, SB_UT_CMD_MID); - + SetTime.Seconds = 0x4321; SetTime.Subseconds = 0x8765; @@ -8878,9 +4958,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(); @@ -8892,7 +4970,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; @@ -8925,9 +5003,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(); @@ -8935,7 +5011,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 */ @@ -8974,9 +5050,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(); @@ -9019,9 +5093,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 */ /* @@ -9033,11 +5105,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(); @@ -9080,9 +5149,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 */ /* @@ -9096,16 +5163,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 @@ -9121,13 +5186,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); @@ -9152,9 +5217,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 @@ -9167,11 +5230,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); @@ -9197,9 +5260,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 @@ -9214,9 +5275,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); @@ -9242,9 +5303,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 @@ -9259,9 +5318,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); @@ -9287,9 +5346,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 */ /* @@ -9306,11 +5363,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(); @@ -9320,11 +5374,11 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_InitMsg(SBCmdPtr, 0x1805, sizeof(SBCmd), true); CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1805 ); - + /* Set checksum field */ - + CFE_SB_GenerateChecksum(SBCmdPtr); - + RtnFrmGet = CFE_SB_GetChecksum(SBCmdPtr); #ifndef MESSAGE_FORMAT_IS_CCSDS_VER_2 ExpRtnFrmGet = 0x2f; @@ -9352,7 +5406,7 @@ void Test_CFE_SB_ChecksumUtils(void) * return false */ CCSDS_WR_SID( (*((CCSDS_PriHdr_t*) SBCmdPtr)), 0x1806 ); - + RtnFrmValidate = CFE_SB_ValidateChecksum(SBCmdPtr); ExpRtnFrmVal = false; @@ -9366,9 +5420,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(); @@ -9378,9 +5430,9 @@ void Test_CFE_SB_ChecksumUtils(void) CFE_SB_InitMsg(SBNoSecHdrPktPtr, 0x1005, sizeof(SBNoSecHdrPkt), true); - + CCSDS_WR_SHDR( SBNoSecHdrPktPtr->Hdr, 0 ); - + /* Set checksum field */ CFE_SB_GenerateChecksum(SBNoSecHdrPktPtr); RtnFrmGet = CFE_SB_GetChecksum(SBNoSecHdrPktPtr); @@ -9406,7 +5458,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; @@ -9421,9 +5473,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(); @@ -9469,9 +5519,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(); @@ -9519,40 +5567,33 @@ void Test_CFE_SB_ChecksumUtils(void) TestStat = CFE_FAIL; } - UT_Report(__FILE__, __LINE__, - TestStat, "Test_CFE_SB_ChecksumUtils", - "Telemetry packet without secondary header test"); + REPORT(); } /* end Test_CFE_SB_ChecksumUtils */ - /* ** Test validating a msg id */ void Test_CFE_SB_ValidateMsgId(void) { - CFE_SB_MsgId_t MsgId; - uint32 ActualReturn; + + START(); SB_ResetUnitTest(); - + /* Validate Msg Id */ MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID; - ActualReturn = CFE_SB_ValidateMsgId(MsgId); + CFE_SB_ValidateMsgId(MsgId); + + REPORT(); + + START(); - UT_Report(__FILE__, __LINE__, - ActualReturn == CFE_SUCCESS, - "CFE_SB_ValidateMsgId", - "Testing validation for a valid MsgId"); - /* Test for invalid msg id */ MsgId = CFE_PLATFORM_SB_HIGHEST_VALID_MSGID + 1; - ActualReturn = CFE_SB_ValidateMsgId(MsgId); - - UT_Report(__FILE__, __LINE__, - ActualReturn == CFE_SB_FAILED, - "CFE_SB_ValidateMsgId", - "Testing validation for an invalid MsgId"); + CFE_SB_ValidateMsgId(MsgId); + + REPORT(); } /* @@ -9560,6 +5601,8 @@ void Test_CFE_SB_ValidateMsgId(void) */ void Test_SB_SpecialCases(void) { + STARTBLOCK(); + Test_OS_MutSem_ErrLogic(); Test_ReqToSendEvent_ErrLogic(); Test_PutDestBlk_ErrLogic(); @@ -9570,8 +5613,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 @@ -9579,52 +5623,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 @@ -9638,34 +5655,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 */ @@ -9677,47 +5671,24 @@ void Test_OS_MutSem_ErrLogic(void) CFE_SB_PipeId_t PipeId; CFE_SB_MsgId_t MsgId = SB_UT_CMD_MID; uint16 PipeDepth = 50; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; -#ifdef UT_VERBOSE - UT_Text("Begin Test Shared Semaphore Give/Take Failure"); -#endif + START(); SB_ResetUnitTest(); UT_SetDeferredRetcode(UT_KEY(OS_MutSemTake), 1, CFE_OS_SEM_FAILURE); UT_SetDeferredRetcode(UT_KEY(OS_MutSemGive), 2, CFE_OS_SEM_FAILURE); CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); CFE_SB_Subscribe(MsgId, PipeId); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); - 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(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_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_(Un)LockSharedData", - "Semaphore give/take failure test"); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_OS_MutSemTake_ErrLogic */ /* @@ -9727,13 +5698,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(); @@ -9741,48 +5707,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 */ /* @@ -9791,42 +5725,14 @@ void Test_ReqToSendEvent_ErrLogic(void) */ void Test_PutDestBlk_ErrLogic(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test PutDestBlk Error"); -#endif + START(); SB_ResetUnitTest(); - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_PutDestinationBlk(NULL); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_PutDestinationBlk(NULL), CFE_SB_BAD_ARGUMENT); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(0); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_PutDestinationBlk", - "PutDestBlk error test"); + REPORT(); } /* end Test_PutDestBlk_ErrLogic */ /* @@ -9834,44 +5740,16 @@ void Test_PutDestBlk_ErrLogic(void) */ void Test_CFE_SB_GetPipeIdx(void) { - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test GetPipeIdx"); -#endif + START(); SB_ResetUnitTest(); CFE_SB.PipeTbl[0].PipeId = 0; CFE_SB.PipeTbl[0].InUse = CFE_SB_NOT_IN_USE; - ExpRtn = CFE_SB_INVALID_PIPE; - ActRtn = CFE_SB_GetPipeIdx(0); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + 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 */ /* @@ -9879,139 +5757,55 @@ void Test_CFE_SB_GetPipeIdx(void) */ void Test_CFE_SB_Buffers(void) { - int32 ExpRtn = sizeof(CFE_SB_BufferD_t) * 4; - int32 ActRtn; - int32 TestStat = CFE_PASS; + int32 ExpRtn; + CFE_SB_BufferD_t *bd; -#ifdef UT_VERBOSE - UT_Text("Begin Test GetBufferFromPool"); -#endif + START(); SB_ResetUnitTest(); CFE_SB.StatTlmMsg.Payload.MemInUse = 0; - CFE_SB.StatTlmMsg.Payload.PeakMemInUse = ExpRtn; + CFE_SB.StatTlmMsg.Payload.PeakMemInUse = sizeof(CFE_SB_BufferD_t) * 4; bd = CFE_SB_GetBufferFromPool(0, 0); - ActRtn = CFE_SB.StatTlmMsg.Payload.PeakMemInUse; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected PeakmemInUse value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.PeakMemInUse, sizeof(CFE_SB_BufferD_t) * 4); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_GetBufferFromPool", - "GetBufferFromPool branch path coverage test"); + START(); - TestStat = CFE_PASS; ExpRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB_ReturnBufferToPool(bd); - ActRtn = CFE_SB.StatTlmMsg.Payload.SBBuffersInUse; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected SBBuffersInUse value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.SBBuffersInUse, ExpRtn); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_ReturnBufferToPool", - "ReturnBufferToPool branch path coverage test"); + START(); - TestStat = CFE_PASS; - ExpRtn = 0; bd->UseCount = 0; CFE_SB_DecrBufUseCnt(bd); - ActRtn = bd->UseCount; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected UseCount value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(bd->UseCount, 0); - ExpRtn = 0; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(0); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_DecrBufUseCnt", - "DecrBufUseCnt branch path coverage test"); + START(); - TestStat = CFE_PASS; - ExpRtn = 0; UT_SetDeferredRetcode(UT_KEY(CFE_ES_PutPoolBuf), 1, -1); CFE_SB.StatTlmMsg.Payload.MemInUse = 0; CFE_SB_PutDestinationBlk((CFE_SB_DestinationD_t *) bd); - ActRtn = CFE_SB.StatTlmMsg.Payload.MemInUse; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected MemInUse value, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB.StatTlmMsg.Payload.MemInUse, 0); - 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", - "PutDestinationBlk branch path coverage test"); + REPORT(); } /* end Test_CFE_SB_Buffers */ /* @@ -10021,83 +5815,35 @@ void Test_CFE_SB_BadPipeInfo(void) { CFE_SB_PipeId_t PipeId; uint16 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; CFE_SB_Qos_t CFE_SB_Default_Qos; -#ifdef UT_VERBOSE - UT_Text("Begin Test BadPipeInfo"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe1")); /* Set the pipe ID to an erroneous value and attempt to delete the pipe */ CFE_SB.PipeTbl[0].PipeId = 1; CFE_SB.PipeTbl[0].InUse = 1; - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_DeletePipeFull(0, 0); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_EQ(CFE_SB_DeletePipeFull(0, 0), CFE_SB_BAD_ARGUMENT); - ExpRtn = 2; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(2); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_DeletePipeFull", - "DeletePipeFull bad pipe information branch path coverage test"); + START(); /* Reset the pipe ID and delete the pipe */ CFE_SB.PipeTbl[0].PipeId = 0; - TestStat = CFE_PASS; - ExpRtn = CFE_SB_BAD_ARGUMENT; - ActRtn = CFE_SB_SubscribeFull(0 ,0, CFE_SB_Default_Qos, - CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, 2); - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - ExpRtn = 4; - ActRtn = UT_GetNumEventsSent(); + ASSERT_EQ(CFE_SB_SubscribeFull(0 ,0, CFE_SB_Default_Qos, + CFE_PLATFORM_SB_DEFAULT_MSG_LIMIT, 2), CFE_SB_BAD_ARGUMENT); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(4); - CFE_SB_DeletePipe(PipeId); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SubscribeFull", - "SubscribeFull bad pipe information branch path coverage test"); + REPORT(); } /* end Test_CFE_SB_BadPipeInfo */ /* @@ -10112,13 +5858,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(); @@ -10128,11 +5869,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); @@ -10140,37 +5877,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; @@ -10178,212 +5889,103 @@ void Test_SB_SendMsgPaths(void) MsgId = SB_UT_CMD_MID; SB_ResetUnitTest(); CFE_SB.SenderReporting = 0; - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in cmd as tlm test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (cmd as tlm), " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - CFE_SB_DeletePipe(PipeId); + START(); /* Test inhibiting sending a "message ID limit error" message */ SB_ResetUnitTest(); MsgId = SB_UT_TLM_MID; CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "MsgLimTestPipe")); /* Set maximum allowed messages on the pipe at one time to 1 */ - CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1); + SETUP(CFE_SB_SubscribeEx(MsgId, PipeId, CFE_SB_Default_Qos, 1)); /* First send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe message limit test 1, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_MSGID_LIM_ERR_EID_BIT); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] = 0; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in pipe message limit test 2, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_MSGID_LIM_ERR_EID)); - if (UT_EventIsInHistory(CFE_SB_MSGID_LIM_ERR_EID) == true) - { - UT_Text("CFE_SB_MSGID_LIM_ERR_EID sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); + REPORT(); + + START(); /* Test inhibiting sending a "pipe full" message */ SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "PipeFullTestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); /* This send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return1 in pipe full test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); /* Tell the QueuePut stub to return OS_QUEUE_FULL on its next call */ UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_QUEUE_FULL); CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_FULL_ERR_EID_BIT); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] = 0; - ExpRtn = CFE_SUCCESS; - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return2 in pipe full test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_Q_FULL_ERR_EID_BIT)); - if (UT_EventIsInHistory(CFE_SB_Q_FULL_ERR_EID_BIT) == true) - { - UT_Text("CFE_SB_Q_FULL_ERR_EID_BIT sent"); - TestStat = CFE_FAIL; - } + EVTCNT(3); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (pipe full), " - "exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + REPORT(); - CFE_SB_DeletePipe(PipeId); + START(); /* Test inhibiting sending a "pipe write error" message */ SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe"); - CFE_SB_Subscribe(MsgId, PipeId); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "TestPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), false); UT_SetDeferredRetcode(UT_KEY(OS_QueuePut), 1, OS_ERROR); CFE_SB.StopRecurseFlags[1] |= CFE_BIT(CFE_SB_Q_WR_ERR_EID_BIT); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); CFE_SB.StopRecurseFlags[1] = 0; - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return in n pipe write error error test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTCNT(3); - ExpRtn = 3; - ActRtn = UT_GetNumEventsSent(); + ASSERT_TRUE(!UT_EventIsInHistory(CFE_SB_Q_WR_ERR_EID)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent (pipe write " - "error), exp=%ld, act=%ld", - (long) ExpRtn, (long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - if (UT_EventIsInHistory(CFE_SB_Q_WR_ERR_EID) == true) - { - UT_Text("CFE_SB_Q_WR_ERR_EID sent"); - TestStat = CFE_FAIL; - } + REPORT(); - CFE_SB_DeletePipe(PipeId); - + START(); /* Setup Test skipping sending to a pipe when the pipe option is set to ignore */ SB_ResetUnitTest(); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "SkipPipe"); - CFE_SB_Subscribe(MsgId, PipeId); - CFE_SB_SetPipeOpts(PipeId, CFE_SB_PIPEOPTS_IGNOREMINE); - + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "SkipPipe")); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + SETUP(CFE_SB_SetPipeOpts(PipeId, CFE_SB_PIPEOPTS_IGNOREMINE)); + /* Test skipping this pipe and the send should pass */ - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; + ASSERT(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return1 in pipe ignore test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - CFE_SB_SetPipeOpts(PipeId, 0); - CFE_SB_DeletePipe(PipeId); - - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_SendMsgFull", - "Send message paths test"); + TEARDOWN(CFE_SB_SetPipeOpts(PipeId, 0)); + TEARDOWN(CFE_SB_DeletePipe(PipeId)); + + REPORT(); } /* end Test_SB_SendMsgPaths */ /* @@ -10398,77 +6000,27 @@ void Test_RcvMsg_UnsubResubPath(void) SB_UT_Test_Tlm_t TlmPkt; CFE_SB_MsgPtr_t TlmPktPtr = (CFE_SB_MsgPtr_t) &TlmPkt; uint32 PipeDepth = 10; - int32 ExpRtn; - int32 ActRtn; - int32 TestStat = CFE_PASS; - -#ifdef UT_VERBOSE - UT_Text("Begin Test for Unsubscribe/Resubscribe Path"); -#endif + START(); SB_ResetUnitTest(); - CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe"); + SETUP(CFE_SB_CreatePipe(&PipeId, PipeDepth, "RcvMsgTestPipe")); CFE_SB_InitMsg(&TlmPkt, MsgId, sizeof(TlmPkt), true); - CFE_SB_Subscribe(MsgId, PipeId); - ActRtn = CFE_SB_SendMsg(TlmPktPtr); - ExpRtn = CFE_SUCCESS; - - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from send in unsub/resub path test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } - - CFE_SB_Unsubscribe(MsgId, PipeId); - CFE_SB_Subscribe(MsgId, PipeId); - ActRtn = CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER); - ExpRtn = CFE_SUCCESS; + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + SETUP(CFE_SB_SendMsg(TlmPktPtr)); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected return from receive in unsub/resub path test, " - "exp=0x%lx, act=0x%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + SETUP(CFE_SB_Unsubscribe(MsgId, PipeId)); + SETUP(CFE_SB_Subscribe(MsgId, PipeId)); + ASSERT(CFE_SB_RcvMsg(&PtrToMsg, PipeId, CFE_SB_PEND_FOREVER)); - if (PtrToMsg != NULL) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Received Msg 0x%x", - (unsigned int) CFE_SB_GetMsgId(PtrToMsg)); -#ifdef UT_VERBOSE - UT_Text(cMsg); -#endif - } + ASSERT_TRUE(PtrToMsg != NULL); - ExpRtn = 6; - ActRtn = UT_GetNumEventsSent(); + EVTCNT(6); - if (ActRtn != ExpRtn) - { - snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, - "Unexpected rtn from UT_GetNumEventsSent, exp=%lx, act=%lx", - (unsigned long) ExpRtn, (unsigned long) ActRtn); - UT_Text(cMsg); - TestStat = CFE_FAIL; - } + EVTSENT(CFE_SB_SUBSCRIPTION_RCVD_EID); - if (UT_EventIsInHistory(CFE_SB_SUBSCRIPTION_RCVD_EID) == false) - { - UT_Text("CFE_SB_SUBSCRIPTION_RCVD_EID not sent"); - TestStat = CFE_FAIL; - } + TEARDOWN(CFE_SB_DeletePipe(PipeId)); - CFE_SB_DeletePipe(PipeId); - UT_Report(__FILE__, __LINE__, - TestStat, "CFE_SB_RcvMsg", "Unsubscribe/resubscribe path test"); + REPORT(); } /* end Test_RcvMsg_UnsubResubPath */ /* @@ -10543,5 +6095,3 @@ void Test_MessageString(void) "CFE_SB_MessageStringGet", "Destination size < source string size"); } /* end Test_MessageString */ - - diff --git a/fsw/cfe-core/unit-test/ut_support.c b/fsw/cfe-core/unit-test/ut_support.c index b09df1840..33ce8126e 100644 --- a/fsw/cfe-core/unit-test/ut_support.c +++ b/fsw/cfe-core/unit-test/ut_support.c @@ -766,6 +766,22 @@ bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, return true; } +bool UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, + const char *ExpName, bool Exp) +{ + char cMsg[UT_MAX_MESSAGE_LENGTH]; + + if(!Exp) + { + snprintf(cMsg, UT_MAX_MESSAGE_LENGTH, "%s (%s:%d) Assert failed (%s)", + TestName, FileName, LineNum, ExpName); + UT_Text(cMsg); + TestStat = CFE_FAIL; + return false; + } + return true; +} + bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp) { char cMsg[UT_MAX_MESSAGE_LENGTH]; diff --git a/fsw/cfe-core/unit-test/ut_support.h b/fsw/cfe-core/unit-test/ut_support.h index 05cb592f1..25afc12df 100644 --- a/fsw/cfe-core/unit-test/ut_support.h +++ b/fsw/cfe-core/unit-test/ut_support.h @@ -701,7 +701,7 @@ CFE_ES_ResetData_t *UT_GetResetDataPtr(void); ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #CFE_PASS, #CFE_FAIL, #START, #REPORT, #SETUP, #ASSERT, #ASSERT_EQ +** \sa #CFE_PASS, #CFE_FAIL, #START, #REPORT, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE ** \sa #EVTCNT, #EVTSENT, #TEARDOWN ** ******************************************************************************/ @@ -761,7 +761,7 @@ void UT_START_impl(const char *FileName, int LineNum, const char *TestName); ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #SETUP, #ASSERT, #ASSERT_EQ, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** \sa #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ #define START() UT_START_impl(__FILE__, __LINE__, __func__) @@ -780,7 +780,7 @@ void UT_REPORT_impl(const char *FileName, int LineNum, const char *TestName); ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #EVTCNT, #EVTSENT, #TEARDOWN +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #TEARDOWN ** ******************************************************************************/ #define REPORT() UT_REPORT_impl(__FILE__, __LINE__, __func__) @@ -800,10 +800,10 @@ bool UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, cons ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #ASSERT, #ASSERT_EQ, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** \sa #START, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define SETUP(FN) if(TestStat == CFE_PASS) UT_SETUP_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) +#define SETUP(FN) (TestStat == CFE_PASS ? UT_SETUP_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) : false) /** \brief Function to be called by the ASSERT() macro */ bool UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); @@ -820,10 +820,10 @@ bool UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, con ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT_EQ, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** \sa #START, #SETUP, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define ASSERT(FN) if(TestStat == CFE_PASS) UT_ASSERT_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) +#define ASSERT(FN) (TestStat == CFE_PASS ? UT_ASSERT_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) : false) /** \brief Function to be called by the ASSERT_EQ() macro */ bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, @@ -842,10 +842,32 @@ bool UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *TestName, ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** \sa #START, #SETUP, #ASSERT, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define ASSERT_EQ(FN,EXP) if(TestStat == CFE_PASS) UT_ASSERT_EQ_impl(__FILE__, __LINE__, __func__, (#FN), (FN), (#EXP), (EXP)) +#define ASSERT_EQ(FN,EXP) (TestStat == CFE_PASS ? UT_ASSERT_EQ_impl(__FILE__, __LINE__, __func__, (#FN), (FN), (#EXP), (EXP)) : false) + +/** \brief Function to be called by the ASSERT_EQ() macro */ +bool UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, + const char *ExpName, bool Exp); + +/*****************************************************************************/ +/** +** \brief Asserts the expected execution of the function being tested. +** +** \par Description +** The core of each unit test is the execution of the function being tested. +** This function and macro should be used to test the execution of the function +** and comparing the return status against the expected return status specified, +** when the return status expected is not CFE_SUCCESS. +** +** \par Assumptions, External Events, and Notes: +** None +** +** \sa #START, #SETUP, #ASSERT, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT, #TEARDOWN +** +******************************************************************************/ +#define ASSERT_TRUE(EXP) (TestStat == CFE_PASS ? UT_ASSERT_TRUE_impl(__FILE__, __LINE__, __func__, (#EXP), (EXP)) : false) /** \brief Function to be called by the EVTCNT() macro */ bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp); @@ -862,10 +884,10 @@ bool UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #EVTSENT, #REPORT, #TEARDOWN +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTSENT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define EVTCNT(EXP) if(TestStat == CFE_PASS) UT_EVTCNT_impl(__FILE__, __LINE__, __func__, (EXP)) +#define EVTCNT(EXP) (TestStat == CFE_PASS ? UT_EVTCNT_impl(__FILE__, __LINE__, __func__, (EXP)) : false) /** \brief Function to be called by the EVTSENT() macro */ bool UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId); @@ -881,10 +903,10 @@ bool UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, co ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #EVTCNT, #REPORT, #TEARDOWN +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #REPORT, #TEARDOWN ** ******************************************************************************/ -#define EVTSENT(EVT) if(TestStat == CFE_PASS) UT_EVTSENT_impl(__FILE__, __LINE__, __func__, (#EVT), (EVT)) +#define EVTSENT(EVT) (TestStat == CFE_PASS ? UT_EVTSENT_impl(__FILE__, __LINE__, __func__, (#EVT), (EVT)) : false) /** \brief Function to be called by the TEARDOWN() macro */ bool UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet); @@ -900,10 +922,10 @@ bool UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, c ** \par Assumptions, External Events, and Notes: ** None ** -** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #EVTCNT, #EVTSENT, #REPORT +** \sa #START, #SETUP, #ASSERT, #ASSERT_EQ, #ASSERT_TRUE, #EVTCNT, #EVTSENT, #REPORT ** ******************************************************************************/ -#define TEARDOWN(FN) if(TestStat == CFE_PASS) UT_TEARDOWN_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) +#define TEARDOWN(FN) (TestStat == CFE_PASS ? UT_TEARDOWN_impl(__FILE__, __LINE__, __func__, (#FN), (FN)) : false) /*****************************************************************************/ /**