Skip to content

Commit

Permalink
Fix #1626, rename/clean CFE coverage assert macros
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jphickey committed Jun 17, 2021
1 parent d03e24e commit 8c4cf23
Show file tree
Hide file tree
Showing 18 changed files with 1,438 additions and 1,403 deletions.
191 changes: 129 additions & 62 deletions modules/core_private/ut-stubs/inc/ut_support.h

Large diffs are not rendered by default.

44 changes: 0 additions & 44 deletions modules/core_private/ut-stubs/src/ut_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -693,47 +693,3 @@ void UT_AddSubTest(void (*Test)(void), void (*Setup)(void), void (*Teardown)(voi

UtTest_Add(Test, Setup, Teardown, strdup(CompleteTestName));
}

void UT_SETUP_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet)
{
UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TSF, FileName, LineNum, "%s - Setup - %s returned 0x%lx",
TestName, FnName, (long int)FnRet);
}

void UT_ASSERT_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet)
{
UtAssertEx(FnRet == CFE_SUCCESS, UtAssert_GetContext(), FileName, LineNum,
"%s - %s returned 0x%lx, expected CFE_SUCCESS", TestName, FnName, (long int)FnRet);
}

void UT_ASSERT_EQ_impl(const char *FileName, int LineNum, const char *FnName, int32 FnRet, const char *ExpName,
int32 Exp)
{
UtAssertEx(FnRet == Exp, UtAssert_GetContext(), FileName, LineNum, "%s - value %ld 0x%lx, expected %s[%ld 0x%lx]",
FnName, (long)FnRet, (long)FnRet, ExpName, (long)Exp, (long)Exp);
}

void UT_ASSERT_TRUE_impl(const char *FileName, int LineNum, const char *TestName, const char *ExpName, bool Exp)
{
UtAssertEx(Exp, UtAssert_GetContext(), FileName, LineNum, "%s - %s", TestName, ExpName);
}

void UT_EVTCNT_impl(const char *FileName, int LineNum, const char *TestName, int32 CntExp)
{
int32 CntSent = UT_GetNumEventsSent();

UtAssertEx(CntSent == CntExp, UtAssert_GetContext(), FileName, LineNum, "%s - event count (sent %ld, expected %ld)",
TestName, (long int)CntSent, (long int)CntExp);
}

void UT_EVTSENT_impl(const char *FileName, int LineNum, const char *TestName, const char *EvtName, int32 EvtId)
{
UtAssertEx(UT_EventIsInHistory(EvtId), UtAssert_GetContext(), FileName, LineNum, "%s - sent event %s [%ld]",
TestName, EvtName, (long int)EvtId);
}

void UT_TEARDOWN_impl(const char *FileName, int LineNum, const char *TestName, const char *FnName, int32 FnRet)
{
UtAssertEx(FnRet == CFE_SUCCESS, UTASSERT_CASETYPE_TTF, FileName, LineNum,
"%s - Teardown failed (%s returned 0x%lx)", TestName, FnName, (long int)FnRet);
}
2 changes: 1 addition & 1 deletion modules/es/ut-coverage/es_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ void TestStartupErrorPaths(void)
/* This prep is necessary so GetAppId works */
ES_UT_SetupSingleAppId(CFE_ES_AppType_EXTERNAL, CFE_ES_AppType_CORE, NULL, &AppRecPtr, NULL);
CFE_ES_Global.SystemState = CFE_ES_SystemState_CORE_READY;
ASSERT(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 0));
CFE_UtAssert_SUCCESS(CFE_ES_WaitForSystemState(CFE_ES_SystemState_CORE_READY, 0));
}

void TestApps(void)
Expand Down
14 changes: 7 additions & 7 deletions modules/evs/ut-coverage/evs_UT.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ void Test_Init(void)
UT_SetDataBuffer(UT_KEY(CFE_MSG_GetMsgId), &msgid, sizeof(msgid), false);

UT_EVS_DoGenericCheckEvents(CFE_EVS_TaskMain, &UT_EVS_EventBuf);
ASSERT_TRUE(UT_SyslogIsInHistory(EVS_SYSLOG_MSGS[8]));
ASSERT_EQ(UT_EVS_EventBuf.EventID, CFE_EVS_ERR_MSGID_EID);
CFE_UtAssert_SyslogIsInHistory(EVS_SYSLOG_MSGS[8]);
UtAssert_INT32_EQ(UT_EVS_EventBuf.EventID, CFE_EVS_ERR_MSGID_EID);

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

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

/* Confirm the right message was sent */
ASSERT_TRUE(MsgSend == MsgData.MsgPtr);
UtAssert_ADDRESS_EQ(MsgSend, MsgData.MsgPtr);

/* Test set event format mode command using a valid command to set long
* format, reports implicitly via event
Expand Down
Loading

0 comments on commit 8c4cf23

Please sign in to comment.