output.h 2.5 KB

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