summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2018-01-28 09:49:46 +0100
committerRichard Levitte <levitte@openssl.org>2018-02-01 07:10:48 +0100
commit71bb86f0dc72c49d9efc098a71a6654004a2035a (patch)
tree49c531123f5e7a05775a008390c987478a05389a /apps
parent39556e63ef6c079d144b07d7f492152abf9efe77 (diff)
Make sure that apps/openssl prefixes its output with '# ' during tests
The reason to do this is that some output might start with an 'ok', which TAP catches and takes for TAP output. The TAP compatible way is to make all output it shouldn't catch look like comments. We do this by setting the environment variable HARNESS_OSSL_PREFIX during tests. When that is set, apps/openssl uses BIO_f_linebuffer and sets its prefix to the content of that environment variable. Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/5224)
Diffstat (limited to 'apps')
-rw-r--r--apps/apps.c20
-rw-r--r--apps/apps.h6
-rw-r--r--apps/openssl.c1
3 files changed, 26 insertions, 1 deletions
diff --git a/apps/apps.c b/apps/apps.c
index 834cedd5a3..0438bdb9bf 100644
--- a/apps/apps.c
+++ b/apps/apps.c
@@ -1,5 +1,5 @@
/*
- * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved.
*
* Licensed under the OpenSSL license (the "License"). You may not use
* this file except in compliance with the License. You can obtain a copy
@@ -2428,14 +2428,26 @@ BIO *dup_bio_in(int format)
BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
}
+static BIO_METHOD *prefix_method = NULL;
+
BIO *dup_bio_out(int format)
{
BIO *b = BIO_new_fp(stdout,
BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
+ void *prefix = NULL;
+
#ifdef OPENSSL_SYS_VMS
if (istext(format))
b = BIO_push(BIO_new(BIO_f_linebuffer()), b);
#endif
+
+ if (istext(format) && (prefix = getenv("HARNESS_OSSL_PREFIX")) != NULL) {
+ if (prefix_method == NULL)
+ prefix_method = apps_bf_prefix();
+ b = BIO_push(BIO_new(prefix_method), b);
+ BIO_ctrl(b, PREFIX_CTRL_SET_PREFIX, 0, prefix);
+ }
+
return b;
}
@@ -2450,6 +2462,12 @@ BIO *dup_bio_err(int format)
return b;
}
+void destroy_prefix_method()
+{
+ BIO_meth_free(prefix_method);
+ prefix_method = NULL;
+}
+
void unbuffer(FILE *fp)
{
/*
diff --git a/apps/apps.h b/apps/apps.h
index 272b967d18..daaef369bc 100644
--- a/apps/apps.h
+++ b/apps/apps.h
@@ -55,6 +55,12 @@ BIO_METHOD *apps_bf_prefix(void);
* remains unlikely for the foreseeable future and beyond.
*/
#define PREFIX_CTRL_SET_PREFIX (1 << 15)
+/*
+ * apps_bf_prefix() returns a dynamically created BIO_METHOD, which we
+ * need to destroy at some point. When created internally, it's stored
+ * in an internal pointer which can be freed with the following function
+ */
+void destroy_prefix_method(void);
BIO *dup_bio_in(int format);
BIO *dup_bio_out(int format);
diff --git a/apps/openssl.c b/apps/openssl.c
index fe1eabdede..fffa05e1c7 100644
--- a/apps/openssl.c
+++ b/apps/openssl.c
@@ -93,6 +93,7 @@ static int apps_startup()
static void apps_shutdown()
{
destroy_ui_method();
+ destroy_prefix_method();
}
static char *make_config_name()