} \
}
+struct __test_metadata;
+
/* Contains all the information about a fixture. */
struct __fixture_metadata {
const char *name;
+ struct __test_metadata *tests;
struct __fixture_metadata *prev, *next;
} _fixture_global __attribute__((unused)) = {
.name = "global",
};
/* Storage for the (global) tests to be run. */
-static struct __test_metadata *__test_list;
static unsigned int __test_count;
/*
static inline void __register_test(struct __test_metadata *t)
{
__test_count++;
- __LIST_APPEND(__test_list, t);
+ __LIST_APPEND(t->fixture->tests, t);
}
static inline int __bail(int for_realz, bool no_print, __u8 step)
static int test_harness_run(int __attribute__((unused)) argc,
char __attribute__((unused)) **argv)
{
+ struct __fixture_metadata *f;
struct __test_metadata *t;
int ret = 0;
unsigned int count = 0;
/* TODO(wad) add optional arguments similar to gtest. */
printf("[==========] Running %u tests from %u test cases.\n",
__test_count, __fixture_count + 1);
- for (t = __test_list; t; t = t->next) {
- count++;
- __run_test(t->fixture, t);
- if (t->passed)
- pass_count++;
- else
- ret = 1;
+ for (f = __fixture_list; f; f = f->next) {
+ for (t = f->tests; t; t = t->next) {
+ count++;
+ __run_test(f, t);
+ if (t->passed)
+ pass_count++;
+ else
+ ret = 1;
+ }
}
printf("[==========] %u / %u tests passed.\n", pass_count, count);
printf("[ %s ]\n", (ret ? "FAILED" : "PASSED"));