Remove building with NOCRYPTO option
[minix3.git] / external / bsd / atf / dist / atf-c / macros_h_test.c
blob3dae471e4dd722e84dbf4d693bc615e5420e9364
1 /*
2 * Automated Testing Framework (atf)
4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <atf-c/macros.h>
32 void atf_require_inside_if(void);
33 void atf_require_equal_inside_if(void);
34 void atf_check_errno_semicolons(void);
35 void atf_require_errno_semicolons(void);
37 void
38 atf_require_inside_if(void)
40 /* Make sure that ATF_REQUIRE can be used inside an if statement that
41 * does not have braces. Earlier versions of it generated an error
42 * if there was an else clause because they confused the compiler
43 * by defining an unprotected nested if. */
44 if (true)
45 ATF_REQUIRE(true);
46 else
47 ATF_REQUIRE(true);
50 void
51 atf_require_equal_inside_if(void)
53 /* Make sure that ATF_REQUIRE_EQUAL can be used inside an if statement
54 * that does not have braces. Earlier versions of it generated an
55 * error if there was an else clause because they confused the
56 * compiler by defining an unprotected nested if. */
57 if (true)
58 ATF_REQUIRE_EQ(true, true);
59 else
60 ATF_REQUIRE_EQ(true, true);
63 void
64 atf_check_errno_semicolons(void)
66 /* Check that ATF_CHECK_ERRNO does not contain a semicolon that would
67 * cause an empty-statement that confuses some compilers. */
68 ATF_CHECK_ERRNO(1, 1 == 1);
69 ATF_CHECK_ERRNO(2, 2 == 2);
72 void
73 atf_require_errno_semicolons(void)
75 /* Check that ATF_REQUIRE_ERRNO does not contain a semicolon that would
76 * cause an empty-statement that confuses some compilers. */
77 ATF_REQUIRE_ERRNO(1, 1 == 1);
78 ATF_REQUIRE_ERRNO(2, 2 == 2);
81 /* Test case names should not be expanded during instatiation so that they
82 * can have the exact same name as macros. */
83 #define TEST_MACRO_1 invalid + name
84 #define TEST_MACRO_2 invalid + name
85 #define TEST_MACRO_3 invalid + name
86 ATF_TC(TEST_MACRO_1);
87 ATF_TC_HEAD(TEST_MACRO_1, tc) { if (tc != NULL) {} }
88 ATF_TC_BODY(TEST_MACRO_1, tc) { if (tc != NULL) {} }
89 atf_tc_t *test_name_1 = &ATF_TC_NAME(TEST_MACRO_1);
90 void (*head_1)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_1);
91 void (*body_1)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_1);
92 ATF_TC_WITH_CLEANUP(TEST_MACRO_2);
93 ATF_TC_HEAD(TEST_MACRO_2, tc) { if (tc != NULL) {} }
94 ATF_TC_BODY(TEST_MACRO_2, tc) { if (tc != NULL) {} }
95 ATF_TC_CLEANUP(TEST_MACRO_2, tc) { if (tc != NULL) {} }
96 atf_tc_t *test_name_2 = &ATF_TC_NAME(TEST_MACRO_2);
97 void (*head_2)(atf_tc_t *) = ATF_TC_HEAD_NAME(TEST_MACRO_2);
98 void (*body_2)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_2);
99 void (*cleanup_2)(const atf_tc_t *) = ATF_TC_CLEANUP_NAME(TEST_MACRO_2);
100 ATF_TC_WITHOUT_HEAD(TEST_MACRO_3);
101 ATF_TC_BODY(TEST_MACRO_3, tc) { if (tc != NULL) {} }
102 atf_tc_t *test_name_3 = &ATF_TC_NAME(TEST_MACRO_3);
103 void (*body_3)(const atf_tc_t *) = ATF_TC_BODY_NAME(TEST_MACRO_3);