From d61f00780a232659161ac08847cd787af8672845 Mon Sep 17 00:00:00 2001 From: Emilia Kasper Date: Tue, 9 Aug 2016 17:03:23 +0200 Subject: Add TEST_check Like OPENSSL_assert, but also prints the error stack before exiting. Reviewed-by: Rich Salz --- test/testutil.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'test/testutil.h') diff --git a/test/testutil.h b/test/testutil.h index 0ff2a82f72..14b7b09800 100644 --- a/test/testutil.h +++ b/test/testutil.h @@ -10,6 +10,8 @@ #ifndef HEADER_TESTUTIL_H # define HEADER_TESTUTIL_H +#include + /*- * SETUP_TEST_FIXTURE and EXECUTE_TEST macros for test case functions. * @@ -94,3 +96,16 @@ int run_tests(const char *test_prog_name); */ int strings_equal(const char *desc, const char *s1, const char *s2); #endif /* HEADER_TESTUTIL_H */ + +/* + * For "impossible" conditions such as malloc failures or bugs in test code, + * where continuing the test would be meaningless. Note that OPENSSL_assert + * is fatal, and is never compiled out. + */ +#define TEST_check(condition) \ + do { \ + if (!(condition)) { \ + ERR_print_errors_fp(stderr); \ + OPENSSL_assert(!#condition); \ + } \ + } while (0); -- cgit v1.2.3