xref: /freebsd/crypto/openssl/test/testutil/output.h (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert /*
2*e0c4386eSCy Schubert  * Copyright 2014-2022 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert  *
4*e0c4386eSCy Schubert  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert  * this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert  * in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert  * https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert  */
9*e0c4386eSCy Schubert 
10*e0c4386eSCy Schubert #ifndef OSSL_TESTUTIL_OUTPUT_H
11*e0c4386eSCy Schubert # define OSSL_TESTUTIL_OUTPUT_H
12*e0c4386eSCy Schubert 
13*e0c4386eSCy Schubert # include <stdarg.h>
14*e0c4386eSCy Schubert 
15*e0c4386eSCy Schubert # define ossl_test__attr__(x)
16*e0c4386eSCy Schubert # if defined(__GNUC__) && defined(__STDC_VERSION__) \
17*e0c4386eSCy Schubert     && !defined(__MINGW32__) && !defined(__MINGW64__) \
18*e0c4386eSCy Schubert     && !defined(__APPLE__)
19*e0c4386eSCy Schubert     /*
20*e0c4386eSCy Schubert      * Because we support the 'z' modifier, which made its appearance in C99,
21*e0c4386eSCy Schubert      * we can't use __attribute__ with pre C99 dialects.
22*e0c4386eSCy Schubert      */
23*e0c4386eSCy Schubert #  if __STDC_VERSION__ >= 199901L
24*e0c4386eSCy Schubert #   undef ossl_test__attr__
25*e0c4386eSCy Schubert #   define ossl_test__attr__ __attribute__
26*e0c4386eSCy Schubert #   if __GNUC__*10 + __GNUC_MINOR__ >= 44
27*e0c4386eSCy Schubert #    define ossl_test__printf__ __gnu_printf__
28*e0c4386eSCy Schubert #   else
29*e0c4386eSCy Schubert #    define ossl_test__printf__ __printf__
30*e0c4386eSCy Schubert #   endif
31*e0c4386eSCy Schubert #  endif
32*e0c4386eSCy Schubert # endif
33*e0c4386eSCy Schubert /*
34*e0c4386eSCy Schubert  * The basic I/O functions used internally by the test framework.  These
35*e0c4386eSCy Schubert  * can be overridden when needed. Note that if one is, then all must be.
36*e0c4386eSCy Schubert  */
37*e0c4386eSCy Schubert void test_open_streams(void);
38*e0c4386eSCy Schubert void test_close_streams(void);
39*e0c4386eSCy Schubert void test_adjust_streams_tap_level(int level);
40*e0c4386eSCy Schubert /* The following ALL return the number of characters written */
41*e0c4386eSCy Schubert int test_vprintf_stdout(const char *fmt, va_list ap)
42*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
43*e0c4386eSCy Schubert int test_vprintf_tapout(const char *fmt, va_list ap)
44*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
45*e0c4386eSCy Schubert int test_vprintf_stderr(const char *fmt, va_list ap)
46*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
47*e0c4386eSCy Schubert int test_vprintf_taperr(const char *fmt, va_list ap)
48*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 0)));
49*e0c4386eSCy Schubert /* These return failure or success */
50*e0c4386eSCy Schubert int test_flush_stdout(void);
51*e0c4386eSCy Schubert int test_flush_tapout(void);
52*e0c4386eSCy Schubert int test_flush_stderr(void);
53*e0c4386eSCy Schubert int test_flush_taperr(void);
54*e0c4386eSCy Schubert 
55*e0c4386eSCy Schubert /* Commodity functions.  There's no need to override these */
56*e0c4386eSCy Schubert int test_printf_stdout(const char *fmt, ...)
57*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
58*e0c4386eSCy Schubert int test_printf_tapout(const char *fmt, ...)
59*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
60*e0c4386eSCy Schubert int test_printf_stderr(const char *fmt, ...)
61*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
62*e0c4386eSCy Schubert int test_printf_taperr(const char *fmt, ...)
63*e0c4386eSCy Schubert     ossl_test__attr__((__format__(ossl_test__printf__, 1, 2)));
64*e0c4386eSCy Schubert 
65*e0c4386eSCy Schubert # undef ossl_test__printf__
66*e0c4386eSCy Schubert # undef ossl_test__attr__
67*e0c4386eSCy Schubert 
68*e0c4386eSCy Schubert #endif                          /* OSSL_TESTUTIL_OUTPUT_H */
69