#ifndef HEADER_TESTUTIL_H
# define HEADER_TESTUTIL_H
+#include <openssl/err.h>
+
/*-
* SETUP_TEST_FIXTURE and EXECUTE_TEST macros for test case functions.
*
void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num);
int run_tests(const char *test_prog_name);
+/*
+ * Test assumption verification helpers.
+ */
+
+/*
+ * Returns 1 if |s1| and |s2| are both NULL or equal.
+ * Otherwise, returns 0 and pretty-prints diagnostics using |desc|.
+ */
+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)