Skip to content

Commit 2cd118e

Browse files
authored
Merge pull request #1132 from nasa/integration-candidate
osal Integration candidate: 2021-08-24
2 parents ce11e7a + 640e1fd commit 2cd118e

File tree

5 files changed

+92
-33
lines changed

5 files changed

+92
-33
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ The autogenerated OSAL user's guide can be viewed at <https://github.com/nasa/cF
1111

1212
## Version History
1313

14+
### Development Build: v5.1.0-rc1+dev594
15+
16+
- Add test case types similar to NA
17+
- See <https://github.com/nasa/osal/pull/1132> and <https://github.com/nasa/cFS/pull/340>
18+
1419

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

src/os/inc/osapi-version.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
/*
3737
* Development Build Macro Definitions
3838
*/
39-
#define OS_BUILD_NUMBER 590
39+
#define OS_BUILD_NUMBER 594
4040
#define OS_BUILD_BASELINE "v5.1.0-rc1"
4141

4242
/*

ut_assert/inc/utassert.h

+23
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,13 @@ typedef enum
5959
UTASSERT_CASETYPE_TSF, /**< Test Setup Failure (TSF) status messages */
6060
UTASSERT_CASETYPE_TTF, /**< Test Teardown Failure (TTF) status messages */
6161
UTASSERT_CASETYPE_MIR, /**< Manual Inspection Required (MIR) status messages */
62+
UTASSERT_CASETYPE_WARN, /**< Test was unable to run (WARN) status messages (e.g. initial condition wrong) */
6263
UTASSERT_CASETYPE_NA, /**< Test Not Applicable (NA) status messages */
6364
UTASSERT_CASETYPE_BEGIN, /**< Beginning of test status messages */
6465
UTASSERT_CASETYPE_END, /**< End of test status messages */
6566
UTASSERT_CASETYPE_INFO, /**< All other informational status messages */
6667
UTASSERT_CASETYPE_PASS, /**< Test case passed (normal) status messages */
68+
UTASSERT_CASETYPE_FLOW, /**< Other condition checks/messages that record test flow, but are not assertions */
6769
UTASSERT_CASETYPE_DEBUG, /**< Debugging messages */
6870
UTASSERT_CASETYPE_MAX /**< Reserved value, No messages should be used with this */
6971
} UtAssert_CaseType_t;
@@ -153,6 +155,11 @@ typedef struct
153155
*/
154156
#define UtAssert_MIR(...) UtAssertEx(false, UTASSERT_CASETYPE_MIR, __FILE__, __LINE__, __VA_ARGS__)
155157

