#include <string.h>
#include "e_os.h"
+#include <openssl/err.h>
+
/*
* Declares the structures needed to register each test case function.
*/
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;
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);
}
}
}