#include <openssl/e_os2.h>
/*-
- * Simple unit tests should implement register_tests() from test_main.h
- * and link against test_main.c.
+ * Simple unit tests should implement register_tests().
* To register tests, call ADD_TEST or ADD_ALL_TESTS:
*
- * #include "test_main.h"
- *
* void register_tests(void)
* {
* ADD_TEST(test_foo);
* }
*
* Tests that need to perform custom setup or read command-line arguments should
- * implement test_main() from test_main_custom.h and link against
- * test_main_custom.c:
+ * implement test_main():
*
* int test_main(int argc, char *argv[])
* {
* Simple parameterized tests. Calls test_function(idx) for each 0 <= idx < num.
*/
# define ADD_ALL_TESTS(test_function, num) \
- add_all_tests(#test_function, test_function, num)
+ add_all_tests(#test_function, test_function, num, 1)
+/*
+ * A variant of the same without TAP output.
+ */
+# define ADD_ALL_TESTS_NOSUBTEST(test_function, num) \
+ add_all_tests(#test_function, test_function, num, 0)
/*-
* Test cases that share common setup should use the helper
__owur int finish_test(int ret);
void add_test(const char *test_case_name, int (*test_fn) ());
-void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num);
+void add_all_tests(const char *test_case_name, int (*test_fn)(int idx), int num,
+ int subtest);
__owur int run_tests(const char *test_prog_name);
+/*
+ * Declarations for user defined functions
+ */
+void register_tests(void);
+int test_main(int argc, char *argv[]);
+
+
/*
* Test assumption verification helpers.
*/
-# if defined(__GNUC__)
-#define PRINTF_FORMAT(a, b) __attribute__ ((format(printf, a, b)))
-# else
#define PRINTF_FORMAT(a, b)
+#if defined(__GNUC__) && defined(__STDC_VERSION__)
+ /*
+ * Because we support the 'z' modifier, which made its appearance in C99,
+ * we can't use __attribute__ with pre C99 dialects.
+ */
+# if __STDC_VERSION__ >= 199901L
+# undef PRINTF_FORMAT
+# define PRINTF_FORMAT(a, b) __attribute__ ((format(printf, a, b)))
+# endif
#endif
# define DECLARE_COMPARISON(type, name, opname) \
DECLARE_COMPARISONS(unsigned char, uchar)
DECLARE_COMPARISONS(long, long)
DECLARE_COMPARISONS(unsigned long, ulong)
+/*
+ * Because this comparison uses a printf format specifier that's not
+ * universally known (yet), we provide an option to not have it declared.
+ */
+# ifndef TESTUTIL_NO_size_t_COMPARISON
DECLARE_COMPARISONS(size_t, size_t)
+# endif
/*
* Pointer comparisons against other pointers and null.
DECLARE_COMPARISON(char *, str, eq)
DECLARE_COMPARISON(char *, str, ne)
+/*
+ * Same as above, but for strncmp.
+ */
+int test_strn_eq(const char *file, int line, const char *, const char *,
+ const char *a, const char *b, size_t s);
+int test_strn_ne(const char *file, int line, const char *, const char *,
+ const char *a, const char *b, size_t s);
+
/*
* Equality test for memory blocks where NULL is a legitimate value.
* These calls return 1 if the two memory blocks compare true.
# define TEST_str_eq(a, b) test_str_eq(__FILE__, __LINE__, #a, #b, a, b)
# define TEST_str_ne(a, b) test_str_ne(__FILE__, __LINE__, #a, #b, a, b)
+# define TEST_strn_eq(a, b, n) test_strn_eq(__FILE__, __LINE__, #a, #b, a, b, n)
+# define TEST_strn_ne(a, b, n) test_strn_ne(__FILE__, __LINE__, #a, #b, a, b, n)
# define TEST_mem_eq(a, m, b, n) test_mem_eq(__FILE__, __LINE__, #a, #b, a, m, b, n)
# define TEST_mem_ne(a, m, b, n) test_mem_ne(__FILE__, __LINE__, #a, #b, a, m, b, n)
OPENSSL_assert(!#condition); \
} \
} while (0)
+
+extern BIO *bio_out;
+extern BIO *bio_err;
+
+int subtest_level(void);
#endif /* HEADER_TESTUTIL_H */