158+
/**
159+
* \brief Skip a test due to improper setup (Manual Intervention Required)
160+
*/
161+
#define UtAssert_WARN(...) UtAssertEx(false, UTASSERT_CASETYPE_WARN, __FILE__, __LINE__, __VA_ARGS__)
162+
156163
/**
157164
* \brief Compares two integers and determines if they are equal within a specified absolute tolerance.
158165
*/
@@ -587,6 +594,22 @@ bool UtAssertEx(bool Expression, UtAssert_CaseType_t CaseType, const char *File,
587594
*/
588595
void UtAssert_Abort(const char *Message);
589596

597+
/**
598+
* \brief Gets the short/abbreviated name for a UtAssert case type
599+
*
600+
* For tagging lines in the output log file, this returns a short string
601+
* representing the human-readable name of the UtAssert case type.
602+
*
603+
* The returned string is 5 characters or less in length.
604+
*
605+
* \note This function does not return NULL, such that it can be
606+
* used directly inside a printf()-style call.
607+
*
608+
* \param CaseType Message case type
609+
* \returns String representation of case type
610+
*/
611+
const char *UtAssert_GetCaseTypeAbbrev(UtAssert_CaseType_t CaseType);
612+
590613
/**
591614
* \brief Output an informational message to the console/log file
592615
*

ut_assert/src/utassert.c

+56-2
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@ void UtAssert_DoTestSegmentReport(const char *SegmentName, const UtAssert_TestCo
7979
char ReportBuffer[144];
8080

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

9191
UT_BSP_DoText(UTASSERT_CASETYPE_END, ReportBuffer);
9292
}
@@ -225,6 +225,60 @@ void UtAssert_Abort(const char *Message)
225225
UT_BSP_DoText(UTASSERT_CASETYPE_ABORT, Message);
226226
}
227227

228+
const char *UtAssert_GetCaseTypeAbbrev(UtAssert_CaseType_t CaseType)
229+
{
230+
const char *AbbrevStr;
231+
232+
switch (CaseType)
233+
{
234+
case UTASSERT_CASETYPE_ABORT:
235+
AbbrevStr = "ABORT";
236+
break;
237+
case UTASSERT_CASETYPE_FAILURE:
238+
AbbrevStr = "FAIL";
239+
break;
240+
case UTASSERT_CASETYPE_MIR:
241+
AbbrevStr = "MIR";
242+
break;
243+
case UTASSERT_CASETYPE_TSF:
244+
AbbrevStr = "TSF";
245+
break;
246+
case UTASSERT_CASETYPE_TTF:
247+
AbbrevStr = "TTF";
248+
break;
249+
case UTASSERT_CASETYPE_WARN:
250+
AbbrevStr = "WARN";
251+
break;
252+
case UTASSERT_CASETYPE_NA:
253+
AbbrevStr = "N/A";
254+
break;
255+
case UTASSERT_CASETYPE_BEGIN:
256+
AbbrevStr = "BEGIN";
257+
break;
258+
case UTASSERT_CASETYPE_END:
259+
AbbrevStr = "END";
260+
break;
261+
case UTASSERT_CASETYPE_PASS:
262+
AbbrevStr = "PASS";
263+
break;
264+
case UTASSERT_CASETYPE_INFO:
265+
AbbrevStr = "INFO";
266+
break;
267+
case UTASSERT_CASETYPE_FLOW:
268+
AbbrevStr = "FLOW";
269+
break;
270+
case UTASSERT_CASETYPE_DEBUG:
271+
AbbrevStr = "DEBUG";
272+
break;
273+
default:
274+
/* do not return NULL, as the result may be directly passed to C library functions */
275+
AbbrevStr = "OTHER";
276+
break;
277+
}
278+
279+
return AbbrevStr;
280+
}
281+
228282
void UtAssert_Message(uint8 MessageType, const char *File, uint32 Line, const char *Spec, ...)
229283
{
230284
va_list va;

ut_assert/src/utbsp.c

+7-30
Original file line numberDiff line numberDiff line change
@@ -116,60 +116,37 @@ void UT_BSP_StartTestSegment(uint32 SegmentNumber, const char *SegmentName)
116116

117117
void UT_BSP_DoText(uint8 MessageType, const char *OutputMessage)
118118
{
119-
const char *Prefix;
120-
char Buffer[16];
121-
size_t MsgLen;
122-
uint32 TermModeBits = OS_BSP_CONSOLEMODE_NORMAL;
123-
uint32 MsgEnabled = BSP_UT_Global.CurrVerbosity >> MessageType;
119+
char Buffer[16];
120+
size_t MsgLen;
121+
uint32 TermModeBits = OS_BSP_CONSOLEMODE_NORMAL;
122+
uint32 MsgEnabled = BSP_UT_Global.CurrVerbosity >> MessageType;
124123

125124
if (MsgEnabled & 1)
126125
{
127126
UT_BSP_Lock();
128127

128+
/* Determine if the message type warrants special treatment (color/highlight/etc). */
129129
switch (MessageType)
130130
{
131131
case UTASSERT_CASETYPE_ABORT:
132-
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED;
133-
Prefix = "ABORT";
134-
break;
135132
case UTASSERT_CASETYPE_FAILURE:
136133
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED;
137-
Prefix = "FAIL";
138134
break;
139135
case UTASSERT_CASETYPE_MIR:
136+
case UTASSERT_CASETYPE_WARN:
140137
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED | OS_BSP_CONSOLEMODE_GREEN;
141-
Prefix = "MIR";
142138
break;
143139
case UTASSERT_CASETYPE_TSF:
144-
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED | OS_BSP_CONSOLEMODE_BLUE;
145-
Prefix = "TSF";
146-
break;
147140
case UTASSERT_CASETYPE_TTF:
148141
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_RED | OS_BSP_CONSOLEMODE_BLUE;
149-
Prefix = "TTF";
150-
break;
151-
case UTASSERT_CASETYPE_NA:
152-
Prefix = "N/A";
153142
break;
154143
case UTASSERT_CASETYPE_BEGIN:
155144
OS_BSP_ConsoleOutput_Impl("\n", 1); /* add a bit of extra whitespace between tests */
156-
Prefix = "BEGIN";
157-
break;
158-
case UTASSERT_CASETYPE_END:
159-
Prefix = "END";
160145
break;
161146
case UTASSERT_CASETYPE_PASS:
162147
TermModeBits = OS_BSP_CONSOLEMODE_HIGHLIGHT | OS_BSP_CONSOLEMODE_GREEN;
163-
Prefix = "PASS";
164-
break;
165-
case UTASSERT_CASETYPE_INFO:
166-
Prefix = "INFO";
167-
break;
168-
case UTASSERT_CASETYPE_DEBUG:
169-
Prefix = "DEBUG";
170148
break;
171149
default:
172-
Prefix = "OTHER";
173150
break;
174151
}
175152

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

181-
snprintf(Buffer, sizeof(Buffer), "[%5s]", Prefix);
158+
snprintf(Buffer, sizeof(Buffer), "[%5s]", UtAssert_GetCaseTypeAbbrev(MessageType));
182159

183160
if (TermModeBits != OS_BSP_CONSOLEMODE_NORMAL)
184161
{

0 commit comments

Comments
 (0)