mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
Merge branch '889-improve-clang-cmocka-interaction' into 'master'
Resolve "Improve clang/cmocka interaction." Closes #889 See merge request isc-projects/bind9!1542
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@@ -197,15 +197,26 @@
|
||||
#ifdef UNIT_TESTING
|
||||
extern void mock_assert(const int result, const char* const expression,
|
||||
const char * const file, const int line);
|
||||
/*
|
||||
* Allow clang to determine that the following code is not reached
|
||||
* by calling abort() if the condition fails. The abort() will
|
||||
* never be executed as mock_assert() and _assert_true() longjmp
|
||||
* or exit if the condition is false.
|
||||
*/
|
||||
#define REQUIRE(expression) \
|
||||
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
|
||||
((!(expression)) ? \
|
||||
(mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
|
||||
#define ENSURE(expression) \
|
||||
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
|
||||
((!(int)(expression)) ? \
|
||||
(mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
|
||||
#define INSIST(expression) \
|
||||
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
|
||||
((!(expression)) ? \
|
||||
(mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
|
||||
#define INVARIANT(expression) \
|
||||
mock_assert((int)(expression), #expression, __FILE__, __LINE__)
|
||||
|
||||
((!(expression)) ? \
|
||||
(mock_assert(0, #expression, __FILE__, __LINE__), abort()) : (void)0)
|
||||
#define _assert_true(c, e, f, l) \
|
||||
((c) ? (void)0 : (_assert_true(0, e, f, l), abort()))
|
||||
#else /* UNIT_TESTING */
|
||||
/*
|
||||
* Assertions
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@@ -15,6 +15,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
|
Reference in New Issue
Block a user