Fix errtest for older compilers
authorShane Lontis <shane.lontis@oracle.com>
Wed, 27 May 2020 02:10:52 +0000 (12:10 +1000)
committerShane Lontis <shane.lontis@oracle.com>
Thu, 28 May 2020 04:18:13 +0000 (14:18 +1000)
Some older compilers use "unknown function" if they dont support __func, so the
test using ERR_PUT_error needed to compensate for this when comparing against the
expected value.

Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11967)

test/errtest.c

index cc2f661..9adf4ca 100644 (file)
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <openssl/opensslconf.h>
 #include <openssl/err.h>
+#include <openssl/macros.h>
 
 #include "testutil.h"
 
 
 static int test_print_error_format(void)
 {
-    static const char expected[] =
-        ":error::system library:test_print_error_format:Operation not permitted:"
+    static const char expected_format[] =
+        ":error::system library:%s:Operation not permitted:"
 # ifndef OPENSSL_NO_FILENAMES
         "errtest.c:30:";
 # else
         ":0:";
 # endif
+    char expected[256];
     char *out = NULL, *p = NULL;
     int ret = 0, len;
     BIO *bio = NULL;
 
+    BIO_snprintf(expected, sizeof(expected), expected_format, OPENSSL_FUNC);
+
     if (!TEST_ptr(bio = BIO_new(BIO_s_mem())))
         return 0;