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