diff options
| author | Tomasz Kramkowski <tk@the-tk.com> | 2021-09-21 21:13:40 +0100 | 
|---|---|---|
| committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-09-21 21:13:40 +0100 | 
| commit | 5a54c2cf51e207872dcf2a05fe19a5fba85278f7 (patch) | |
| tree | 5322a38bc33934cd3467031da4ddfa94a673742b /test.c | |
| parent | 69c8b1fe3f9c065b0e2f06bf62bda70cc4a5eba7 (diff) | |
| download | pack-5a54c2cf51e207872dcf2a05fe19a5fba85278f7.tar.gz pack-5a54c2cf51e207872dcf2a05fe19a5fba85278f7.tar.xz pack-5a54c2cf51e207872dcf2a05fe19a5fba85278f7.zip  | |
test.c: Output TAP formatted tests
Diffstat (limited to 'test.c')
| -rw-r--r-- | test.c | 17 | 
1 files changed, 11 insertions, 6 deletions
@@ -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;  	}  | 
