Skip to content

Commit 8c4cf23

Browse files
committed
Fix #1626, rename/clean CFE coverage assert macros
Rename CFE coverage test assert macros in ut_support.h to have consistent name prefix. Also adds a "VOIDCALL" and "RESOURCEID_EQ" macro for logging void functions and ID checks, respectively.
1 parent d03e24e commit 8c4cf23

File tree

18 files changed

+1438
-1403
lines changed

18 files changed

+1438
-1403
lines changed

modules/core_private/ut-stubs/inc/ut_support.h

Lines changed: 129 additions & 62 deletions
Large diffs are not rendered by default.

modules/core_private/ut-stubs/src/ut_support.c

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -693,47 +693,3 @@ void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(voi
693693

694694
UtTest_Add(Test, Setup, Teardown, strdup(CompleteTestName));
695695
}
696-
697-
void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet)
698-
{
699-
UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TSF, FileName, LineNum, "%s - Setup - %s returned 0x%lx",
700-
TestName, FnName, (long int)FnRet);
701-
}
702-
703-
void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet)
704-
{
705-
UtAssertEx(FnRet == CFE_SUCCESS, UtAssert_GetContext(), FileName, LineNum,
706-
"%s - %s returned 0x%lx, expected CFE_SUCCESS", TestName, FnName, (long int)FnRet);
707-
}
708-
709-
void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *FnName, int32 FnRet, const char *ExpName,
710-
int32 Exp)
711-
{
712-
UtAssertEx(FnRet == Exp, UtAssert_GetContext(), FileName, LineNum, "%s - value %ld 0x%lx, expected %s[%ld 0x%lx]",
713-
FnName, (long)FnRet, (long)FnRet, ExpName, (long)Exp, (long)Exp);
714-
}
715-
716-
void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, const char *ExpName, bool Exp)
717-
{
718-
UtAssertEx(Exp, UtAssert_GetContext(), FileName, LineNum, "%s - %s", TestName, ExpName);
719-
}
720-
721-
void UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp)
722-
{
723-
int32 CntSent = UT_GetNumEventsSent();
724-
725-
UtAssertEx(CntSent == CntExp, UtAssert_GetContext(), FileName, LineNum, "%s - event count (sent %ld, expected %ld)",
726-
TestName, (long int)CntSent, (long int)CntExp);
727-
}
728-
729-
void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId)
730-
{
731-
UtAssertEx(UT_EventIsInHistory(EvtId), UtAssert_GetContext(), FileName, LineNum, "%s - sent event %s [%ld]",
732-
TestName, EvtName, (long int)EvtId);
733-
}
734-
735-
void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet)
736-
{
737-
UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TTF, FileName, LineNum,
738-
"%s - Teardown failed (%s returned 0x%lx)", TestName, FnName, (long int)FnRet);
739-
}

modules/es/ut-coverage/es_UT.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ void TestStartupErrorPaths(void)
10301030
/* This prep is necessary so GetAppId works */
10311031
ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppType_CORE, NULL, &AppRecPtr, NULL);
10321032
CFE_ES_Global.SystemState = CFE_ES_SystemState_CORE_READY;
1033-
ASSERT(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 0));
1033+
CFE_UtAssert_SUCCESS(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 0));
10341034
}
10351035

10361036
void TestApps(void)

modules/evs/ut-coverage/evs_UT.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,8 @@ void Test_Init(void)
245245
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false);
246246

247247
UT_EVS_DoGenericCheckEvents(CFE_EVS_TaskMain, &UT_EVS_EventBuf);
248-
ASSERT_TRUE(UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[8]));
249-
ASSERT_EQ(UT_EVS_EventBuf.EventID, CFE_EVS_ERR_MSGID_EID);
248+
CFE_UtAssert_SyslogIsInHistory(EVS_SYSLOG_MSGS[8]);
249+
UtAssert_INT32_EQ(UT_EVS_EventBuf.EventID, CFE_EVS_ERR_MSGID_EID);
250250

251251
/* Test early initialization with a get reset area failure */
252252
UT_InitData();
@@ -716,13 +716,13 @@ void Test_Format(void)
716716
CFE_EVS_SendEvent(0, CFE_EVS_EventType_INFORMATION, "Short format check 1");
717717

718718
/* Note implementation initializes both short and long message */
719-
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_Init)), 2);
720-
ASSERT_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1);
721-
ASSERT_TRUE(CFE_SB_MsgId_Equal(MsgData.MsgId, ShortFmtSnapshotData.MsgId));
722-
ASSERT_TRUE(!CFE_SB_MsgId_Equal(MsgData.MsgId, LongFmtSnapshotData.MsgId));
719+
UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_MSG_Init)), 2);
720+
UtAssert_INT32_EQ(UT_GetStubCount(UT_KEY(CFE_SB_TransmitMsg)), 1);
721+
UtAssert_INT32_EQ(CFE_SB_MsgId_Equal(MsgData.MsgId, ShortFmtSnapshotData.MsgId), true);
722+
UtAssert_INT32_EQ(CFE_SB_MsgId_Equal(MsgData.MsgId, LongFmtSnapshotData.MsgId), false);
723723

724724
/* Confirm the right message was sent */
725-
ASSERT_TRUE(MsgSend == MsgData.MsgPtr);
725+
UtAssert_ADDRESS_EQ(MsgSend, MsgData.MsgPtr);
726726

727727
/* Test set event format mode command using a valid command to set long
728728
* format, reports implicitly via event

0 commit comments

Comments
 (0)