]> git.saurik.com Git - apple/hfs.git/blame - tests/hfs-tests.h
hfs-366.30.3.tar.gz
[apple/hfs.git] / tests / hfs-tests.h
CommitLineData
558d2836
A
1//
2// hfs-tests.h
3// hfs
4//
5// Created by Chris Suter on 8/11/15.
6//
7//
8
9#ifndef hfs_tests_c
10#define hfs_tests_c
11
12#include <sys/cdefs.h>
13#include <stdbool.h>
14
15__BEGIN_DECLS
16
17typedef struct test_ctx {
18 int reserved;
19} test_ctx_t;
20
21typedef int (* test_fn_t)(test_ctx_t *);
22
23typedef struct test {
24 const char *name;
25 test_fn_t test_fn;
26 bool run_as_root;
27 // Other attributes
28} test_t;
29
30#define TEST_DECL(test_name, ...) \
31 static int run_##test_name(test_ctx_t *); \
32 struct test test_##test_name = { \
33 .name = #test_name, \
34 .test_fn = run_##test_name, \
35 __VA_ARGS__ \
36 }; \
37 static __attribute__((constructor)) \
38 void register_test_##test_name(void) { \
39 register_test(&test_##test_name); \
40 }
41
42#ifndef TEST
43#define TEST(x, ...) TEST_DECL(x, ##__VA_ARGS__)
44#endif
45
46void register_test(test_t *test);
47
48__END_DECLS
49
50#endif /* hfs_tests_c */