From 5a54c2cf51e207872dcf2a05fe19a5fba85278f7 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Tue, 21 Sep 2021 21:13:40 +0100 Subject: test.c: Output TAP formatted tests --- test.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/test.c b/test.c index 0a30e33..0d92ff7 100644 --- a/test.c +++ b/test.c @@ -189,21 +189,26 @@ TEST(unpack_struct_simple, "unpack_struct simple") int main(void) { extern struct test __start_tests, __stop_tests; + struct test *tests = &__start_tests; + ptrdiff_t length = &__stop_tests - &__start_tests; int ret = EXIT_SUCCESS; + assert(length >= 0); + pack_trace = PACK_TRACE_OFF; - for (struct test *t = &__start_tests; t < &__stop_tests; t++) { - if (t->func()) { - printf(" OK %s\n", t->desc); + printf("1..%tu\n", length); + for (ptrdiff_t i = 0; i < length; i++) { + if (tests[i].func()) { + printf("ok %tu - %s\n", i + 1, tests[i].desc); continue; } pack_trace = PACK_TRACE_ALL; - fprintf(stderr, ">>> Test failure trace for '%s'\n", t->desc); - t->func(); + fprintf(stderr, ">>> Test failure trace for '%s'\n", tests[i].desc); + tests[i].func(); fprintf(stderr, "<<<\n"); pack_trace = PACK_TRACE_OFF; - printf("FAIL %s\n", t->desc); + printf("not ok - %tu %s\n", i + 1, tests[i].desc); ret = EXIT_FAILURE; } -- cgit v1.2.3-54-g00ecf