# HG changeset patch # User Matti Hamalainen # Date 1456395550 -7200 # Node ID 68e8ad3327b896e2c06418f0720fb1972f6f175e # Parent a688d34c11d4ebf6973fe35c2dc4bd289414a5cd Improve tests output. diff -r a688d34c11d4 -r 68e8ad3327b8 tests.c --- a/tests.c Thu Feb 25 11:59:06 2016 +0200 +++ b/tests.c Thu Feb 25 12:19:10 2016 +0200 @@ -12,6 +12,7 @@ typedef struct { char *header, *res; + BOOL shown; } test_ctx; @@ -33,19 +34,26 @@ static const int arg_nopts = sizeof(arg_opts) / sizeof(arg_opts[0]); -void tprintv(const int level, const char *fmt, va_list ap) +BOOL tprintv(const int level, const char *fmt, va_list ap) { if (level <= th_verbosityLevel) + { vfprintf(stdout, fmt, ap); + return TRUE; + } + else + return FALSE; } -void tprint(const int level, const char *fmt, ...) +BOOL tprint(const int level, const char *fmt, ...) { + BOOL retv; va_list ap; va_start(ap, fmt); - tprintv(level, fmt, ap); + retv = tprintv(level, fmt, ap); va_end(ap); + return retv; } @@ -146,12 +154,16 @@ { if (check) { - tprint(2, "%s: OK\n", ctx->header); + if (!ctx->shown && tprint(2, "%s: OK\n", ctx->header)) + ctx->shown = TRUE; + tests_passed++; } else { - tprint(0, "%s: FAIL\n", ctx->header); + if (!ctx->shown && tprint(0, "%s: FAIL\n", ctx->header)) + ctx->shown = TRUE; + if (fmt != NULL) { tprint(0, " - ");