Constify X509|X509_CRL|X509_REVOKED_get_ext
[openssl.git] / test / testutil.c
index 9a67630fd3f9fd9d996a22d5ae11876e4b1fec11..a16ef0fa0779920a47a93bf13abbc3adb4f1e3f3 100644 (file)
@@ -12,6 +12,7 @@
 #include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <string.h>
 #include "e_os.h"
 
 /*
@@ -89,3 +90,20 @@ int run_tests(const char *test_prog_name)
     printf("  All tests passed.\n");
     return EXIT_SUCCESS;
 }
+
+static const char *print_string_maybe_null(const char *s)
+{
+    return s == NULL ? "(NULL)" : s;
+}
+
+int strings_equal(const char *desc, const char *s1, const char *s2)
+{
+    if (s1 == NULL && s2 == NULL)
+      return 1;
+    if (s1 == NULL || s2 == NULL || strcmp(s1, s2) != 0) {
+        fprintf(stderr, "%s mismatch: %s vs %s\n", desc, print_string_maybe_null(s1),
+                print_string_maybe_null(s2));
+        return 0;
+    }
+    return 1;
+}