diff options
| -rw-r--r-- | tests/test-runner.c | 3 | ||||
| -rw-r--r-- | tests/test-runner.h | 17 |
2 files changed, 17 insertions, 3 deletions
diff --git a/tests/test-runner.c b/tests/test-runner.c index bb07013..24ae317 100644 --- a/tests/test-runner.c +++ b/tests/test-runner.c @@ -124,6 +124,9 @@ int main(int argc, char *argv[]) break; } + if (t->must_fail) + success = !success; + if (success) { pass++; fprintf(stderr, ", pass.\n"); diff --git a/tests/test-runner.h b/tests/test-runner.h index 253df81..0614101 100644 --- a/tests/test-runner.h +++ b/tests/test-runner.h @@ -8,14 +8,25 @@ struct test { const char *name; void (*run)(void); -}; + int must_fail; +} __attribute__ ((aligned (16))); #define TEST(name) \ static void name(void); \ \ - const struct test test##name \ + const struct test test##name \ __attribute__ ((section ("test_section"))) = { \ - #name, name \ + #name, name, 0 \ + }; \ + \ + static void name(void) + +#define FAIL_TEST(name) \ + static void name(void); \ + \ + const struct test test##name \ + __attribute__ ((section ("test_section"))) = { \ + #name, name, 1 \ }; \ \ static void name(void) |
