initial commit
[libc-test] / common / main.c
1 #include "test.h"
2
3 #define T(t) void t();
4 #include "main.h"
5 #undef T
6
7 struct test test__ = {0};
8
9 static int verbose;
10 static int count;
11 static int nfailed;
12
13 static void run(const char *n, void (*f)()) {
14         count++;
15         test__.failed = 0;
16         test__.name = n;
17         if (verbose)
18                 fprintf(stderr, "running %s:\n", test__.name);
19         f();
20         if (test__.failed) {
21                 nfailed++;
22                 fprintf(stderr, "FAILED %s\n", test__.name);
23         } else if (verbose)
24                 fprintf(stderr, "PASSED %s\n", test__.name);
25 }
26
27 static int summary() {
28         fprintf(stderr, "PASS:%d FAIL:%d\n", count-nfailed, nfailed);
29         return !!nfailed;
30 }
31
32 int main() {
33 #define T(t) run(#t, t);
34 #include "main.h"
35         return summary();
36 }