diff options
author | Pauli <paul.dale@oracle.com> | 2019-04-15 09:53:53 +1000 |
---|---|---|
committer | Pauli <paul.dale@oracle.com> | 2019-05-09 20:21:09 +1000 |
commit | c5f7a99645aa1718e226e6d867efcd5cabcbd610 (patch) | |
tree | 1c88c93f60a4bc51c9f43e24133ecded33b07040 /test/testutil/driver.c | |
parent | 1fb3c0afffec0b53a01fa3374bb0099218902ce0 (diff) | |
download | openssl-c5f7a99645aa1718e226e6d867efcd5cabcbd610.tar.gz |
Test skip option.
Provide C test cases with the option to skip tests and subtests.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8695)
Diffstat (limited to 'test/testutil/driver.c')
-rw-r--r-- | test/testutil/driver.c | 55 |
1 files changed, 22 insertions, 33 deletions
diff --git a/test/testutil/driver.c b/test/testutil/driver.c index 10d74e2ea4..2da83ed727 100644 --- a/test/testutil/driver.c +++ b/test/testutil/driver.c @@ -280,20 +280,20 @@ void set_test_title(const char *title) test_title = title == NULL ? NULL : strdup(title); } -PRINTF_FORMAT(2, 3) static void test_verdict(int pass, const char *extra, ...) +PRINTF_FORMAT(2, 3) static void test_verdict(int verdict, + const char *description, ...) { va_list ap; test_flush_stdout(); test_flush_stderr(); - test_printf_stdout("%*s%s", level, "", pass ? "ok" : "not ok"); - if (extra != NULL) { - test_printf_stdout(" "); - va_start(ap, extra); - test_vprintf_stdout(extra, ap); - va_end(ap); - } + test_printf_stdout("%*s%s ", level, "", verdict != 0 ? "ok" : "not ok"); + va_start(ap, description); + test_vprintf_stdout(description, ap); + va_end(ap); + if (verdict == TEST_SKIP_CODE) + test_printf_stdout(" # skipped"); test_printf_stdout("\n"); test_flush_stdout(); } @@ -349,20 +349,14 @@ int run_tests(const char *test_prog_name) } test_flush_stdout(); } else if (all_tests[i].num == -1) { - int ret = 0; - set_test_title(all_tests[i].test_case_name); - ret = all_tests[i].test_fn(); - verdict = 1; - if (!ret) { - verdict = 0; - ++num_failed; - } + verdict = all_tests[i].test_fn(); test_verdict(verdict, "%d - %s", ii + 1, test_title); - finalize(ret); + finalize(verdict != 0); } else { int num_failed_inner = 0; + verdict = TEST_SKIP_CODE; level += 4; if (all_tests[i].subtest && single_iter == -1) { test_printf_stdout("%*s# Subtest: %s\n", level, "", @@ -381,39 +375,34 @@ int run_tests(const char *test_prog_name) while (jstep == 0 || gcd(all_tests[i].num, jstep) != 1); for (jj = 0; jj < all_tests[i].num; jj++) { - int ret; + int v; j = (j + jstep) % all_tests[i].num; if (single_iter != -1 && ((jj + 1) != single_iter)) continue; set_test_title(NULL); - ret = all_tests[i].param_test_fn(j); + v = all_tests[i].param_test_fn(j); - if (!ret) + if (v == 0) { ++num_failed_inner; + verdict = 0; + } else if (v != TEST_SKIP_CODE && verdict != 0) { + verdict = 1; + } - finalize(ret); + finalize(v != 0); if (all_tests[i].subtest) { - verdict = 1; - if (!ret) { - verdict = 0; - ++num_failed_inner; - } if (test_title != NULL) - test_verdict(verdict, "%d - %s", jj + 1, test_title); + test_verdict(v, "%d - %s", jj + 1, test_title); else - test_verdict(verdict, "%d - iteration %d", - jj + 1, j + 1); + test_verdict(v, "%d - iteration %d", jj + 1, j + 1); } } level -= 4; - verdict = 1; - if (num_failed_inner) { - verdict = 0; + if (verdict == 0) ++num_failed; - } test_verdict(verdict, "%d - %s", ii + 1, all_tests[i].test_case_name); } |