test: don't make it more complicated than necessary.
[openssl.git] / test / testutil / basic_output.c
1 /*
2  * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include "../testutil.h"
11
12 #include <openssl/crypto.h>
13 #include <openssl/bio.h>
14
15 BIO *bio_out = NULL;
16 BIO *bio_err = NULL;
17
18 void test_open_streams(void)
19 {
20     bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
21     bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
22
23     OPENSSL_assert(bio_out != NULL);
24     OPENSSL_assert(bio_err != NULL);
25 }
26
27 void test_close_streams(void)
28 {
29     BIO_free(bio_out);
30     BIO_free(bio_err);
31 }
32
33 int test_puts_stdout(const char *str)
34 {
35     return BIO_puts(bio_out, str);
36 }
37
38 int test_puts_stderr(const char *str)
39 {
40     return BIO_puts(bio_err, str);
41 }
42
43 int test_vprintf_stdout(const char *fmt, va_list ap)
44 {
45     return BIO_vprintf(bio_out, fmt, ap);
46 }
47
48 int test_vprintf_stderr(const char *fmt, va_list ap)
49 {
50     return BIO_vprintf(bio_err, fmt, ap);
51 }
52
53 int test_flush_stdout(void)
54 {
55     return BIO_flush(bio_out);
56 }
57
58 int test_flush_stderr(void)
59 {
60     return BIO_flush(bio_err);
61 }