* Configuration is now done with files, instead of through command line switches specified in CMakeLists.txt. * Link tests with a static library instead of compiling individual wepoll source files as part of the test executable. This should make the CI run significantly faster.
46 lines
1.5 KiB
C
46 lines
1.5 KiB
C
#ifndef TEST_UTIL_H_
|
|
#define TEST_UTIL_H_
|
|
|
|
#include <assert.h>
|
|
|
|
#ifdef __clang__
|
|
#pragma clang diagnostic ignored "-Wbad-function-cast"
|
|
#pragma clang diagnostic ignored "-Wcast-qual"
|
|
#pragma clang diagnostic ignored "-Wformat-non-iso"
|
|
#pragma clang diagnostic ignored "-Wkeyword-macro"
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
#define no_return __declspec(noreturn)
|
|
#else /* GCC/Clang */
|
|
#define no_return __attribute__((noreturn))
|
|
#endif
|
|
|
|
#ifdef _MSC_VER
|
|
#define no_inline __declspec(noinline)
|
|
#else /* GCC/Clang */
|
|
#define no_inline __attribute__((noinline))
|
|
#endif
|
|
|
|
void no_inline no_return check_fail(const char* message);
|
|
|
|
#define test_util__to_string_helper(v) #v
|
|
#define test_util__to_string(v) test_util__to_string_helper(v)
|
|
|
|
#define check(expression) \
|
|
(void) ((!!(expression)) || \
|
|
(check_fail("\n" \
|
|
"Check failed:\n" \
|
|
" test: " #expression "\n" \
|
|
" file: " __FILE__ "\n" \
|
|
" line: " test_util__to_string(__LINE__) "\n"), \
|
|
0))
|
|
|
|
/* Polyfill `static_assert` for some versions of clang and gcc. */
|
|
#if (defined(__clang__) || defined(__GNUC__)) && !defined(static_assert)
|
|
#define static_assert(condition, message) typedef __attribute__( \
|
|
(__unused__)) int __static_assert_##__LINE__[(condition) ? 1 : -1]
|
|
#endif
|
|
|
|
#endif /* TEST_UTIL_H_ */
|