Home | History | Annotate | Line # | Download | only in testutil
basic_output.c revision 1.1
      1 /*
      2  * Copyright 2017-2018 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 #include "output.h"
     12 #include "tu_local.h"
     13 
     14 #include <openssl/crypto.h>
     15 #include <openssl/bio.h>
     16 
     17 BIO *bio_out = NULL;
     18 BIO *bio_err = NULL;
     19 
     20 void test_open_streams(void)
     21 {
     22     bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
     23     bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
     24 #ifdef __VMS
     25     bio_out = BIO_push(BIO_new(BIO_f_linebuffer()), bio_out);
     26     bio_err = BIO_push(BIO_new(BIO_f_linebuffer()), bio_err);
     27 #endif
     28     bio_err = BIO_push(BIO_new(BIO_f_tap()), bio_err);
     29 
     30     OPENSSL_assert(bio_out != NULL);
     31     OPENSSL_assert(bio_err != NULL);
     32 }
     33 
     34 void test_close_streams(void)
     35 {
     36     BIO_free_all(bio_out);
     37     BIO_free_all(bio_err);
     38 }
     39 
     40 int test_vprintf_stdout(const char *fmt, va_list ap)
     41 {
     42     return BIO_vprintf(bio_out, fmt, ap);
     43 }
     44 
     45 int test_vprintf_stderr(const char *fmt, va_list ap)
     46 {
     47     return BIO_vprintf(bio_err, fmt, ap);
     48 }
     49 
     50 int test_flush_stdout(void)
     51 {
     52     return BIO_flush(bio_out);
     53 }
     54 
     55 int test_flush_stderr(void)
     56 {
     57     return BIO_flush(bio_err);
     58 }
     59