Tapify libtestutil a bit better
authorRichard Levitte <levitte@openssl.org>
Tue, 25 Apr 2017 19:13:26 +0000 (21:13 +0200)
committerRichard Levitte <levitte@openssl.org>
Tue, 25 Apr 2017 19:13:26 +0000 (21:13 +0200)
This includes better signals of skips and subtests according to TAP 12,
and flushing stdout and stderr at the end of every test function to
make sure we get the output in good order.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3309)

test/testutil/driver.c

index 4f6b511..29c97a9 100644 (file)
@@ -138,13 +138,23 @@ int run_tests(const char *test_prog_name)
     char *verdict = NULL;
     int i, j;
 
-    helper_printf_stdout("%*s%d..%d\n", level, "", 1, num_tests);
+    if (num_tests < 1)
+        helper_printf_stdout("%*s1..0 # Skipped: %s\n", level, "",
+                             test_prog_name);
+    else if (level > 0)
+        helper_printf_stdout("%*s1..%d # Subtest: %s\n", level, "", num_tests,
+                             test_prog_name);
+    else
+        helper_printf_stdout("%*s1..%d\n", level, "", num_tests);
     test_flush_stdout();
 
     for (i = 0; i != num_tests; ++i) {
         if (all_tests[i].num == -1) {
             int ret = all_tests[i].test_fn();
 
+            test_flush_stdout();
+            test_flush_stderr();
+
             verdict = "ok";
             if (!ret) {
                 verdict = "not ok";
@@ -169,6 +179,9 @@ int run_tests(const char *test_prog_name)
             for (j = 0; j < all_tests[i].num; j++) {
                 int ret = all_tests[i].param_test_fn(j);
 
+                test_flush_stdout();
+                test_flush_stderr();
+
                 if (!ret)
                     ++num_failed_inner;