ad1aebc10a6629a22935b7bc0b4b1ae268f10e68
[lunaix-os.git] / lunaix-os / tests / shared / framework.c
1 #include <testing/basic.h>
2 #include <stdlib.h>
3
4 struct test_context* __test_ctx;
5
6 void 
7 main(int argc, const char* argv[])
8 {
9     __test_ctx = calloc(sizeof(*__test_ctx), 1);
10
11     printf("\n");
12
13     run_test(argc, argv);
14
15     printf(
16         "All test done: %d passed, %d failed\n",
17         __test_ctx->stats.total_passed,
18         __test_ctx->stats.total_failed
19     );
20     printf("************\n\n");
21
22     exit(__test_ctx->stats.total_failed > 0);
23 }
24
25 void
26 begin_testcase(const char* name)
27 {
28     if (__test_ctx->name) {
29         printf("previous test case: '%s' is still actuive\n", name);
30         exit(1);
31     }
32
33     __test_ctx->name = name;
34     __test_ctx->stats.countings[0] = 0;
35     __test_ctx->stats.countings[1] = 0;
36
37     printf("%s\n", name);
38 }
39
40 void
41 end_testcase()
42 {
43     printf("..... passed: %d, failed: %d\n\n", 
44             __test_ctx->stats.passed, __test_ctx->stats.failed);
45
46     __test_ctx->stats.total_passed += __test_ctx->stats.passed;
47     __test_ctx->stats.total_failed += __test_ctx->stats.failed;
48     __test_ctx->name = NULL;
49
50 }