Commit | Line | Data |
---|---|---|
0235b0db MJ |
1 | /* |
2 | * SPDX-License-Identifier: BSD-2-Clause | |
aa968dde | 3 | * |
0235b0db MJ |
4 | * Copyright (C) 2004 Nik Clayton |
5 | * Copyright (C) 2017 Jérémie Galarneau | |
aa968dde YB |
6 | */ |
7 | ||
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__)) | |
17 | ||
18 | # define ok1(e) ((e) ? \ | |
19 | _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \ | |
20 | _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) | |
21 | ||
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__ */ | |
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 | ||
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(...) 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() } while(0); | |
56 | ||
830153f4 | 57 | #ifdef __MINGW_PRINTF_FORMAT |
694fc888 | 58 | # define TAP_PRINTF_FORMAT __MINGW_PRINTF_FORMAT |
830153f4 | 59 | #else |
694fc888 | 60 | # define TAP_PRINTF_FORMAT printf |
830153f4 SM |
61 | #endif |
62 | ||
694fc888 | 63 | __attribute__((format(TAP_PRINTF_FORMAT, 5, 6))) |
5eddd0b3 | 64 | unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...); |
aa968dde YB |
65 | |
66 | int plan_no_plan(void); | |
cd1322b2 | 67 | __attribute__((noreturn)) |
5eddd0b3 | 68 | int plan_skip_all(const char *); |
aa968dde YB |
69 | int plan_tests(unsigned int); |
70 | ||
694fc888 | 71 | __attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) |
5eddd0b3 | 72 | unsigned int diag(const char *, ...); |
01c5442b | 73 | void diag_multiline(const char *); |
aa968dde | 74 | |
694fc888 | 75 | __attribute__((format(TAP_PRINTF_FORMAT, 2, 3))) |
5eddd0b3 | 76 | int skip(unsigned int, const char *, ...); |
aa968dde | 77 | |
694fc888 | 78 | __attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) |
5eddd0b3 | 79 | void todo_start(const char *, ...); |
aa968dde YB |
80 | void todo_end(void); |
81 | ||
82 | int exit_status(void); |