IF[{- !$disabled{tests} -}]
LIBS_NO_INST=libtestutil.a
SOURCE[libtestutil.a]=testutil/basic_output.c testutil/output_helpers.c \
- testutil/driver.c testutil/tests.c \
+ testutil/driver.c testutil/tests.c testutil/cb.c \
{- rebase_files("../apps", $target{apps_aux_src}) -} \
testutil/test_main.c testutil/main.c
INCLUDE[libtestutil.a]=.. ../include
void test_info(const char *file, int line, const char *desc, ...)
PRINTF_FORMAT(3, 4);
void test_info_c90(const char *desc, ...) PRINTF_FORMAT(1, 2);
+void test_openssl_errors(void);
/*
* The following macros provide wrapper calls to the test functions with
# define TEST_error(...) test_error(__FILE__, __LINE__, __VA_ARGS__)
# define TEST_info(...) test_info(__FILE__, __LINE__, __VA_ARGS__)
# endif
+# define TEST_openssl_errors test_openssl_errors
/*
* For "impossible" conditions such as malloc failures or bugs in test code,
# define TEST_check(condition) \
do { \
if (!(condition)) { \
- ERR_print_errors_fp(stderr); \
+ TEST_openssl_errors(); \
OPENSSL_assert(!#condition); \
} \
} while (0)
--- /dev/null
+/*
+ * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#include "output.h"
+#include "tu_local.h"
+
+int openssl_error_cb(const char *str, size_t len, void *u)
+{
+ return test_printf_stderr("%*s# %s", subtest_level(), "", str);
+}
}
#endif
-static int err_cb(const char *str, size_t len, void *u)
-{
- return test_puts_stderr(str);
-}
-
void setup_test()
{
char *TAP_levels = getenv("HARNESS_OSSL_LEVEL");
int finish_test(int ret)
{
#ifndef OPENSSL_NO_CRYPTO_MDEBUG
- if (should_report_leaks() && CRYPTO_mem_leaks_cb(err_cb, NULL) <= 0)
+ if (should_report_leaks()
+ && CRYPTO_mem_leaks_cb(openssl_error_cb, NULL) <= 0)
return EXIT_FAILURE;
#endif
if (success)
ERR_clear_error();
else
- ERR_print_errors_cb(err_cb, NULL);
+ ERR_print_errors_cb(openssl_error_cb, NULL);
}
int run_tests(const char *test_prog_name)
va_end(ap);
}
+void test_openssl_errors(void)
+{
+ ERR_print_errors_cb(openssl_error_cb, NULL);
+}
+
/*
* Define some comparisons between pairs of various types.
* These functions return 1 if the test is true.
* https://www.openssl.org/source/license.html
*/
+#include <stdlib.h> /* size_t */
+
int subtest_level(void);
+int openssl_error_cb(const char *str, size_t len, void *u);