mirror of
https://github.com/isc-projects/bind9.git
synced 2026-03-02 21:40:43 -05:00
improve clang / cmocka integration
(cherry picked from commit cb913177ae)
This commit is contained in:
parent
ae383b7b52
commit
2671666ef8
7 changed files with 22 additions and 5 deletions
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <setjmp.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -220,15 +220,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
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <isc/net.h>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define UNIT_TESTING
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue