summaryrefslogtreecommitdiffstats
path: root/test/testutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/testutil.c')
-rw-r--r--test/testutil.c18
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);
}
}
}