Remove misleading diagnostics on pinned sender cert in OSSL_CMP_validate_msg()
[openssl.git] / test / bioprinttest.c
index d35bffa8408b94045a6f91dded41a5befaa9f091..04d1613c6cf499a701497c1eea9fb79f94d7381f 100644 (file)
@@ -1,7 +1,7 @@
 /*
- * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
  *
- * Licensed under the OpenSSL license (the "License").  You may not use
+ * Licensed under the Apache License 2.0 (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
  * in the file LICENSE in the source distribution or at
  * https://www.openssl.org/source/license.html
@@ -146,14 +146,14 @@ typedef struct j_data_st {
 } j_data;
 
 static j_data jf_data[] = {
-    { 0xffffffffffffffffU, "%ju", "18446744073709551615" },
-    { 0xffffffffffffffffU, "%jx", "ffffffffffffffff" },
-    { 0x8000000000000000U, "%ju", "9223372036854775808" },
+    { 0xffffffffffffffffULL, "%ju", "18446744073709551615" },
+    { 0xffffffffffffffffULL, "%jx", "ffffffffffffffff" },
+    { 0x8000000000000000ULL, "%ju", "9223372036854775808" },
     /*
      * These tests imply two's-complement, but it's the only binary
      * representation we support, see test/sanitytest.c...
      */
-    { 0x8000000000000000U, "%ji", "-9223372036854775808" },
+    { 0x8000000000000000ULL, "%ji", "-9223372036854775808" },
 };
 
 static int test_j(int i)
@@ -249,13 +249,42 @@ static int test_big(void)
     if (!TEST_int_eq(BIO_snprintf(buf, sizeof(buf),
                                   "%f\n", 2 * (double)ULONG_MAX), -1))
         return 0;
+
     return 1;
 }
 
+typedef enum OPTION_choice {
+    OPT_ERR = -1,
+    OPT_EOF = 0,
+    OPT_PRINT,
+    OPT_TEST_ENUM
+} OPTION_CHOICE;
+
+const OPTIONS *test_get_options(void)
+{
+    static const OPTIONS options[] = {
+        OPT_TEST_OPTIONS_DEFAULT_USAGE,
+        { "expected", OPT_PRINT, '-', "Output values" },
+        { NULL }
+    };
+    return options;
+}
 
 int setup_tests(void)
 {
-    justprint = test_has_option("-expected");
+    OPTION_CHOICE o;
+
+    while ((o = opt_next()) != OPT_EOF) {
+        switch (o) {
+        case OPT_PRINT:
+            justprint = 1;
+            break;
+        case OPT_TEST_CASES:
+            break;
+        default:
+            return 0;
+        }
+    }
 
     ADD_TEST(test_big);
     ADD_ALL_TESTS(test_fp, nelem(pw_params));
@@ -268,10 +297,20 @@ int setup_tests(void)
  * Replace testutil output routines.  We do this to eliminate possible sources
  * of BIO error
  */
+BIO *bio_out = NULL;
+BIO *bio_err = NULL;
+
+static int tap_level = 0;
+
 void test_open_streams(void)
 {
 }
 
+void test_adjust_streams_tap_level(int level)
+{
+    tap_level = level;
+}
+
 void test_close_streams(void)
 {
 }
@@ -283,12 +322,12 @@ void test_close_streams(void)
  */
 int test_vprintf_stdout(const char *fmt, va_list ap)
 {
-    return vfprintf(stdout, fmt, ap);
+    return fprintf(stdout, "%*s# ", tap_level, "") + vfprintf(stdout, fmt, ap);
 }
 
 int test_vprintf_stderr(const char *fmt, va_list ap)
 {
-    return vfprintf(stderr, fmt, ap);
+    return fprintf(stderr, "%*s# ", tap_level, "") + vfprintf(stderr, fmt, ap);
 }
 
 int test_flush_stdout(void)
@@ -300,3 +339,24 @@ int test_flush_stderr(void)
 {
     return fflush(stderr);
 }
+
+int test_vprintf_tapout(const char *fmt, va_list ap)
+{
+    return fprintf(stdout, "%*s", tap_level, "") + vfprintf(stdout, fmt, ap);
+}
+
+int test_vprintf_taperr(const char *fmt, va_list ap)
+{
+    return fprintf(stderr, "%*s", tap_level, "") + vfprintf(stderr, fmt, ap);
+}
+
+int test_flush_tapout(void)
+{
+    return fflush(stdout);
+}
+
+int test_flush_taperr(void)
+{
+    return fflush(stderr);
+}
+