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