aboutsummaryrefslogtreecommitdiff
path: root/tests/test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.c')
-rw-r--r--tests/test.c43
1 files changed, 36 insertions, 7 deletions
diff --git a/tests/test.c b/tests/test.c
index 2055c78..cc14456 100644
--- a/tests/test.c
+++ b/tests/test.c
@@ -1,4 +1,6 @@
1#include "test.h" 1#include <stdio.h>
2
3#include "fst_tests.h"
2 4
3static bool run_test(Test *); 5static bool run_test(Test *);
4static bool run_suite(TestSuite *); 6static bool run_suite(TestSuite *);
@@ -36,15 +38,42 @@ run_suite(TestSuite *suite)
36 return true; 38 return true;
37} 39}
38 40
39int main() { 41static bool
42module_in_args(char *module, int argc, char *argv[])
43{
44 for (int i = 0; i < argc; i++)
45 if (!strcmp(module, argv[i]))
46 return true;
47 return false;
48}
49
50int main(int argc, char *argv[]) {
51 /* TODO: init should be in testsuites */
40 init_env(); 52 init_env();
41 init_trans(); 53 init_trans();
54 /**************************************/
42 55
43 if (!run_suite(&fst_pre_init_suite)) 56 TestModule fst = { .name = "fst", .suites = fst_testsuites };
44 return 1; 57 TestModule *modules[999] = {
45 if (!run_suite(&fst_post_init_suite)) 58 &fst,
46 return 1; 59 NULL
60 };
61
62
63 bool all = argc == 1 || module_in_args("all", argc, argv);
64 int count = 0;
65 for (int i = 0; modules[i] != NULL; i++) {
66 if (all || module_in_args(modules[i]->name, argc, argv)) {
67 for (int j = 0; modules[i]->suites[j] != NULL; j++) {
68 if (!run_suite(modules[i]->suites[j])) {
69 return 1;
70 } else {
71 count++;
72 }
73 }
74 }
75 }
47 76
48 printf("All tests passed.\n"); 77 printf("All tests passed (%d test suites).\n", count);
49 return 0; 78 return 0;
50} 79}

Generated with cgit - Back to sebastiano.tronto.net