aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorBjoern B. Brandenburg <bbb@cs.unc.edu>2010-02-25 18:16:52 -0500
committerBjoern B. Brandenburg <bbb@cs.unc.edu>2010-02-25 18:16:52 -0500
commitf534210a79a04e1e9aeec7dcb8e900d933b8bae2 (patch)
treebedbe39d82dbb9759a22826a3cd394114ab5486d /include
parent8026e36c2901691bde793f85f7a0f8ca6e9c44dc (diff)
parentf3d21c128e5b40acd1f15e3ddcd7fd54ca3a9bed (diff)
Merge branch 'tests'
Diffstat (limited to 'include')
-rw-r--r--include/tests.h50
1 files changed, 50 insertions, 0 deletions
diff --git a/include/tests.h b/include/tests.h
new file mode 100644
index 0000000..3adba18
--- /dev/null
+++ b/include/tests.h
@@ -0,0 +1,50 @@
1#ifndef TESTS_H
2#define TESTS_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <errno.h>
7
8#define fail(fmt, args...) \
9 do { \
10 fprintf(stderr, "\n!! TEST FAILURE " fmt "\n at %s:%d (%s)\n", \
11 ## args, __FILE__, __LINE__, __FUNCTION__); \
12 fflush(stderr); \
13 exit(200); \
14 } while (0)
15
16#define ASSERT(predicate) \
17 do { \
18 if (!(predicate)) \
19 fail("%s", #predicate); \
20 } while (0)
21
22#define SYSCALL(call) \
23 do { \
24 if ((call) < 0) \
25 fail("%s, %m", #call); \
26 } while (0)
27
28#define SYSCALL_FAILS(expected, call) \
29 do { \
30 if ((call) == 0 || errno != (expected)) \
31 fail("%s, %m (expected: %s)", #call, #expected); \
32 } while (0)
33
34
35typedef void (*testfun_t)(void);
36
37struct testcase {
38 testfun_t function;
39 const char* description;
40};
41
42struct testsuite {
43 const char* plugin;
44 int* testcases;
45 int num_cases;
46};
47
48#define TESTCASE(function, plugins, description) void test_ ## function (void)
49
50#endif