Import warning flags and tap from Babeltrace
[argpar.git] / tests / tap / tap.h
CommitLineData
a99ee691
SM
1/*
2 * SPDX-License-Identifier: BSD-2-Clause
7ac57709 3 *
a99ee691
SM
4 * Copyright (C) 2004 Nik Clayton
5 * Copyright (C) 2017 Jérémie Galarneau
7ac57709
SM
6 */
7
a99ee691
SM
8/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
9 and requires the caller to add the final comma if they've ommitted
10 the optional arguments */
11#ifdef __GNUC__
12# define ok(e, test, ...) ((e) ? \
13 _gen_result(1, __func__, __FILE__, __LINE__, \
14 test, ## __VA_ARGS__) : \
15 _gen_result(0, __func__, __FILE__, __LINE__, \
16 test, ## __VA_ARGS__))
7ac57709 17
7ac57709
SM
18# define ok1(e) ((e) ? \
19 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
20 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
21
a99ee691
SM
22# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
23# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
24
25# define skip_start(test, n, fmt, ...) \
26 do { \
27 if((test)) { \
28 skip(n, fmt, ## __VA_ARGS__); \
29 continue; \
30 }
31#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
7ac57709
SM
32# define ok(e, ...) ((e) ? \
33 _gen_result(1, __func__, __FILE__, __LINE__, \
34 __VA_ARGS__) : \
35 _gen_result(0, __func__, __FILE__, __LINE__, \
36 __VA_ARGS__))
37
a99ee691
SM
38# define ok1(e) ((e) ? \
39 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
40 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
7ac57709 41
a99ee691
SM
42# define pass(...) ok(1, __VA_ARGS__);
43# define fail(...) ok(0, __VA_ARGS__);
7ac57709
SM
44
45# define skip_start(test, n, ...) \
46 do { \
47 if((test)) { \
48 skip(n, __VA_ARGS__); \
49 continue; \
50 }
a99ee691
SM
51#else /* __STDC_VERSION__ */
52# error "Needs gcc or C99 compiler for variadic macros."
53#endif /* __STDC_VERSION__ */
7ac57709 54
a99ee691 55#define skip_end() } while(0);
7ac57709 56
a99ee691
SM
57#ifdef __MINGW_PRINTF_FORMAT
58# define TAP_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
7ac57709 59#else
a99ee691 60# define TAP_PRINTF_FORMAT printf
7ac57709
SM
61#endif
62
a99ee691
SM
63__attribute__((format(TAP_PRINTF_FORMAT, 5, 6)))
64unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...);
7ac57709 65
a99ee691
SM
66int plan_no_plan(void);
67__attribute__((noreturn))
68int plan_skip_all(const char *);
69int plan_tests(unsigned int);
7ac57709 70
a99ee691
SM
71__attribute__((format(TAP_PRINTF_FORMAT, 1, 2)))
72unsigned int diag(const char *, ...);
73void diag_multiline(const char *);
7ac57709 74
a99ee691
SM
75__attribute__((format(TAP_PRINTF_FORMAT, 2, 3)))
76int skip(unsigned int, const char *, ...);
7ac57709 77
a99ee691
SM
78__attribute__((format(TAP_PRINTF_FORMAT, 1, 2)))
79void todo_start(const char *, ...);
7ac57709
SM
80void todo_end(void);
81
7ac57709 82int exit_status(void);
This page took 0.025297 seconds and 4 git commands to generate.