diff options
Diffstat (limited to 'tap/tap.h')
| -rw-r--r-- | tap/tap.h | 43 |
1 files changed, 24 insertions, 19 deletions
| @@ -28,45 +28,50 @@ | |||
| 28 | and requires the caller to add the final comma if they've omitted | 28 | and requires the caller to add the final comma if they've omitted |
| 29 | the optional arguments */ | 29 | the optional arguments */ |
| 30 | #ifdef __GNUC__ | 30 | #ifdef __GNUC__ |
| 31 | # define ok(e, test, ...) \ | 31 | # define ok(e, test, ...) \ |
| 32 | ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__) \ | 32 | ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__) \ |
| 33 | : _gen_result(0, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__)) | 33 | : _gen_result(0, __func__, __FILE__, __LINE__, test, ##__VA_ARGS__)) |
| 34 | 34 | ||
| 35 | # define ok1(e) ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) | 35 | # define ok1(e) \ |
| 36 | ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) \ | ||
| 37 | : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) | ||
| 36 | 38 | ||
| 37 | # define pass(test, ...) ok(1, test, ##__VA_ARGS__); | 39 | # define pass(test, ...) ok(1, test, ##__VA_ARGS__); |
| 38 | # define fail(test, ...) ok(0, test, ##__VA_ARGS__); | 40 | # define fail(test, ...) ok(0, test, ##__VA_ARGS__); |
| 39 | 41 | ||
| 40 | # define skip_start(test, n, fmt, ...) \ | 42 | # define skip_start(test, n, fmt, ...) \ |
| 41 | do { \ | 43 | do { \ |
| 42 | if ((test)) { \ | 44 | if ((test)) { \ |
| 43 | skip(n, fmt, ##__VA_ARGS__); \ | 45 | skip(n, fmt, ##__VA_ARGS__); \ |
| 44 | continue; \ | 46 | continue; \ |
| 45 | } | 47 | } |
| 46 | #else /* __GNUC__ */ | 48 | #else /* __GNUC__ */ |
| 47 | /* The original tap.h used to test if __STDC_VERSION__ >= 199901L here. This | 49 | /* The original tap.h used to test if __STDC_VERSION__ >= 199901L here. This |
| 48 | * doesn't seem to work on HP-UX even though the code compile fine. I'm not | 50 | * doesn't seem to work on HP-UX even though the code compile fine. I'm not |
| 49 | * sure how to add an exception here for HP-UX so I just removed the check | 51 | * sure how to add an exception here for HP-UX so I just removed the check |
| 50 | * for now */ | 52 | * for now */ |
| 51 | # define ok(e, ...) \ | 53 | # define ok(e, ...) \ |
| 52 | ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, __VA_ARGS__) : _gen_result(0, __func__, __FILE__, __LINE__, __VA_ARGS__)) | 54 | ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, __VA_ARGS__) \ |
| 55 | : _gen_result(0, __func__, __FILE__, __LINE__, __VA_ARGS__)) | ||
| 53 | 56 | ||
| 54 | # define ok1(e) ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) | 57 | # define ok1(e) \ |
| 58 | ((e) ? _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) \ | ||
| 59 | : _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e)) | ||
| 55 | 60 | ||
| 56 | # define pass(...) ok(1, __VA_ARGS__); | 61 | # define pass(...) ok(1, __VA_ARGS__); |
| 57 | # define fail(...) ok(0, __VA_ARGS__); | 62 | # define fail(...) ok(0, __VA_ARGS__); |
| 58 | 63 | ||
| 59 | # define skip_start(test, n, ...) \ | 64 | # define skip_start(test, n, ...) \ |
| 60 | do { \ | 65 | do { \ |
| 61 | if ((test)) { \ | 66 | if ((test)) { \ |
| 62 | skip(n, __VA_ARGS__); \ | 67 | skip(n, __VA_ARGS__); \ |
| 63 | continue; \ | 68 | continue; \ |
| 64 | } | 69 | } |
| 65 | #endif /* __GNUC__ */ | 70 | #endif /* __GNUC__ */ |
| 66 | 71 | ||
| 67 | #define skip_end \ | 72 | #define skip_end \ |
| 68 | } \ | 73 | } \ |
| 69 | while (0) \ | 74 | while (0) \ |
| 70 | ; | 75 | ; |
| 71 | 76 | ||
| 72 | unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); | 77 | unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...); |
