| 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 | # define ok(e, ...) ((e) ? \ |
| 13 | _gen_result(1, __func__, __FILE__, __LINE__, \ |
| 14 | __VA_ARGS__) : \ |
| 15 | _gen_result(0, __func__, __FILE__, __LINE__, \ |
| 16 | __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(...) ok(1, __VA_ARGS__) |
| 23 | # define fail(...) ok(0, __VA_ARGS__) |
| 24 | |
| 25 | # define skip_start(test, n, ...) \ |
| 26 | do { \ |
| 27 | if((test)) { \ |
| 28 | skip(n, __VA_ARGS__); \ |
| 29 | continue; \ |
| 30 | } |
| 31 | |
| 32 | #define skip_end() } while(0); |
| 33 | |
| 34 | #ifdef __MINGW_PRINTF_FORMAT |
| 35 | # define TAP_PRINTF_FORMAT __MINGW_PRINTF_FORMAT |
| 36 | #else |
| 37 | # define TAP_PRINTF_FORMAT printf |
| 38 | #endif |
| 39 | |
| 40 | __attribute__((format(TAP_PRINTF_FORMAT, 5, 6))) |
| 41 | unsigned int _gen_result(int, const char *, const char *, unsigned int, const char *, ...); |
| 42 | |
| 43 | int plan_no_plan(void); |
| 44 | __attribute__((__noreturn__)) |
| 45 | int plan_skip_all(const char *); |
| 46 | int plan_tests(unsigned int); |
| 47 | |
| 48 | __attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) |
| 49 | unsigned int diag(const char *, ...); |
| 50 | void diag_multiline(const char *); |
| 51 | |
| 52 | __attribute__((format(TAP_PRINTF_FORMAT, 2, 3))) |
| 53 | int skip(unsigned int, const char *, ...); |
| 54 | |
| 55 | __attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) |
| 56 | void todo_start(const char *, ...); |
| 57 | void todo_end(void); |
| 58 | |
| 59 | int exit_status(void); |
| 60 | |
| 61 | void tap_disable(void); |
| 62 | |
| 63 | unsigned int rdiag_start(void); |
| 64 | __attribute__((format(TAP_PRINTF_FORMAT, 1, 2))) |
| 65 | unsigned int rdiag(const char *fmt, ...); |
| 66 | unsigned int rdiag_end(void); |
| 67 | |
| 68 | #ifdef __cplusplus |
| 69 | } |
| 70 | #endif |