basic_output.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #include "../testutil.h"
  10. #include "output.h"
  11. #include "tu_local.h"
  12. #include <openssl/crypto.h>
  13. #include <openssl/bio.h>
  14. BIO *bio_out = NULL;
  15. BIO *bio_err = NULL;
  16. void test_open_streams(void)
  17. {
  18. bio_out = BIO_new_fp(stdout, BIO_NOCLOSE | BIO_FP_TEXT);
  19. bio_err = BIO_new_fp(stderr, BIO_NOCLOSE | BIO_FP_TEXT);
  20. #ifdef __VMS
  21. bio_out = BIO_push(BIO_new(BIO_f_linebuffer()), bio_out);
  22. bio_err = BIO_push(BIO_new(BIO_f_linebuffer()), bio_err);
  23. #endif
  24. bio_err = BIO_push(BIO_new(BIO_f_tap()), bio_err);
  25. OPENSSL_assert(bio_out != NULL);
  26. OPENSSL_assert(bio_err != NULL);
  27. }
  28. void test_close_streams(void)
  29. {
  30. BIO_free_all(bio_out);
  31. BIO_free_all(bio_err);
  32. }
  33. int test_vprintf_stdout(const char *fmt, va_list ap)
  34. {
  35. return BIO_vprintf(bio_out, fmt, ap);
  36. }
  37. int test_vprintf_stderr(const char *fmt, va_list ap)
  38. {
  39. return BIO_vprintf(bio_err, fmt, ap);
  40. }
  41. int test_flush_stdout(void)
  42. {
  43. return BIO_flush(bio_out);
  44. }
  45. int test_flush_stderr(void)
  46. {
  47. return BIO_flush(bio_err);
  48. }