From 0f81f5f78c06bd69a96deb66cd30e50a67310ef2 Mon Sep 17 00:00:00 2001
From: Richard Levitte <levitte@openssl.org>
Date: Fri, 4 Sep 2015 14:07:57 +0200
Subject: [PATCH] Have the test executables output in text mode

The test executables use standard output and standard error for text output,
so let's open the corresponding BIOs in text mode.

Reviewed-by: Tim Hudson <tjh@openssl.org>
---
 test/bntest.c    | 2 +-
 test/dhtest.c    | 2 +-
 test/dsatest.c   | 2 +-
 test/ecdhtest.c  | 2 +-
 test/ecdsatest.c | 2 +-
 test/exptest.c   | 2 +-
 test/jpaketest.c | 2 +-
 test/srptest.c   | 2 +-
 test/ssltest.c   | 2 +-
 9 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/test/bntest.c b/test/bntest.c
index effbd7524..675d0eb26 100644
--- a/test/bntest.c
+++ b/test/bntest.c
@@ -168,7 +168,7 @@ int main(int argc, char *argv[])
     if (out == NULL)
         EXIT(1);
     if (outfile == NULL) {
-        BIO_set_fp(out, stdout, BIO_NOCLOSE);
+        BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
     } else {
         if (!BIO_write_filename(out, outfile)) {
             perror(outfile);
diff --git a/test/dhtest.c b/test/dhtest.c
index 7e46166ee..9ce92ee39 100644
--- a/test/dhtest.c
+++ b/test/dhtest.c
@@ -107,7 +107,7 @@ int main(int argc, char *argv[])
     out = BIO_new(BIO_s_file());
     if (out == NULL)
         EXIT(1);
-    BIO_set_fp(out, stdout, BIO_NOCLOSE);
+    BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 
     _cb = BN_GENCB_new();
     if (!_cb)
diff --git a/test/dsatest.c b/test/dsatest.c
index e138c6414..1f4b8379c 100644
--- a/test/dsatest.c
+++ b/test/dsatest.c
@@ -136,7 +136,7 @@ int main(int argc, char **argv)
     unsigned int siglen;
 
     if (bio_err == NULL)
-        bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
+        bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
 
     CRYPTO_malloc_debug_init();
     CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
diff --git a/test/ecdhtest.c b/test/ecdhtest.c
index 47c8185b7..0145b36c7 100644
--- a/test/ecdhtest.c
+++ b/test/ecdhtest.c
@@ -466,7 +466,7 @@ int main(int argc, char *argv[])
     out = BIO_new(BIO_s_file());
     if (out == NULL)
         EXIT(1);
-    BIO_set_fp(out, stdout, BIO_NOCLOSE);
+    BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 
     if ((ctx = BN_CTX_new()) == NULL)
         goto err;
diff --git a/test/ecdsatest.c b/test/ecdsatest.c
index 4b6d0444b..2cf1725d6 100644
--- a/test/ecdsatest.c
+++ b/test/ecdsatest.c
@@ -510,7 +510,7 @@ int main(void)
     int ret = 1;
     BIO *out;
 
-    out = BIO_new_fp(stdout, BIO_NOCLOSE);
+    out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 
     /* enable memory leak checking unless explicitly disabled */
     if (!((getenv("OPENSSL_DEBUG_MEMORY") != NULL) &&
diff --git a/test/exptest.c b/test/exptest.c
index 2da8dc2ff..97b74d98d 100644
--- a/test/exptest.c
+++ b/test/exptest.c
@@ -151,7 +151,7 @@ int main(int argc, char *argv[])
 
     if (out == NULL)
         EXIT(1);
-    BIO_set_fp(out, stdout, BIO_NOCLOSE);
+    BIO_set_fp(out, stdout, BIO_NOCLOSE | BIO_FP_TEXT);
 
     for (i = 0; i < 200; i++) {
         RAND_bytes(&c, 1);
diff --git a/test/jpaketest.c b/test/jpaketest.c
index ef9e54bdb..15f00cf2e 100644
--- a/test/jpaketest.c
+++ b/test/jpaketest.c
@@ -114,7 +114,7 @@ int main(int argc, char **argv)
     BIGNUM *secret = BN_new();
     BIO *bio_err;
 
-    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
+    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
 
     CRYPTO_malloc_debug_init();
     CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
diff --git a/test/srptest.c b/test/srptest.c
index 807521807..60cdbc31f 100644
--- a/test/srptest.c
+++ b/test/srptest.c
@@ -124,7 +124,7 @@ static int run_srp(const char *username, const char *client_pass,
 int main(int argc, char **argv)
 {
     BIO *bio_err;
-    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE);
+    bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
 
     CRYPTO_malloc_debug_init();
     CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
diff --git a/test/ssltest.c b/test/ssltest.c
index 6f9d16c51..4959aed3a 100644
--- a/test/ssltest.c
+++ b/test/ssltest.c
@@ -1310,7 +1310,7 @@ int main(int argc, char *argv[])
     if (fips_mode) {
         if (!FIPS_mode_set(1)) {
             ERR_load_crypto_strings();
-            ERR_print_errors(BIO_new_fp(stderr, BIO_NOCLOSE));
+            ERR_print_errors(bio_err);
             EXIT(1);
         } else
             fprintf(stderr, "*** IN FIPS MODE ***\n");