tests: add diag_multiline() helper to escape multi-line diagnostic info
[babeltrace.git] / tests / utils / tap / tap.h
CommitLineData
aa968dde
YB
1/*-
2 * Copyright (c) 2004 Nik Clayton
840c5b80 3 * 2017 Jérémie Galarneau
aa968dde
YB
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
29 and requires the caller to add the final comma if they've ommitted
30 the optional arguments */
31#ifdef __GNUC__
32# define ok(e, test, ...) ((e) ? \
33 _gen_result(1, __func__, __FILE__, __LINE__, \
34 test, ## __VA_ARGS__) : \
35 _gen_result(0, __func__, __FILE__, __LINE__, \
36 test, ## __VA_ARGS__))
37
38# define ok1(e) ((e) ? \
39 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
40 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
41
42# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
43# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
44
45# define skip_start(test, n, fmt, ...) \
46 do { \
47 if((test)) { \
48 skip(n, fmt, ## __VA_ARGS__); \
49 continue; \
50 }
51#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
52# define ok(e, ...) ((e) ? \
53 _gen_result(1, __func__, __FILE__, __LINE__, \
54 __VA_ARGS__) : \
55 _gen_result(0, __func__, __FILE__, __LINE__, \
56 __VA_ARGS__))
57
58# define ok1(e) ((e) ? \
59 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
60 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
61
62# define pass(...) ok(1, __VA_ARGS__);
63# define fail(...) ok(0, __VA_ARGS__);
64
65# define skip_start(test, n, ...) \
66 do { \
67 if((test)) { \
68 skip(n, __VA_ARGS__); \
69 continue; \
70 }
71#else /* __STDC_VERSION__ */
72# error "Needs gcc or C99 compiler for variadic macros."
73#endif /* __STDC_VERSION__ */
74
75#define skip_end() } while(0);
76
77unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...);
78
79int plan_no_plan(void);
80int plan_skip_all(char *);
81int plan_tests(unsigned int);
82
83unsigned int diag(char *, ...);
840c5b80 84void diag_multiline(const char *);
aa968dde
YB
85
86int skip(unsigned int, char *, ...);
87
88void todo_start(char *, ...);
89void todo_end(void);
90
91int exit_status(void);
This page took 0.044432 seconds and 4 git commands to generate.