diff options
-rw-r--r-- | payloads/libpayload/include/assert.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/payloads/libpayload/include/assert.h b/payloads/libpayload/include/assert.h index 50847a3b47..2152af4f7a 100644 --- a/payloads/libpayload/include/assert.h +++ b/payloads/libpayload/include/assert.h @@ -29,6 +29,17 @@ #include <stdlib.h> #include <stdio.h> +#ifdef __TEST__ + +/* CMocka function redefinition */ +void mock_assert(const int result, const char *const expression, const char *const file, + const int line); + +#define MOCK_ASSERT(result, expression) mock_assert((result), (expression), __FILE__, __LINE__) +#define assert(statement) MOCK_ASSERT(!!(statement), #statement) + +#else + // assert's existence depends on NDEBUG state on _last_ inclusion of assert.h, // so don't guard this against double-includes. #ifdef NDEBUG @@ -43,3 +54,5 @@ abort(); \ } #endif + +#endif /* __TEST__ */ |