Skip to content

Commit 7ebb463

Browse files
authored
Merge pull request #1138 from nasa/integration-candidate
osal Integration candidate: 2021-08-31
2 parents 2cd118e + 8939836 commit 7ebb463

4 files changed

Lines changed: 46 additions & 9 deletions

File tree

README.md

Lines changed: 5 additions & 0 deletions
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+dev598
15+
16+
- Add UTAssert macros that help test bit field storage
17+
- See <https://github.com/nasa/osal/pull/1138> and <https://github.com/nasa/cFS/pull/348>
18+
1419
### Development Build: v5.1.0-rc1+dev594
1520

1621
- Add test case types similar to NA

src/os/inc/osapi-version.h

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

4242
/*

ut_assert/inc/utassert.h

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,16 @@ typedef enum
8181
*/
8282
typedef enum
8383
{
84-
UtAssert_Compare_NONE, /**< invalid/not used, always false */
85-
UtAssert_Compare_EQ, /**< actual equals reference value */
86-
UtAssert_Compare_NEQ, /**< actual does not non equal reference value */
87-
UtAssert_Compare_LT, /**< actual less than reference (exclusive) */
88-
UtAssert_Compare_GT, /**< actual greater than reference (exclusive) */
89-
UtAssert_Compare_LTEQ, /**< actual less than or equal to reference (inclusive) */
90-
UtAssert_Compare_GTEQ, /**< actual greater than reference (inclusive) */
91-
UtAssert_Compare_MAX /**< placeholder, not used */
84+
UtAssert_Compare_NONE, /**< invalid/not used, always false */
85+
UtAssert_Compare_EQ, /**< actual equals reference value */
86+
UtAssert_Compare_NEQ, /**< actual does not non equal reference value */
87+
UtAssert_Compare_LT, /**< actual less than reference (exclusive) */
88+
UtAssert_Compare_GT, /**< actual greater than reference (exclusive) */
89+
UtAssert_Compare_LTEQ, /**< actual less than or equal to reference (inclusive) */
90+
UtAssert_Compare_GTEQ, /**< actual greater than reference (inclusive) */
91+
UtAssert_Compare_BITMASK_SET, /**< actual equals reference value */
92+
UtAssert_Compare_BITMASK_UNSET, /**< actual equals reference value */
93+
UtAssert_Compare_MAX /**< placeholder, not used */
9294
} UtAssert_Compare_t;
9395

9496
/**
@@ -404,6 +406,24 @@ typedef struct
404406
UtAssert_GenericUnsignedCompare((uint32)(expr), UtAssert_Compare_GT, (uint32)(ref), UtAssert_Radix_DECIMAL, \
405407
__FILE__, __LINE__, "", #expr, #ref)
406408

409+
/**
410+
* \brief Macro for checking that bits in a bit field are set
411+
*
412+
* Test Passes if all the bits specified in "mask" are set in "rawval"
413+
*/
414+
#define UtAssert_BITMASK_SET(rawval, mask) \
415+
UtAssert_GenericUnsignedCompare((uint32)(rawval), UtAssert_Compare_BITMASK_SET, (uint32)(mask), \
416+
UtAssert_Radix_HEX, __FILE__, __LINE__, "", #rawval, #mask)
417+
418+
/**
419+
* \brief Macro for checking that bits in a bit field are unset
420+
*
421+
* Test Passes if none of the bits specified in "mask" are set in "rawval"
422+
*/
423+
#define UtAssert_BITMASK_UNSET(rawval, mask) \
424+
UtAssert_GenericUnsignedCompare((uint32)(rawval), UtAssert_Compare_BITMASK_UNSET, (uint32)(mask), \
425+
UtAssert_Radix_HEX, __FILE__, __LINE__, "", #rawval, #mask)
426+
407427
/**
408428
* \brief Macro for logging calls to a "void" function
409429
*

ut_assert/src/utassert.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,12 @@ const char *UtAssert_GetOpText(UtAssert_Compare_t CompareType)
336336
case UtAssert_Compare_GTEQ: /* actual greater than reference (inclusive) */
337337
OpText = ">=";
338338
break;
339+
case UtAssert_Compare_BITMASK_SET: /* bit(s) in reference are set in actual */
340+
OpText = "&";
341+
break;
342+
case UtAssert_Compare_BITMASK_UNSET: /* bit(s) in reference are not set in actual */
343+
OpText = "&~";
344+
break;
339345
default: /* should never happen */
340346
OpText = "??";
341347
break;
@@ -371,6 +377,12 @@ bool UtAssert_GenericUnsignedCompare(unsigned long ActualValue, UtAssert_Compare
371377
case UtAssert_Compare_GTEQ: /* actual greater than reference (inclusive) */
372378
Result = (ActualValue >= ReferenceValue);
373379
break;
380+
case UtAssert_Compare_BITMASK_SET: /* bit(s) in reference are set in actual */
381+
Result = (ActualValue & ReferenceValue) == ReferenceValue;
382+
break;
383+
case UtAssert_Compare_BITMASK_UNSET: /* bit(s) in reference are not set in actual */
384+
Result = (ActualValue & ReferenceValue) == 0;
385+
break;
374386
default: /* should never happen */
375387
Result = false;
376388
break;

0 commit comments

Comments
 (0)