Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

osal Integration candidate: 2021-08-24 #1132

Merged
merged 3 commits into from
Aug 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF

## Version History

### Development Build: v5.1.0-rc1+dev594

- Add test case types similar to NA
- See <https://github.com/nasa/osal/pull/1132> and <https://github.com/nasa/cFS/pull/340>


### Development Build: v5.1.0-rc1+dev590

Expand Down
2 changes: 1 addition & 1 deletion src/os/inc/osapi-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
/*
* Development Build Macro Definitions
*/
#define OS_BUILD_NUMBER 590
#define OS_BUILD_NUMBER 594
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
23 changes: 23 additions & 0 deletions ut_assert/inc/utassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,13 @@ typedef enum
UTASSERT_CASETYPE_TSF, /**< Test Setup Failure (TSF) status messages */
UTASSERT_CASETYPE_TTF, /**< Test Teardown Failure (TTF) status messages */
UTASSERT_CASETYPE_MIR, /**< Manual Inspection Required (MIR) status messages */
UTASSERT_CASETYPE_WARN, /**< Test was unable to run (WARN) status messages (e.g. initial condition wrong) */
UTASSERT_CASETYPE_NA, /**< Test Not Applicable (NA) status messages */
UTASSERT_CASETYPE_BEGIN, /**< Beginning of test status messages */
UTASSERT_CASETYPE_END, /**< End of test status messages */
UTASSERT_CASETYPE_INFO, /**< All other informational status messages */
UTASSERT_CASETYPE_PASS, /**< Test case passed (normal) status messages */
UTASSERT_CASETYPE_FLOW, /**< Other condition checks/messages that record test flow, but are not assertions */
UTASSERT_CASETYPE_DEBUG, /**< Debugging messages */
UTASSERT_CASETYPE_MAX /**< Reserved value, No messages should be used with this */
} UtAssert_CaseType_t;
Expand Down Expand Up @@ -153,6 +155,11 @@ typedef struct
*/
#define UtAssert_MIR(...) UtAssertEx(false, UTASSERT_CASETYPE_MIR, __FILE__, __LINE__, __VA_ARGS__)

/**
* \brief Skip a test due to improper setup (Manual Intervention Required)
*/
#define UtAssert_WARN(...) UtAssertEx(false, UTASSERT_CASETYPE_WARN, __FILE__, __LINE__, __VA_ARGS__)

/**
* \brief Compares two integers and determines if they are equal within a specified absolute tolerance.
*/
Expand Down Expand Up @@ -587,6 +594,22 @@ bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File,
*/
void UtAssert_Abort(const char *Message);

/**
* \brief Gets the short/abbreviated name for a UtAssert case type
*
* For tagging lines in the output log file, this returns a short string
* representing the human-readable name of the UtAssert case type.
*
* The returned string is 5 characters or less in length.
*
* \note This function does not return NULL, such that it can be
* used directly inside a printf()-style call.
*
* \param CaseType Message case type
* \returns String representation of case type
*/
const char *UtAssert_GetCaseTypeAbbrev(UtAssert_CaseType_t CaseType);

