/* Copyright (c) 2008 The NetBSD Foundation, Inc.1* All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions and the following disclaimer.8* 2. Redistributions in binary form must reproduce the above copyright9* notice, this list of conditions and the following disclaimer in the10* documentation and/or other materials provided with the distribution.11*12* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND13* CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,14* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF15* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.16* IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY17* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL18* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE19* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS20* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER21* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR22* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN23* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */2425#include <atf-c/macros.h>2627void atf_require_inside_if(void);28void atf_require_equal_inside_if(void);29void atf_check_errno_semicolons(void);30void atf_require_errno_semicolons(void);3132void33atf_require_inside_if(void)34{35/* Make sure that ATF_REQUIRE can be used inside an if statement that36* does not have braces. Earlier versions of it generated an error37* if there was an else clause because they confused the compiler38* by defining an unprotected nested if. */39if (true)40ATF_REQUIRE(true);41else42ATF_REQUIRE(true);43}4445void46atf_require_equal_inside_if(void)47{48/* Make sure that ATF_REQUIRE_EQUAL can be used inside an if statement49* that does not have braces. Earlier versions of it generated an50* error if there was an else clause because they confused the51* compiler by defining an unprotected nested if. */52if (true)53ATF_REQUIRE_EQ(true, true);54else55ATF_REQUIRE_EQ(true, true);56}5758void59atf_check_errno_semicolons(void)60{61/* Check that ATF_CHECK_ERRNO does not contain a semicolon that would62* cause an empty-statement that confuses some compilers. */63ATF_CHECK_ERRNO(1, 1 == 1);64ATF_CHECK_ERRNO(2, 2 == 2);65}6667void68atf_require_errno_semicolons(void)69{70/* Check that ATF_REQUIRE_ERRNO does not contain a semicolon that would71* cause an empty-statement that confuses some compilers. */72ATF_REQUIRE_ERRNO(1, 1 == 1);73ATF_REQUIRE_ERRNO(2, 2 == 2);74}7576/* Test case names should not be expanded during instatiation so that they77* can have the exact same name as macros. */78#define TEST_MACRO_1 invalid + name79#define TEST_MACRO_2 invalid + name80#define TEST_MACRO_3 invalid + name81ATF_TC(TEST_MACRO_1);82ATF_TC_HEAD(TEST_MACRO_1, tc) { if (tc != NULL) {} }83ATF_TC_BODY(TEST_MACRO_1, tc) { if (tc != NULL) {} }84atf_tc_t *test_name_1 = &ATF_TC_NAME(TEST_MACRO_1);85atf_tc_pack_t *test_pack_1 = &ATF_TC_PACK_NAME(TEST_MACRO_1);86void (*head_1)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_1);87void (*body_1)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_1);88ATF_TC_WITH_CLEANUP(TEST_MACRO_2);89ATF_TC_HEAD(TEST_MACRO_2, tc) { if (tc != NULL) {} }90ATF_TC_BODY(TEST_MACRO_2, tc) { if (tc != NULL) {} }91ATF_TC_CLEANUP(TEST_MACRO_2, tc) { if (tc != NULL) {} }92atf_tc_t *test_name_2 = &ATF_TC_NAME(TEST_MACRO_2);93atf_tc_pack_t *test_pack_2 = &ATF_TC_PACK_NAME(TEST_MACRO_2);94void (*head_2)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_2);95void (*body_2)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_2);96void (*cleanup_2)(const atf_tc_t *) = ATF_TC_CLEANUP_NAME(TEST_MACRO_2);97ATF_TC_WITHOUT_HEAD(TEST_MACRO_3);98ATF_TC_BODY(TEST_MACRO_3, tc) { if (tc != NULL) {} }99atf_tc_t *test_name_3 = &ATF_TC_NAME(TEST_MACRO_3);100atf_tc_pack_t *test_pack_3 = &ATF_TC_PACK_NAME(TEST_MACRO_3);101void (*body_3)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_3);102103104