summaryrefslogtreecommitdiffstats
path: root/test/testutil.h
diff options
context:
space:
mode:
authorEmilia Kasper <emilia@openssl.org>2016-08-09 17:03:23 +0200
committerEmilia Kasper <emilia@openssl.org>2016-08-10 14:41:21 +0200
commitd61f00780a232659161ac08847cd787af8672845 (patch)
treeac4c3feba589d309b0ad0650c21e3fb17c8749a6 /test/testutil.h
parentSSL tests: port CT tests, add a few more (diff)
downloadopenssl-d61f00780a232659161ac08847cd787af8672845.tar.xz
openssl-d61f00780a232659161ac08847cd787af8672845.zip
Add TEST_check
Like OPENSSL_assert, but also prints the error stack before exiting. Reviewed-by: Rich Salz <rsalz@openssl.org>
Diffstat (limited to 'test/testutil.h')
-rw-r--r--test/testutil.h15
1 files changed, 15 insertions, 0 deletions
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 <openssl/err.h>
+
/*-
* 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);