Back to index

nagios-plugins  1.4.16
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 #else /* __GNUC__ */
00051 /* The original tap.h used to test if __STDC_VERSION__ >= 199901L here. This
00052  * doesn't seem to work on HP-UX even though the code compile fine. I'm not
00053  * sure how to add an exception here for HP-UX so I just removed the check
00054  * for now */
00055 # define ok(e, ...) ((e) ?                                     \
00056                    _gen_result(1, __func__, __FILE__, __LINE__,       \
00057                              __VA_ARGS__) :                           \
00058                    _gen_result(0, __func__, __FILE__, __LINE__,       \
00059                              __VA_ARGS__))
00060 
00061 # define ok1(e) ((e) ?                                                \
00062                _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
00063                _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
00064 
00065 # define pass(...) ok(1, __VA_ARGS__);
00066 # define fail(...) ok(0, __VA_ARGS__);
00067 
00068 # define skip_start(test, n, ...)                \
00069        do {                                      \
00070               if((test)) {                       \
00071                      skip(n,  __VA_ARGS__);             \
00072                      continue;                   \
00073               }
00074 #endif /* __GNUC__ */
00075 
00076 # define skip_end } while(0);
00077 
00078 unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...);
00079 
00080 int plan_no_plan(void);
00081 int plan_skip_all(char *);
00082 int plan_tests(unsigned int);
00083 
00084 unsigned int diag(char *, ...);
00085 
00086 int skip(unsigned int, char *, ...);
00087 
00088 void todo_start(char *, ...);
00089 void todo_end(void);
00090 
00091 int exit_status(void);