Remove building with NOCRYPTO option
[minix3.git] / external / bsd / atf / dist / tools / expect_helpers.c
blobb38ccf574bc8be577e8a4389899243b8178dcc69
1 /*
2 * Automated Testing Framework (atf)
4 * Copyright (c) 2010 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 <signal.h>
31 #include <stdlib.h>
32 #include <unistd.h>
34 #include <atf-c.h>
36 ATF_TC_WITHOUT_HEAD(pass_and_pass);
37 ATF_TC_BODY(pass_and_pass, tc)
39 atf_tc_expect_pass();
42 ATF_TC_WITHOUT_HEAD(pass_but_fail_requirement);
43 ATF_TC_BODY(pass_but_fail_requirement, tc)
45 atf_tc_expect_pass();
46 atf_tc_fail("Some reason");
49 ATF_TC_WITHOUT_HEAD(pass_but_fail_check);
50 ATF_TC_BODY(pass_but_fail_check, tc)
52 atf_tc_expect_pass();
53 atf_tc_fail_nonfatal("Some reason");
56 ATF_TC_WITHOUT_HEAD(fail_and_fail_requirement);
57 ATF_TC_BODY(fail_and_fail_requirement, tc)
59 atf_tc_expect_fail("Fail %s", "reason");
60 atf_tc_fail("The failure");
61 atf_tc_expect_pass();
64 ATF_TC_WITHOUT_HEAD(fail_and_fail_check);
65 ATF_TC_BODY(fail_and_fail_check, tc)
67 atf_tc_expect_fail("Fail first");
68 atf_tc_fail_nonfatal("abc");
69 atf_tc_expect_pass();
71 atf_tc_expect_fail("And fail again");
72 atf_tc_fail_nonfatal("def");
73 atf_tc_expect_pass();
76 ATF_TC_WITHOUT_HEAD(fail_but_pass);
77 ATF_TC_BODY(fail_but_pass, tc)
79 atf_tc_expect_fail("Fail first");
80 atf_tc_fail_nonfatal("abc");
81 atf_tc_expect_pass();
83 atf_tc_expect_fail("Will not fail");
84 atf_tc_expect_pass();
86 atf_tc_expect_fail("And fail again");
87 atf_tc_fail_nonfatal("def");
88 atf_tc_expect_pass();
91 ATF_TC_WITHOUT_HEAD(exit_any_and_exit);
92 ATF_TC_BODY(exit_any_and_exit, tc)
94 atf_tc_expect_exit(-1, "Call will exit");
95 exit(EXIT_SUCCESS);
98 ATF_TC_WITHOUT_HEAD(exit_code_and_exit);
99 ATF_TC_BODY(exit_code_and_exit, tc)
101 atf_tc_expect_exit(123, "Call will exit");
102 exit(123);
105 ATF_TC_WITHOUT_HEAD(exit_but_pass);
106 ATF_TC_BODY(exit_but_pass, tc)
108 atf_tc_expect_exit(-1, "Call won't exit");
111 ATF_TC_WITHOUT_HEAD(signal_any_and_signal);
112 ATF_TC_BODY(signal_any_and_signal, tc)
114 atf_tc_expect_signal(-1, "Call will signal");
115 kill(getpid(), SIGKILL);
118 ATF_TC_WITHOUT_HEAD(signal_no_and_signal);
119 ATF_TC_BODY(signal_no_and_signal, tc)
121 atf_tc_expect_signal(SIGHUP, "Call will signal");
122 kill(getpid(), SIGHUP);
125 ATF_TC_WITHOUT_HEAD(signal_but_pass);
126 ATF_TC_BODY(signal_but_pass, tc)
128 atf_tc_expect_signal(-1, "Call won't signal");
131 ATF_TC_WITHOUT_HEAD(death_and_exit);
132 ATF_TC_BODY(death_and_exit, tc)
134 atf_tc_expect_death("Exit case");
135 exit(123);
138 ATF_TC_WITHOUT_HEAD(death_and_signal);
139 ATF_TC_BODY(death_and_signal, tc)
141 atf_tc_expect_death("Signal case");
142 kill(getpid(), SIGKILL);
145 ATF_TC_WITHOUT_HEAD(death_but_pass);
146 ATF_TC_BODY(death_but_pass, tc)
148 atf_tc_expect_death("Call won't die");
151 ATF_TC(timeout_and_hang);
152 ATF_TC_HEAD(timeout_and_hang, tc)
154 atf_tc_set_md_var(tc, "timeout", "1");
156 ATF_TC_BODY(timeout_and_hang, tc)
158 atf_tc_expect_timeout("Will overrun");
159 sleep(5);
162 ATF_TC(timeout_but_pass);
163 ATF_TC_HEAD(timeout_but_pass, tc)
165 atf_tc_set_md_var(tc, "timeout", "1");
167 ATF_TC_BODY(timeout_but_pass, tc)
169 atf_tc_expect_timeout("Will just exit");
172 ATF_TP_ADD_TCS(tp)
174 ATF_TP_ADD_TC(tp, pass_and_pass);
175 ATF_TP_ADD_TC(tp, pass_but_fail_requirement);
176 ATF_TP_ADD_TC(tp, pass_but_fail_check);
177 ATF_TP_ADD_TC(tp, fail_and_fail_requirement);
178 ATF_TP_ADD_TC(tp, fail_and_fail_check);
179 ATF_TP_ADD_TC(tp, fail_but_pass);
180 ATF_TP_ADD_TC(tp, exit_any_and_exit);
181 ATF_TP_ADD_TC(tp, exit_code_and_exit);
182 ATF_TP_ADD_TC(tp, exit_but_pass);
183 ATF_TP_ADD_TC(tp, signal_any_and_signal);
184 ATF_TP_ADD_TC(tp, signal_no_and_signal);
185 ATF_TP_ADD_TC(tp, signal_but_pass);
186 ATF_TP_ADD_TC(tp, death_and_exit);
187 ATF_TP_ADD_TC(tp, death_and_signal);
188 ATF_TP_ADD_TC(tp, death_but_pass);
189 ATF_TP_ADD_TC(tp, timeout_and_hang);
190 ATF_TP_ADD_TC(tp, timeout_but_pass);
192 return atf_no_error();