Commit 52731c00 authored by Ondřej Surý's avatar Ondřej Surý Committed by Ondřej Surý

Add support for cmocka assert testing by overriding REQUIRE/INSIST/... macros...

Add support for cmocka assert testing by overriding REQUIRE/INSIST/... macros when UNIT_TESTING is defined
parent 10535d1c
Pipeline #2463 passed with stages
in 8 minutes and 24 seconds
......@@ -203,6 +203,19 @@
*/
#include <isc/likely.h>
#ifdef UNIT_TESTING
extern void mock_assert(const int result, const char* const expression,
const char * const file, const int line);
#define REQUIRE(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
#define ENSURE(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
#define INSIST(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
#define INVARIANT(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
#else /* UNIT_TESTING */
/*
* Assertions
*/
......@@ -217,6 +230,8 @@
/*% Invariant Assertion */
#define INVARIANT(e) ISC_INVARIANT(e)
#endif /* UNIT_TESTING */
/*
* Errors
*/
......@@ -226,9 +241,19 @@
#define UNEXPECTED_ERROR isc_error_unexpected
/*% Fatal Error */
#define FATAL_ERROR isc_error_fatal
#ifdef UNIT_TESTING
#define RUNTIME_CHECK(expression) \
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
#else /* UNIT_TESTING */
/*% Runtime Check */
#define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond)
#endif /* UNIT_TESTING */
/*%
* Time
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment