macros.h revision a747113422afaa29ce72d2c5ba7f0b7ea9ec2054
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Automated Testing Framework (atf)
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt * Copyright (c) 2008 The NetBSD Foundation, Inc.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * All rights reserved.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * Redistribution and use in source and binary forms, with or without
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * modification, are permitted provided that the following conditions
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * 1. Redistributions of source code must retain the above copyright
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * notice, this list of conditions and the following disclaimer.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * 2. Redistributions in binary form must reproduce the above copyright
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * notice, this list of conditions and the following disclaimer in the
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * documentation and/or other materials provided with the distribution.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static void atfu_ ## tc ## _body(const atf_tc_t *); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static atf_tc_pack_t atfu_ ## tc ## _tc_pack = { \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static void atfu_ ## tc ## _body(const atf_tc_t *); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static atf_tc_pack_t atfu_ ## tc ## _tc_pack = { \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static void atfu_ ## tc ## _body(const atf_tc_t *); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static void atfu_ ## tc ## _cleanup(const atf_tc_t *); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt static atf_tc_pack_t atfu_ ## tc ## _tc_pack = { \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt atfu_ ## tc ## _head(atf_tc_t *tcptr ATF_DEFS_ATTRIBUTE_UNUSED)
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt atfu_ ## tc ## _body(const atf_tc_t *tcptr ATF_DEFS_ATTRIBUTE_UNUSED)
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt atfu_ ## tc ## _cleanup(const atf_tc_t *tcptr ATF_DEFS_ATTRIBUTE_UNUSED)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt int atf_tp_main(int, char **, atf_error_t (*)(atf_tp_t *)); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt return atf_tp_main(argc, argv, atfu_tp_add_tcs); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atfu_err = atf_tc_init_pack(&atfu_ ## tc ## _tc, \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt (const char *const *)atfu_config); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atfu_err = atf_tp_add_tc(tp, &atfu_ ## tc ## _tc); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_fail_requirement(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_fail_check(__FILE__, __LINE__, fmt, ##__VA_ARGS__); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_fail_requirement(__FILE__, __LINE__, "%s", #x " not met"); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_fail_check(__FILE__, __LINE__, "%s", #x " not met"); \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define ATF_REQUIRE_EQ(x, y) \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define ATF_CHECK_EQ(x, y) \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_REQUIRE_MSG((x) == (y), "%s != %s: " fmt, #x, #y, ##__VA_ARGS__)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_MSG((x) == (y), "%s != %s: " fmt, #x, #y, ##__VA_ARGS__)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_REQUIRE_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s)", #x, #y, x, y)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#define ATF_CHECK_STREQ(x, y) \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s)", #x, #y, x, y)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_REQUIRE_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s): " fmt, \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #x, #y, x, y, ##__VA_ARGS__)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt ATF_CHECK_MSG(strcmp(x, y) == 0, "%s != %s (%s != %s): " fmt, \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt #x, #y, x, y, ##__VA_ARGS__)
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK_MSG(atf_utils_grep_string("%s", string, regexp), \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt#define ATF_REQUIRE_MATCH_MSG(regexp, string, fmt, ...) \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_REQUIRE_MSG(atf_utils_grep_string("%s", string, regexp), \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt "'%s' not matched in '%s': " fmt, regexp, string, \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt#define ATF_CHECK_MATCH_MSG(regexp, string, fmt, ...) \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt ATF_CHECK_MSG(atf_utils_grep_string("%s", string, regexp), \
a747113422afaa29ce72d2c5ba7f0b7ea9ec2054Evan Hunt "'%s' not matched in '%s': " fmt, regexp, string, \
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_check_errno(__FILE__, __LINE__, exp_errno, #bool_expr, bool_expr)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt atf_tc_require_errno(__FILE__, __LINE__, exp_errno, #bool_expr, bool_expr)
ef421f66f47224a42073deaf087378c5d0c9952eEvan Hunt#endif /* !defined(ATF_C_MACROS_H) */