From 6b969d25ce136eaf695222bd1a10bff1ecac0220 Mon Sep 17 00:00:00 2001 From: Onur Gündüz Date: Sat, 20 Jun 2026 20:10:56 +0200 Subject: all: split Makefile and reorg library/tools --- tools/server/test_util.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 tools/server/test_util.h (limited to 'tools/server/test_util.h') diff --git a/tools/server/test_util.h b/tools/server/test_util.h new file mode 100644 index 0000000..c6b6a13 --- /dev/null +++ b/tools/server/test_util.h @@ -0,0 +1,26 @@ +#ifndef FFWD_SERVER_TEST_UTIL_H +#define FFWD_SERVER_TEST_UTIL_H + +/* Shared harness for the ffwd-server unit tests. TEST_ASSERT records failures + * (rather than aborting) so a single run reports every failure, not just the + * first. Each test file includes this, runs its checks, and ends main with + * `return TEST_REPORT("label");`, which prints a summary and yields the exit + * code (0 when clean, 1 otherwise). */ + +#include + +static int test_failures = 0; + +#define TEST_ASSERT(cond) \ + do { \ + if (!(cond)) { \ + fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #cond); \ + test_failures++; \ + } \ + } while (0) + +#define TEST_REPORT(label) \ + (test_failures ? (fprintf(stderr, "%s: %d failure(s)\n", (label), test_failures), 1) \ + : (printf("ok: %s\n", (label)), 0)) + +#endif /* FFWD_SERVER_TEST_UTIL_H */ -- cgit v1.3.1