2 * Copyright (c) 2004 Nik Clayton
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 #if (!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L) && !defined(__GNUC__)
28 # error "Needs gcc or C99 compiler for variadic macros."
31 # define ok(e, ...) ((e) ? \
32 _gen_result(1, __func__, __FILE__, __LINE__, \
34 _gen_result(0, __func__, __FILE__, __LINE__, \
37 # define ok1(e) ((e) ? \
38 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
39 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
41 # define pass(...) ok(1, __VA_ARGS__)
42 # define fail(...) ok(0, __VA_ARGS__)
44 # define skip_if(cond, n, ...) \
45 if (cond) skip((n), __VA_ARGS__); \
48 # define skip_start(test, n, ...) \
51 skip(n, __VA_ARGS__); \
55 # define skip_end } while(0)
57 #ifndef PRINTF_ATTRIBUTE
59 #define PRINTF_ATTRIBUTE(a1, a2) __attribute__ ((format (__printf__, a1, a2)))
61 #define PRINTF_ATTRIBUTE(a1, a2)
65 unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...)
66 PRINTF_ATTRIBUTE(5, 6);
68 void plan_no_plan(void);
69 void plan_skip_all(char *);
70 void plan_tests(unsigned int);
72 void diag(char *, ...) PRINTF_ATTRIBUTE(1, 2);
74 void skip(unsigned int, char *, ...) PRINTF_ATTRIBUTE(2, 3);
76 void todo_start(char *, ...) PRINTF_ATTRIBUTE(1, 2);
79 int exit_status(void);
80 #endif /* C99 or gcc */