From e24735c6be98e0e033a3957ad6f147f54e275f4c Mon Sep 17 00:00:00 2001 From: Joseph Hickey Date: Wed, 25 Aug 2021 13:40:18 -0400 Subject: [PATCH 1/2] Fix #1135, add bitmask assert macros Add a pair of macros that can confirm a value has bits set or does not have bits set. By using bitmask-aware macros, the logged information can include both the raw/actual value as well as the specific bits being tested. --- ut_assert/inc/utassert.h | 36 ++++++++++++++++++++++++++++-------- ut_assert/src/utassert.c | 12 ++++++++++++ 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/ut_assert/inc/utassert.h b/ut_assert/inc/utassert.h index bde9ff397..67470fdc6 100644 --- a/ut_assert/inc/utassert.h +++ b/ut_assert/inc/utassert.h @@ -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; /** @@ -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 * diff --git a/ut_assert/src/utassert.c b/ut_assert/src/utassert.c index 8642ca260..4d3f064e2 100644 --- a/ut_assert/src/utassert.c +++ b/ut_assert/src/utassert.c @@ -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; @@ -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; From 8939836f29ee19dd083f7b00ebb5d6e2bf2748c4 Mon Sep 17 00:00:00 2001 From: "Gerardo E. Cruz-Ortiz" <59618057+astrogeco@users.noreply.github.com> Date: Wed, 1 Sep 2021 10:18:29 -0400 Subject: [PATCH 2/2] IC:2021-08-31, Bump to v5.1.0-rc1+dev598 --- README.md | 5 +++++ src/os/inc/osapi-version.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d0986500c..8970e8baf 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ The autogenerated OSAL user's guide can be viewed at and + ### Development Build: v5.1.0-rc1+dev594 - Add test case types similar to NA diff --git a/src/os/inc/osapi-version.h b/src/os/inc/osapi-version.h index 679edaee0..e91916b83 100644 --- a/src/os/inc/osapi-version.h +++ b/src/os/inc/osapi-version.h @@ -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" /*