16bc1e9cdSJohn Baldwin /*- 26bc1e9cdSJohn Baldwin * Copyright (c) 2008 Yahoo!, Inc. 36bc1e9cdSJohn Baldwin * All rights reserved. 46bc1e9cdSJohn Baldwin * Written by: John Baldwin <jhb@FreeBSD.org> 56bc1e9cdSJohn Baldwin * 66bc1e9cdSJohn Baldwin * Redistribution and use in source and binary forms, with or without 76bc1e9cdSJohn Baldwin * modification, are permitted provided that the following conditions 86bc1e9cdSJohn Baldwin * are met: 96bc1e9cdSJohn Baldwin * 1. Redistributions of source code must retain the above copyright 106bc1e9cdSJohn Baldwin * notice, this list of conditions and the following disclaimer. 116bc1e9cdSJohn Baldwin * 2. Redistributions in binary form must reproduce the above copyright 126bc1e9cdSJohn Baldwin * notice, this list of conditions and the following disclaimer in the 136bc1e9cdSJohn Baldwin * documentation and/or other materials provided with the distribution. 146bc1e9cdSJohn Baldwin * 3. Neither the name of the author nor the names of any co-contributors 156bc1e9cdSJohn Baldwin * may be used to endorse or promote products derived from this software 166bc1e9cdSJohn Baldwin * without specific prior written permission. 176bc1e9cdSJohn Baldwin * 186bc1e9cdSJohn Baldwin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 196bc1e9cdSJohn Baldwin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 206bc1e9cdSJohn Baldwin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 216bc1e9cdSJohn Baldwin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 226bc1e9cdSJohn Baldwin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 236bc1e9cdSJohn Baldwin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 246bc1e9cdSJohn Baldwin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 256bc1e9cdSJohn Baldwin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 266bc1e9cdSJohn Baldwin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 276bc1e9cdSJohn Baldwin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 286bc1e9cdSJohn Baldwin * SUCH DAMAGE. 296bc1e9cdSJohn Baldwin * 306bc1e9cdSJohn Baldwin * $FreeBSD$ 316bc1e9cdSJohn Baldwin */ 326bc1e9cdSJohn Baldwin 336bc1e9cdSJohn Baldwin #ifndef __TEST_H__ 346bc1e9cdSJohn Baldwin #define __TEST_H__ 356bc1e9cdSJohn Baldwin 366bc1e9cdSJohn Baldwin #include <sys/linker_set.h> 376bc1e9cdSJohn Baldwin 386bc1e9cdSJohn Baldwin struct regression_test { 396bc1e9cdSJohn Baldwin void (*rt_function)(void); 406bc1e9cdSJohn Baldwin const char *rt_name; 416bc1e9cdSJohn Baldwin }; 426bc1e9cdSJohn Baldwin 436bc1e9cdSJohn Baldwin #define TEST(function, name) \ 446bc1e9cdSJohn Baldwin static struct regression_test _regtest_##function = { \ 456bc1e9cdSJohn Baldwin (function), \ 466bc1e9cdSJohn Baldwin (name) \ 476bc1e9cdSJohn Baldwin }; \ 486bc1e9cdSJohn Baldwin DATA_SET(regression_tests_set, _regtest_##function) 496bc1e9cdSJohn Baldwin 506bc1e9cdSJohn Baldwin void fail(void); 516bc1e9cdSJohn Baldwin void fail_err(const char *fmt, ...); 526bc1e9cdSJohn Baldwin void pass(void); 536bc1e9cdSJohn Baldwin void run_tests(void); 546bc1e9cdSJohn Baldwin void skip(const char *reason); 556bc1e9cdSJohn Baldwin void todo(const char *reason); 566bc1e9cdSJohn Baldwin 576bc1e9cdSJohn Baldwin #define fail_errno(tag) fail_err("%s: %s", (tag), strerror(errno)) 586bc1e9cdSJohn Baldwin 596bc1e9cdSJohn Baldwin #endif /* !__TEST_H__ */ 60