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-31 #1138

Merged
merged 3 commits into from
Sep 1, 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+dev598

- Add UTAssert macros that help test bit field storage
- See <https://github.com/nasa/osal/pull/1138> and <https://github.com/nasa/cFS/pull/348>

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

- Add test case types similar to NA
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 594
#define OS_BUILD_NUMBER 598
#define OS_BUILD_BASELINE "v5.1.0-rc1"

/*
Expand Down
36 changes: 28 additions & 8 deletions ut_assert/inc/utassert.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,16 @@ typedef enum
*/
typedef enum
{
UtAssert_Compare_NONE, /**< invalid/not used, always false */
UtAssert_Compare_EQ, /**< actual equals reference value */
UtAssert_Compare_NEQ, /**< actual does not non equal reference value */
UtAssert_Compare_LT, /**< actual less than reference (exclusive) */
UtAssert_Compare_GT, /**< actual greater than reference (exclusive) */
UtAssert_Compare_LTEQ, /**< actual less than or equal to reference (inclusive) */
UtAssert_Compare_GTEQ, /**< actual greater than reference (inclusive) */
UtAssert_Compare_MAX /**< placeholder, not used */
UtAssert_Compare_NONE, /**< invalid/not used, always false */
UtAssert_Compare_EQ, /**< actual equals reference value */
UtAssert_Compare_NEQ, /**< actual does not non equal reference value */
UtAssert_Compare_LT, /**< actual less than reference (exclusive) */
UtAssert_Compare_GT, /**< actual greater than reference (exclusive) */
UtAssert_Compare_LTEQ, /**< actual less than or equal to reference (inclusive) */
UtAssert_Compare_GTEQ, /**< actual greater than reference (inclusive) */
UtAssert_Compare_BITMASK_SET, /**< actual equals reference value */
UtAssert_Compare_BITMASK_UNSET, /**< actual equals reference value */
UtAssert_Compare_MAX /**< placeholder, not used */
} UtAssert_Compare_t;

/**
Expand Down Expand Up @@ -404,6 +406,24 @@ typedef struct
UtAssert_GenericUnsignedCompare((uint32)(expr), UtAssert_Compare_GT, (uint32)(ref), UtAssert_Radix_DECIMAL, \
__FILE__, __LINE__, "", #expr, #ref)

/**
* \brief Macro for checking that bits in a bit field are set
*
* Test Passes if all the bits specified in "mask" are set in "rawval"
*/
#define UtAssert_BITMASK_SET(rawval, mask) \
UtAssert_GenericUnsignedCompare((uint32)(rawval), UtAssert_Compare_BITMASK_SET, (uint32)(mask), \
UtAssert_Radix_HEX, __FILE__, __LINE__, "", #rawval, #mask)

/**
* \brief Macro for checking that bits in a bit field are unset
*
* Test Passes if none of the bits specified in "mask" are set in "rawval"
*/
#define UtAssert_BITMASK_UNSET(rawval, mask) \
UtAssert_GenericUnsignedCompare((uint32)(rawval), UtAssert_Compare_BITMASK_UNSET, (uint32)(mask), \
UtAssert_Radix_HEX, __FILE__, __LINE__, "", #rawval, #mask)

/**
* \brief Macro for logging calls to a "void" function
*
Expand Down
12 changes: 12 additions & 0 deletions ut_assert/src/utassert.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,12 @@ const char *UtAssert_GetOpText(UtAssert_Compare_t CompareType)
case UtAssert_Compare_GTEQ: /* actual greater than reference (inclusive) */
OpText = ">=";
break;
case UtAssert_Compare_BITMASK_SET: /* bit(s) in reference are set in actual */
OpText = "&";
break;
case UtAssert_Compare_BITMASK_UNSET: /* bit(s) in reference are not set in actual */
OpText = "&~";
break;
default: /* should never happen */
OpText = "??";
break;
Expand Down Expand Up @@ -371,6 +377,12 @@ bool UtAssert_GenericUnsignedCompare(unsigned long ActualValue, UtAssert_Compare
case UtAssert_Compare_GTEQ: /* actual greater than reference (inclusive) */
Result = (ActualValue >= ReferenceValue);
break;
case UtAssert_Compare_BITMASK_SET: /* bit(s) in reference are set in actual */
Result = (ActualValue & ReferenceValue) == ReferenceValue;
break;
case UtAssert_Compare_BITMASK_UNSET: /* bit(s) in reference are not set in actual */
Result = (ActualValue & ReferenceValue) == 0;
break;
default: /* should never happen */
Result = false;
break;
Expand Down