Blame tests/utils/tap.h

Packit c04fcb
/*-
Packit c04fcb
 * Copyright (c) 2004 Nik Clayton
Packit c04fcb
 * All rights reserved.
Packit c04fcb
 *
Packit c04fcb
 * Redistribution and use in source and binary forms, with or without
Packit c04fcb
 * modification, are permitted provided that the following conditions
Packit c04fcb
 * are met:
Packit c04fcb
 * 1. Redistributions of source code must retain the above copyright
Packit c04fcb
 *    notice, this list of conditions and the following disclaimer.
Packit c04fcb
 * 2. Redistributions in binary form must reproduce the above copyright
Packit c04fcb
 *    notice, this list of conditions and the following disclaimer in the
Packit c04fcb
 *    documentation and/or other materials provided with the distribution.
Packit c04fcb
 *
Packit c04fcb
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
Packit c04fcb
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit c04fcb
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Packit c04fcb
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
Packit c04fcb
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit c04fcb
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
Packit c04fcb
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
Packit c04fcb
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
Packit c04fcb
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
Packit c04fcb
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
Packit c04fcb
 * SUCH DAMAGE.
Packit c04fcb
 */
Packit c04fcb
Packit c04fcb
/* '## __VA_ARGS__' is a gcc'ism. C99 doesn't allow the token pasting
Packit c04fcb
   and requires the caller to add the final comma if they've ommitted
Packit c04fcb
   the optional arguments */
Packit c04fcb
#ifdef __GNUC__
Packit c04fcb
# define ok(e, test, ...) ((e) ?					\
Packit c04fcb
			   _gen_result(1, __func__, __FILE__, __LINE__,	\
Packit c04fcb
				       test, ## __VA_ARGS__) :		\
Packit c04fcb
			   _gen_result(0, __func__, __FILE__, __LINE__,	\
Packit c04fcb
				       test, ## __VA_ARGS__))
Packit c04fcb
Packit c04fcb
# define ok1(e) ((e) ?							\
Packit c04fcb
		 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
Packit c04fcb
		 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
Packit c04fcb
Packit c04fcb
# define pass(test, ...) ok(1, test, ## __VA_ARGS__);
Packit c04fcb
# define fail(test, ...) ok(0, test, ## __VA_ARGS__);
Packit c04fcb
Packit c04fcb
# define skip_start(test, n, fmt, ...)			\
Packit c04fcb
	do {						\
Packit c04fcb
		if((test)) {				\
Packit c04fcb
			skip(n, fmt, ## __VA_ARGS__);	\
Packit c04fcb
			continue;			\
Packit c04fcb
		}
Packit c04fcb
#elif __STDC_VERSION__ >= 199901L /* __GNUC__ */
Packit c04fcb
# define ok(e, ...) ((e) ?						\
Packit c04fcb
		     _gen_result(1, __func__, __FILE__, __LINE__,	\
Packit c04fcb
				 __VA_ARGS__) :				\
Packit c04fcb
		     _gen_result(0, __func__, __FILE__, __LINE__,	\
Packit c04fcb
				 __VA_ARGS__))
Packit c04fcb
Packit c04fcb
# define ok1(e) ((e) ?							\
Packit c04fcb
		 _gen_result(1, __func__, __FILE__, __LINE__, "%s", #e) : \
Packit c04fcb
		 _gen_result(0, __func__, __FILE__, __LINE__, "%s", #e))
Packit c04fcb
Packit c04fcb
# define pass(...) ok(1, __VA_ARGS__);
Packit c04fcb
# define fail(...) ok(0, __VA_ARGS__);
Packit c04fcb
Packit c04fcb
# define skip_start(test, n, ...)			\
Packit c04fcb
	do {						\
Packit c04fcb
		if((test)) {				\
Packit c04fcb
			skip(n,  __VA_ARGS__);		\
Packit c04fcb
			continue;			\
Packit c04fcb
		}
Packit c04fcb
#else /* __STDC_VERSION__ */
Packit c04fcb
# error "Needs gcc or C99 compiler for variadic macros."
Packit c04fcb
#endif /* __STDC_VERSION__ */
Packit c04fcb
Packit c04fcb
#define skip_end() } while(0);
Packit c04fcb
Packit c04fcb
unsigned int _gen_result(int, const char *, char *, unsigned int, char *, ...);
Packit c04fcb
Packit c04fcb
int plan_no_plan(void);
Packit c04fcb
int plan_skip_all(char *);
Packit c04fcb
int plan_tests(unsigned int);
Packit c04fcb
Packit c04fcb
unsigned int diag(char *, ...);
Packit c04fcb
Packit c04fcb
int skip(unsigned int, char *, ...);
Packit c04fcb
Packit c04fcb
void todo_start(char *, ...);
Packit c04fcb
void todo_end(void);
Packit c04fcb
Packit c04fcb
int exit_status(void);