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