tap/src/tap.h

Go to the documentation of this file.
00001 /*-
00002  * Copyright (c) 2004 Nik Clayton
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *    notice, this list of conditions and the following disclaimer in the
00012  *    documentation and/or other materials provided with the distribution.
00013  *
00014  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00015  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00016  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00017  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00018  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00019  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00020  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00021  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00022  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00023  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00024  * SUCH DAMAGE.
00025  */
00026 
00027 /* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
00028    and requires the caller to add the final comma if they've ommitted
00029    the optional arguments */
00030 #ifdef __GNUC__
00031 # define ok(e, test, ...) ((e) ?                                        \
00032                            _gen_result(1, __func__, __FILE__, __LINE__, \
00033                                        test, ## __VA_ARGS__) :          \
00034                            _gen_result(0, __func__, __FILE__, __LINE__, \
00035                                        test, ## __VA_ARGS__))
00036 
00037 # define ok1(e) ((e) ?                                                  \
00038                  _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
00039                  _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
00040 
00041 # define pass(test, ...) ok(1, test, ## __VA_ARGS__);
00042 # define fail(test, ...) ok(0, test, ## __VA_ARGS__);
00043 
00044 # define skip_start(test, n, fmt, ...)                  \
00045         do {                                            \
00046                 if((test)) {                            \
00047                         skip(n, fmt, ## __VA_ARGS__);   \
00048                         continue;                       \
00049                 }
00050 #elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
00051 # define ok(e, ...) ((e) ?                                              \
00052                      _gen_result(1, __func__, __FILE__, __LINE__,       \
00053                                  __VA_ARGS__) :                         \
00054                      _gen_result(0, __func__, __FILE__, __LINE__,       \
00055                                  __VA_ARGS__))
00056 
00057 # define ok1(e) ((e) ?                                                  \
00058                  _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
00059                  _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
00060 
00061 # define pass(...) ok(1, __VA_ARGS__);
00062 # define fail(...) ok(0, __VA_ARGS__);
00063 
00064 # define skip_start(test, n, ...)                       \
00065         do {                                            \
00066                 if((test)) {                            \
00067                         skip(n,  __VA_ARGS__);          \
00068                         continue;                       \
00069                 }
00070 #else /* __STDC_VERSION__ */
00071 # error "Needs gcc or C99 compiler for variadic macros."
00072 #endif /* __STDC_VERSION__ */
00073 
00074 # define skip_end } while(0);
00075 
00076 unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...);
00077 
00078 int plan_no_plan(void);
00079 int plan_skip_all(char *);
00080 int plan_tests(unsigned int);
00081 
00082 unsigned int diag(char *, ...);
00083 
00084 int skip(unsigned int, char *, ...);
00085 
00086 void todo_start(char *, ...);
00087 void todo_end(void);
00088 
00089 int exit_status(void);

Generated on Wed Mar 30 17:22:22 2011 for icinga-core by  doxygen 1.4.7