diff options
author | Emilia Kasper <emilia@openssl.org> | 2016-11-03 14:27:05 +0100 |
---|---|---|
committer | Emilia Kasper <emilia@openssl.org> | 2016-11-04 15:05:29 +0100 |
commit | 6ec327eed616deeb4e5ecf1abfb1e1a530ba0701 (patch) | |
tree | 2521227973a0270863480924ab068a5b1fa2efa9 /test/testutil.c | |
parent | 7b1954384114643e1a3c3a0ababa3fd7a112c5e3 (diff) |
testutil: always print errors on failure
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'test/testutil.c')
-rw-r--r-- | test/testutil.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/test/testutil.c b/test/testutil.c index a16ef0fa07..c783b4a98a 100644 --- a/test/testutil.c +++ b/test/testutil.c @@ -15,6 +15,8 @@ #include <string.h> #include "e_os.h" +#include <openssl/err.h> + /* * Declares the structures needed to register each test case function. */ @@ -55,6 +57,14 @@ void add_all_tests(const char *test_case_name, int(*test_fn)(int idx), num_test_cases += num; } +static void finalize(int success) +{ + if (success) + ERR_clear_error(); + else + ERR_print_errors_fp(stderr); +} + int run_tests(const char *test_prog_name) { int num_failed = 0; @@ -66,18 +76,22 @@ int run_tests(const char *test_prog_name) for (i = 0; i != num_tests; ++i) { if (all_tests[i].num == -1) { - if (!all_tests[i].test_fn()) { + int ret = all_tests[i].test_fn(); + if (!ret) { printf("** %s failed **\n--------\n", all_tests[i].test_case_name); ++num_failed; } + finalize(ret); } else { for (j = 0; j < all_tests[i].num; j++) { - if (!all_tests[i].param_test_fn(j)) { + int ret = all_tests[i].param_test_fn(j); + if (!ret) { printf("** %s failed test %d\n--------\n", all_tests[i].test_case_name, j); ++num_failed; } + finalize(ret); } } } |