output.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright 2014-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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. #ifndef OSSL_TESTUTIL_OUTPUT_H
  10. # define OSSL_TESTUTIL_OUTPUT_H
  11. # include <stdarg.h>
  12. # define ossl_test__attr__(x)
  13. # if defined(__GNUC__) && defined(__STDC_VERSION__) \
  14. && !defined(__APPLE__)
  15. /*
  16. * Because we support the 'z' modifier, which made its appearance in C99,
  17. * we can't use __attribute__ with pre C99 dialects.
  18. */
  19. # if __STDC_VERSION__ >= 199901L
  20. # undef ossl_test__attr__
  21. # define ossl_test__attr__ __attribute__
  22. # if __GNUC__*10 + __GNUC_MINOR__ >= 44
  23. # define ossl_test__printf__ __gnu_printf__
  24. # else
  25. # define ossl_test__printf__ __printf__
  26. # endif
  27. # endif
  28. # endif
  29. /*
  30. * The basic I/O functions used internally by the test framework. These
  31. * can be overridden when needed. Note that if one is, then all must be.
  32. */
  33. void test_open_streams(void);
  34. void test_close_streams(void);
  35. void test_adjust_streams_tap_level(int level);
  36. /* The following ALL return the number of characters written */
  37. int test_vprintf_stdout(const char *fmt, va_list ap)
  38. ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
  39. int test_vprintf_tapout(const char *fmt, va_list ap)
  40. ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
  41. int test_vprintf_stderr(const char *fmt, va_list ap)
  42. ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
  43. int test_vprintf_taperr(const char *fmt, va_list ap)
  44. ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
  45. /* These return failure or success */
  46. int test_flush_stdout(void);
  47. int test_flush_tapout(void);
  48. int test_flush_stderr(void);
  49. int test_flush_taperr(void);
  50. /* Commodity functions. There's no need to override these */
  51. int test_printf_stdout(const char *fmt, ...)
  52. ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
  53. int test_printf_tapout(const char *fmt, ...)
  54. ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
  55. int test_printf_stderr(const char *fmt, ...)
  56. ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
  57. int test_printf_taperr(const char *fmt, ...)
  58. ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
  59. # undef ossl_test__printf__
  60. # undef ossl_test__attr__
  61. #endif /* OSSL_TESTUTIL_OUTPUT_H */