basic_output.c 1.1 KB

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