]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
testutil: add the possibility to set the current test title
authorRichard Levitte <levitte@openssl.org>
Thu, 11 May 2017 17:12:48 +0000 (19:12 +0200)
committerRichard Levitte <levitte@openssl.org>
Thu, 11 May 2017 18:40:23 +0000 (20:40 +0200)
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3445)

test/testutil.h
test/testutil/driver.c

index 8e4481e41392325fc536bffa5a8ff3c07a468f67..d8acd7380f19a3341adf0971170aefe8bc759d56 100644 (file)
@@ -140,6 +140,7 @@ void add_test(const char *test_case_name, int (*test_fn) ());
 void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num,
                    int subtest);
 __owur int run_tests(const char *test_prog_name);
+void set_test_title(const char *title);
 
 /*
  * Declarations for user defined functions
index 786bc38f2b19331d54e10ec299104ef2466a6ccd..660db7b3270c660da4a83113a1d5d45f5f55b2a3 100644 (file)
@@ -121,6 +121,13 @@ static void finalize(int success)
         ERR_print_errors_cb(openssl_error_cb, NULL);
 }
 
+static const char *test_title = NULL;
+
+void set_test_title(const char *title)
+{
+    test_title = title;
+}
+
 int run_tests(const char *test_prog_name)
 {
     int num_failed = 0;
@@ -139,7 +146,10 @@ int run_tests(const char *test_prog_name)
 
     for (i = 0; i != num_tests; ++i) {
         if (all_tests[i].num == -1) {
-            int ret = all_tests[i].test_fn();
+            int ret = 0;
+
+            set_test_title(all_tests[i].test_case_name);
+            ret = all_tests[i].test_fn();
 
             test_flush_stdout();
             test_flush_stderr();
@@ -150,7 +160,7 @@ int run_tests(const char *test_prog_name)
                 ++num_failed;
             }
             test_printf_stdout("%*s%s %d - %s\n", level, "", verdict, i + 1,
-                               all_tests[i].test_case_name);
+                               test_title);
             test_flush_stdout();
             finalize(ret);
         } else {
@@ -166,7 +176,10 @@ 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);
+                int ret = 0;
+
+                set_test_title(NULL);
+                ret = all_tests[i].param_test_fn(j);
 
                 test_flush_stdout();
                 test_flush_stderr();
@@ -182,7 +195,12 @@ int run_tests(const char *test_prog_name)
                         verdict = "not ok";
                         ++num_failed_inner;
                     }
-                    test_printf_stdout("%*s%s %d\n", level, "", verdict, j + 1);
+                    if (test_title != NULL)
+                        test_printf_stdout("%*s%s %d - %s\n", level, "", verdict,
+                                           j + 1, test_title);
+                    else
+                        test_printf_stdout("%*s%s %d\n", level, "", verdict,
+                                           j + 1);
                     test_flush_stdout();
                 }
             }