#include <errno.h>
#include <string.h>
#include <ctype.h>
-#include "../../e_os.h"
+#include "internal/nelem.h"
+#include <openssl/asn1.h>
/*
* Output a failed test first line.
const char *left, const char *right,
const char *op)
{
- test_printf_stderr("%*s# %s: ", subtest_level(), "",
- prefix != NULL ? prefix : "ERROR");
+ test_printf_stderr("%s: ", prefix != NULL ? prefix : "ERROR");
if (type)
test_printf_stderr("(%s) ", type);
if (op != NULL) {
{
test_fail_message_prefix(prefix, file, line, type, left, right, op);
if (fmt != NULL) {
- test_printf_stderr("%*s# ", subtest_level(), "");
test_vprintf_stderr(fmt, ap);
test_printf_stderr("\n");
}
if (fmt != NULL) {
va_list ap;
- test_printf_stderr("%*s# ", subtest_level(), "");
va_start(ap, fmt);
test_vprintf_stderr(fmt, ap);
va_end(ap);
BN_free(aa);
return 0;
}
+
+static const char *print_time(const ASN1_TIME *t)
+{
+ return t == NULL ? "<null>" : (char *)ASN1_STRING_get0_data(t);
+}
+
+#define DEFINE_TIME_T_COMPARISON(opname, op) \
+ int test_time_t_ ## opname(const char *file, int line, \
+ const char *s1, const char *s2, \
+ const time_t t1, const time_t t2) \
+ { \
+ ASN1_TIME *at1 = ASN1_TIME_set(NULL, t1); \
+ ASN1_TIME *at2 = ASN1_TIME_set(NULL, t2); \
+ int r = at1 != NULL && at2 != NULL \
+ && ASN1_TIME_compare(at1, at2) op 0; \
+ if (!r) \
+ test_fail_message(NULL, file, line, "time_t", s1, s2, #op, \
+ "[%s] compared to [%s]", \
+ print_time(at1), print_time(at2)); \
+ ASN1_STRING_free(at1); \
+ ASN1_STRING_free(at2); \
+ return r; \
+ }
+DEFINE_TIME_T_COMPARISON(eq, ==)
+DEFINE_TIME_T_COMPARISON(ne, !=)
+DEFINE_TIME_T_COMPARISON(gt, >)
+DEFINE_TIME_T_COMPARISON(ge, >=)
+DEFINE_TIME_T_COMPARISON(lt, <)
+DEFINE_TIME_T_COMPARISON(le, <=)