From 286c76e990754bdf6e8a2f8d776f81ae5838e52a Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 18 Aug 2021 13:47:27 -0400 Subject: [PATCH] Update #1815 (WIP): Use "FLOW" testcase Use the new "FLOW" tag provided from UtAssert, and add an extra tag to the MAY_BE use case to decode whether the condition was a match/no match. --- modules/cfe_assert/inc/cfe_assert.h | 2 +- modules/cfe_assert/src/cfe_assert_io.c | 6 ++++++ modules/cfe_assert/src/cfe_assert_runner.c | 18 +++++++++++++++--- modules/cfe_testcase/src/es_cds_test.c | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/modules/cfe_assert/inc/cfe_assert.h b/modules/cfe_assert/inc/cfe_assert.h index b6a190a87..4224e46a6 100644 --- a/modules/cfe_assert/inc/cfe_assert.h +++ b/modules/cfe_assert/inc/cfe_assert.h @@ -215,7 +215,7 @@ typedef void (*CFE_Assert_StatusCallback_t)(uint8 MessageType, const char *Prefi ** ******************************************************************************/ #define CFE_Assert_STATUS_MAY_BE(expected) \ - CFE_Assert_Status_DeferredCheck(expected, UTASSERT_CASETYPE_NA, __FILE__, __LINE__, #expected) + CFE_Assert_Status_DeferredCheck(expected, UTASSERT_CASETYPE_FLOW, __FILE__, __LINE__, #expected) /*****************************************************************************/ /** diff --git a/modules/cfe_assert/src/cfe_assert_io.c b/modules/cfe_assert/src/cfe_assert_io.c index b16a0377f..613d82c76 100644 --- a/modules/cfe_assert/src/cfe_assert_io.c +++ b/modules/cfe_assert/src/cfe_assert_io.c @@ -114,6 +114,9 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage) case UTASSERT_CASETYPE_TTF: Prefix = "TTF"; break; + case UTASSERT_CASETYPE_WARN: + Prefix = "WARN"; + break; case UTASSERT_CASETYPE_NA: Prefix = "N/A"; break; @@ -129,6 +132,9 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage) case UTASSERT_CASETYPE_INFO: Prefix = "INFO"; break; + case UTASSERT_CASETYPE_FLOW: + Prefix = "FLOW"; + break; case UTASSERT_CASETYPE_DEBUG: Prefix = "DEBUG"; break; diff --git a/modules/cfe_assert/src/cfe_assert_runner.c b/modules/cfe_assert/src/cfe_assert_runner.c index aec11e210..850f4584b 100644 --- a/modules/cfe_assert/src/cfe_assert_runner.c +++ b/modules/cfe_assert/src/cfe_assert_runner.c @@ -119,6 +119,8 @@ bool CFE_Assert_Status_DeferredCheck(CFE_Status_t Status, UtAssert_CaseType_t Ca const char *Text) { bool Result; + const char *ExtraTag; + if (CFE_Assert_Global.StoredText[0] == 0) { /* If no status was stored, then this is a bug in the test program (need to store a result first) */ @@ -127,11 +129,21 @@ bool CFE_Assert_Status_DeferredCheck(CFE_Status_t Status, UtAssert_CaseType_t Ca } else { + Result = (Status == CFE_Assert_Global.StoredStatus); + if (Result) + { + ExtraTag = "match"; + } + else + { + ExtraTag = "not match"; + } + /* This produces a log message similar to what UtAssert_INT32_EQ would produce. * Note the file/line will reflect where the call was made, not where this assertion was done */ - Result = UtAssertEx(Status == CFE_Assert_Global.StoredStatus, CaseType, CFE_Assert_Global.StoredFile, - CFE_Assert_Global.StoredLine, "%s (%ld) == %s (%ld)", CFE_Assert_Global.StoredText, - (long)CFE_Assert_Global.StoredStatus, Text, (long)Status); + Result = UtAssertEx(Result, CaseType, CFE_Assert_Global.StoredFile, + CFE_Assert_Global.StoredLine, "%s (%ld) == %s (%ld) -> %s", CFE_Assert_Global.StoredText, + (long)CFE_Assert_Global.StoredStatus, Text, (long)Status, ExtraTag); } return Result; diff --git a/modules/cfe_testcase/src/es_cds_test.c b/modules/cfe_testcase/src/es_cds_test.c index 7dc030dd4..44ba530e4 100644 --- a/modules/cfe_testcase/src/es_cds_test.c +++ b/modules/cfe_testcase/src/es_cds_test.c @@ -62,7 +62,7 @@ void TestRegisterCDS(void) * to preconditions beyond the control of this test app. Need to clear the CDS * memory and/or do a power-on reset to get full test. */ - UtAssert_NA("CDS already exists. CFE_ES_RegisterCDS new allocation could not be properly tested"); + UtAssert_WARN("CDS already exists. CFE_ES_RegisterCDS new allocation could not be properly tested"); } else {