/**
* \brief Output an informational message to the console/log file
*
Expand Down
58 changes: 56 additions & 2 deletions ut_assert/src/utassert.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ void UtAssert_DoTestSegmentReport(const char *SegmentName, const UtAssert_TestCo
char ReportBuffer[144];

snprintf(ReportBuffer, sizeof(ReportBuffer),
"%02u %-20s TOTAL::%-4u PASS::%-4u FAIL::%-4u MIR::%-4u TSF::%-4u TTF::%-4u N/A::%-4u\n",
"%02u %-20s TOTAL::%-4u PASS::%-4u FAIL::%-4u MIR::%-4u TSF::%-4u TTF::%-4u WARN::%-4u\n",
(unsigned int)TestCounters->TestSegmentCount, SegmentName, (unsigned int)TestCounters->TotalTestCases,
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_PASS],
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_FAILURE],
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_MIR],
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_TSF],
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_TTF],
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_NA]);
(unsigned int)TestCounters->CaseCount[UTASSERT_CASETYPE_WARN]);

UT_BSP_DoText(UTASSERT_CASETYPE_END, ReportBuffer);
}
Expand Down Expand Up @@ -225,6 +225,60 @@ void UtAssert_Abort(const char *Message)
UT_BSP_DoText(UTASSERT_CASETYPE_ABORT, Message);
}

const char *UtAssert_GetCaseTypeAbbrev(UtAssert_CaseType_t CaseType)
{
const char *AbbrevStr;

switch (CaseType)
{
case UTASSERT_CASETYPE_ABORT:
AbbrevStr = "ABORT";
break;
case UTASSERT_CASETYPE_FAILURE:
AbbrevStr = "FAIL";
break;
case UTASSERT_CASETYPE_MIR:
AbbrevStr = "MIR";
break;
case UTASSERT_CASETYPE_TSF:
AbbrevStr = "TSF";
break;
case UTASSERT_CASETYPE_TTF:
AbbrevStr = "TTF";
break;
case UTASSERT_CASETYPE_WARN:
AbbrevStr = "WARN";
break;
case UTASSERT_CASETYPE_NA:
AbbrevStr = "N/A";
break;
case UTASSERT_CASETYPE_BEGIN:
AbbrevStr = "BEGIN";
break;
case UTASSERT_CASETYPE_END:
AbbrevStr = "END";
break;
case UTASSERT_CASETYPE_PASS:
AbbrevStr = "PASS";
break;
case UTASSERT_CASETYPE_INFO:
AbbrevStr = "INFO";
break;
case UTASSERT_CASETYPE_FLOW:
AbbrevStr = "FLOW";
break;
case UTASSERT_CASETYPE_DEBUG:
AbbrevStr = "DEBUG";
break;
default:
/* do not return NULL, as the result may be directly passed to C library functions */
AbbrevStr = "OTHER";
break;
}

return AbbrevStr;
}

void UtAssert_Message(uint8 MessageType, const char *File, uint32 Line, const char *Spec, ...)
{
va_list va;
Expand Down
37 changes: 7 additions & 30 deletions ut_assert/src/utbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,60 +116,37 @@ void UT_BSP_StartTestSegment(uint32 SegmentNumber, const char *SegmentName)

void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)
{
const char *Prefix;
char Buffer[16];
size_t MsgLen;
uint32 TermModeBits = OS_BSP_CONSOLEMODE_NORMAL;
uint32 MsgEnabled = BSP_UT_Global.CurrVerbosity >> MessageType;
char Buffer[16];
size_t MsgLen;
uint32 TermModeBits = OS_BSP_CONSOLEMODE_NORMAL;
uint32 MsgEnabled = BSP_UT_Global.CurrVerbosity >> MessageType;

if (MsgEnabled & 1)
{
UT_BSP_Lock();

/* Determine if the message type warrants special treatment (color/highlight/etc). */
switch (MessageType)
{
case UTASSERT_CASETYPE_ABORT:
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED;
Prefix = "ABORT";
break;
case UTASSERT_CASETYPE_FAILURE:
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED;
Prefix = "FAIL";
break;
case UTASSERT_CASETYPE_MIR:
case UTASSERT_CASETYPE_WARN:
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED | OS_BSP_CONSOLEMODE_GREEN;
Prefix = "MIR";
break;
case UTASSERT_CASETYPE_TSF:
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED | OS_BSP_CONSOLEMODE_BLUE;
Prefix = "TSF";
break;
case UTASSERT_CASETYPE_TTF:
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED | OS_BSP_CONSOLEMODE_BLUE;
Prefix = "TTF";
break;
case UTASSERT_CASETYPE_NA:
Prefix = "N/A";
break;
case UTASSERT_CASETYPE_BEGIN:
OS_BSP_ConsoleOutput_Impl("\n", 1); /* add a bit of extra whitespace between tests */
Prefix = "BEGIN";
break;
case UTASSERT_CASETYPE_END:
Prefix = "END";
break;
case UTASSERT_CASETYPE_PASS:
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_GREEN;
Prefix = "PASS";
break;
case UTASSERT_CASETYPE_INFO:
Prefix = "INFO";
break;
case UTASSERT_CASETYPE_DEBUG:
Prefix = "DEBUG";
break;
default:
Prefix = "OTHER";
break;
}

Expand All @@ -178,7 +155,7 @@ void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)
TermModeBits = OS_BSP_CONSOLEMODE_NORMAL;
}

snprintf(Buffer, sizeof(Buffer), "[%5s]", Prefix);
snprintf(Buffer, sizeof(Buffer), "[%5s]", UtAssert_GetCaseTypeAbbrev(MessageType));

if (TermModeBits != OS_BSP_CONSOLEMODE_NORMAL)
{
Expand Down