core-lightning/wallet/test/test_utils.h
Rusty Russell 4ffda340d3 check: make sure all files outside contrib/ include "config.h" first.
And turn "" includes into full-path (which makes it easier to put
config.h first, and finds some cases check-includes.sh missed
previously).

config.h sets _GNU_SOURCE which really needs to be done before any
'#includes': we mainly got away with it with glibc, but other platforms
like Alpine may have stricter requirements.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-12-06 10:05:39 +10:30

30 lines
692 B
C

#ifndef LIGHTNING_WALLET_TEST_TEST_UTILS_H
#define LIGHTNING_WALLET_TEST_TEST_UTILS_H
#include "config.h"
#include "lightningd/lightningd.h"
/* Definitions "inspired" by libsecp256k1 */
#define TEST_FAILURE(msg) do { \
fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg); \
return false; \
} while(0)
#ifdef HAVE_BUILTIN_EXPECT
#define EXPECT(x,c) __builtin_expect((x),(c))
#else
#define EXPECT(x,c) (x)
#endif
#define CHECK_MSG(cond,msg) do { \
if (EXPECT(!(cond), 0)) { \
TEST_FAILURE(msg); \
} \
} while(0)
#define CHECK(cond) CHECK_MSG(cond,"test condition failed");
const struct config test_config;
#endif /* LIGHTNING_WALLET_TEST_TEST_UTILS_H */