Skip to content

Commit bc73437

Browse files
authored
Merge pull request #513 from nasa/integration-candidate
Fast Track for Integration Candidate 2020-06-10
2 parents 4258f8c + 9910039 commit bc73437

File tree

3 files changed

+91
-4
lines changed

3 files changed

+91
-4
lines changed

README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ This distribution contains:
2020
### Development Build: 5.0.20
2121
- Add "non-zero" to the out variable description for OS_Create (and related) API's.
2222
- Increases the buffer for context info from 128 to 256 bytes and the total report buffer to 320 bytes.
23-
- Add stub functions for `OS_TaskFindIdBySystemData()`, `OS_FileSysAddFixedMap()`,
24-
`OS_TimedRead()`, `OS_TimedWrite()`, and `OS_FileSysAddFixedMap()`
25-
- See <https://github.com/nasa/osal/pull/511>
23+
- Add stub functions for `OS_TaskFindIdBySystemData()`, `OS_FileSysAddFixedMap()`, `OS_TimedRead()`, `OS_TimedWrite()`, and `OS_FileSysAddFixedMap()`
24+
- Added the following wrappers macros around `UtAssert_True` for commonly-used asserts:
25+
- `UtAssert_INT32_EQ` - check equality as 32 bit signed int
26+
- `UtAssert_UINT32_EQ` - check equality as 32 bit unsigned int
27+
- `UtAssert_NOT_NULL` - check pointer not null
28+
- `UtAssert_NULL` - check pointer is null
29+
- `UtAssert_NONZERO` - check integer is nonzero
30+
- `UtAssert_ZERO` - check integer is zero
31+
- `UtAssert_STUB_COUNT` - check stub count
32+
- Using `unsigned long` instead of `uintmax_t` to fix support for VxWorks
33+
34+
- See <https://github.com/nasa/osal/pull/511> and <https://github.com/nasa/osal/pull/513>
2635

2736
### Development Build: 5.0.19
2837

ut_assert/inc/utassert.h

+78
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,84 @@ typedef struct
134134
#define UtAssert_Type(Type,Expression,...) \
135135
UtAssertEx(Expression, UTASSERT_CASETYPE_##Type, __FILE__, __LINE__, __VA_ARGS__)
136136

137+
/**
138+
* \brief Compare two values for equality with an auto-generated description message
139+
* Values will be compared in an "int32" type context.
140+
*/
141+
#define UtAssert_INT32_EQ(actual,expect) do \
142+
{ \
143+
int32 rcexp = (int32)(expect); \
144+
int32 rcact = (int32)(actual); \
145+
UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", \
146+
#actual, (long)rcact, \
147+
#expect, (long)rcexp); \
148+
} while(0)
149+
150+
/**
151+
* \brief Compare two values for equality with an auto-generated description message
152+
* Values will be compared in an "uint32" type context.
153+
*/
154+
#define UtAssert_UINT32_EQ(actual,expect) do \
155+
{ \
156+
uint32 rcexp = (uint32)(expect); \
157+
uint32 rcact = (uint32)(actual); \
158+
UtAssert_True(rcact == rcexp, "%s (%lu) == %s (%lu)", \
159+
#actual, (unsigned long)rcact, \
160+
#expect, (unsigned long)rcexp); \
161+
} while(0)
162+
163+
/**
164+
* \brief Confirm a pointer value is not NULL
165+
*/
166+
#define UtAssert_NOT_NULL(actual) do \
167+
{ \
168+
void* ptr = (void*)(actual); \
169+
UtAssert_True(ptr != NULL, "%s (%p) != NULL", \
170+
#actual, ptr); \
171+
} while(0)
172+
173+
/**
174+
* \brief Confirm a pointer value is NULL
175+
*/
176+
#define UtAssert_NULL(actual) do \
177+
{ \
178+
void* ptr = (void*)(actual); \
179+
UtAssert_True(ptr == NULL, "%s (%p) == NULL", \
180+
#actual, ptr); \
181+
} while(0)
182+
183+
/**
184+
* \brief Confirm an integer value is nonzero
185+
*/
186+
#define UtAssert_NONZERO(actual) do \
187+
{ \
188+
long val = (long)(actual); \
189+
UtAssert_True(val != 0, "%s (%ld) != 0", \
190+
#actual, val); \
191+
} while(0)
192+
193+
/**
194+
* \brief Confirm an integer value is nonzero
195+
*/
196+
#define UtAssert_ZERO(actual) do \
197+
{ \
198+
long val = (long)(actual); \
199+
UtAssert_True(val == 0, "%s (%ld) == 0", \
200+
#actual, val); \
201+
} while(0)
202+
203+
/**
204+
* \brief Confirm that a stub function has been invoked the expected number of times
205+
*/
206+
#define UtAssert_STUB_COUNT(stub,expected) do \
207+
{ \
208+
uint32 expval = (uint32)(expected); \
209+
uint32 actval = UT_GetStubCount(UT_KEY(stub)); \
210+
UtAssert_True(actval == expval, "%s() count (%lu) == %s (%lu)", \
211+
#stub, (unsigned long)actval, \
212+
#expected, (unsigned long)expval); \
213+
} while(0)
214+
137215
/*
138216
* Exported Functions
139217
*/

ut_assert/src/utstubs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ const void* UT_Hook_GetArgPtr(const UT_StubContext_t *ContextPtr, const char *Na
599599

600600
static const union
601601
{
602-
uintmax_t AsInt;
602+
unsigned long AsInt;
603603
void *AsPtr;
604604
double AsFloat;
605605
} ARG_DEFAULT_ZERO_VALUE = { 0 };

0 commit comments

Comments
 (0)