Mercurial > hg > th-libs
diff tests.c @ 529:c44ebf5b08fd
Improve printf debugging in tests.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 28 Dec 2019 09:55:37 +0200 |
parents | d6b64ba5e6ea |
children | 94d4130cc29c |
line wrap: on
line diff
--- a/tests.c Sat Dec 28 09:54:57 2019 +0200 +++ b/tests.c Sat Dec 28 09:55:37 2019 +0200 @@ -25,7 +25,7 @@ typedef struct { char *header; - BOOL shown; + BOOL shown, failed; } test_ctx; @@ -183,6 +183,8 @@ tprint(0, "\n"); } tests_failed++; + + ctx->failed = TRUE; } } @@ -210,6 +212,10 @@ va_list tmp; test_ctx ctx; + // Setup printf debug value + th_printf_debug = th_verbosity >= 3; + th_printf_debug_prefix = " - "; + // Test basic *printf() functionality test_start(&ctx, "th_vsnprintf(%" PRIu_SIZE_T ", \"%s\", %s)", len, fmt, msg); @@ -228,6 +234,13 @@ test_result_msg(&ctx, (unsigned char) buf2[len] == SET_SENTINEL_BYTE, "buffer #2 overflow, sentinel 0x%02x", buf2[len]); } + if (ctx.failed && !th_printf_debug && th_verbosity >= 1) + { + th_printf_debug = TRUE; + va_copy(tmp, ap); ret1 = th_vsnprintf(buf1, len, fmt, tmp); + va_copy(tmp, ap); ret2 = vsnprintf(buf2, len, fmt, tmp); + } + test_end(&ctx); } @@ -563,8 +576,6 @@ tprint(1, "Enabled test types are 0x%04x.\n", optFlags); - // Setup printf debug value - th_printf_debug = th_verbosity >= 3; // // Test series for printf()