Remove building with NOCRYPTO option
[minix.git] / tests / usr.bin / config / t_config.sh
blob8a8079c6a81460f07d5e5e03a9ccb0ecf6061418
1 # $NetBSD: t_config.sh,v 1.7 2015/10/04 07:59:47 uebayasi Exp $
3 # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
4 # All rights reserved.
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 # notice, this list of conditions and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
15 # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 # POSSIBILITY OF SUCH DAMAGE.
28 run_and_check_prep()
30 local name="${1}"; shift
32 mkdir compile
33 supportdir="$(atf_get_srcdir)/support"
35 local config_str
36 eval config_str=\$${name}_config_str
37 if [ -n "$config_str" ]; then
38 config="d_${name}"
39 printf "$config_str" >"${config}"
40 else
41 config="$(atf_get_srcdir)/d_${name}"
45 run_and_check_pass()
47 local name="${1}"; shift
49 run_and_check_prep "${name}"
51 atf_check -o ignore -s eq:0 \
52 config -s "${supportdir}" -b "compile/${name}" "${config}"
55 run_and_check_warn()
57 local name="${1}"; shift
59 run_and_check_prep "${name}"
61 local stderr
62 eval stderr=\$${name}_stderr
63 atf_check -o ignore -e "${stderr}" -s eq:0 \
64 config -s "${supportdir}" -b "compile/${name}" "${config}"
67 run_and_check_fail()
69 local name="${1}"; shift
71 run_and_check_prep "${name}"
73 atf_check -o ignore -e ignore -s ne:0 \
74 config -s "${supportdir}" -b "compile/${name}" "${config}"
77 test_output()
79 local name="${1}"; shift
80 local res=1
82 run_and_check_prep "${name}"
84 config -s "${supportdir}" -b compile/"${name}" "${config}" >/dev/null &&
85 cd compile/"${name}" &&
86 check_${name} &&
87 cd $OLDPWD &&
88 res=0
90 atf_check test $res -eq 0
93 # Defines a test case for config(1).
94 test_case()
96 local name="${1}"; shift
97 local type="${1}"; shift
98 local descr="${*}"
100 atf_test_case "${name}"
101 eval "${name}_head() { \
102 atf_set descr \"${descr}\"; \
103 atf_set require.progs \"config\"; \
105 eval "${name}_body() { \
106 run_and_check_${type} '${name}'; \
110 test_case shadow_instance pass "Checks correct handling of shadowed instances"
111 test_case loop pass "Checks correct handling of loops"
112 test_case loop2 pass "Checks correct handling of devices that can be their" \
113 "own parents"
114 test_case pseudo_parent pass "Checks correct handling of children of pseudo" \
115 "devices (PR/32329)"
116 test_case postponed_orphan fail "Checks that config catches adding an" \
117 "instance of a child of a negated instance as error"
118 test_case no_pseudo fail "Checks that config catches ommited 'pseudo-device'" \
119 "as error (PR/34111)"
120 test_case deffs_redef fail "Checks that config doesn't allow a deffs to use" \
121 "the same name as a previous defflag/defparam"
123 # Selecting an undefined option.
124 undefined_opt_config_str='
125 include "../d_min"
126 options UNDEFINED
128 test_case undefined_opt pass \
129 "Checks that config allows a selection for an undefined options"
131 # Negating an undefined option.
132 no_undefined_opt_config_str='
133 include "../d_min"
134 no options UNDEFINED
136 no_undefined_opt_stderr='match:UNDEFINED'
137 test_case no_undefined_opt warn \
138 "Checks that config allows a negation for an undefined options"
140 # Attribute selection
141 test_case select pass "Attribute selection"
142 select_config_str='
143 include "../d_min"
144 select c
146 check_select()
148 local f=Makefile
150 grep -q '^ a\.c ' $f &&
151 grep -q '^ b\.c ' $f &&
152 grep -q '^ c\.c ' $f &&
155 select_body() {
156 test_output select
159 # Attribute negation
160 test_case no_select pass "Attribute negation"
161 no_select_config_str='
162 include "../d_min"
163 select c
164 no select a
166 check_no_select()
168 local f=Makefile
170 : >tmp
171 grep -q '^a\.o:' $f >>tmp
172 grep -q '^b\.o:' $f >>tmp
173 grep -q '^c\.o:' $f >>tmp
175 [ ! -s tmp ] &&
178 no_select_body() {
179 test_output no_select
182 # Device instance
183 test_case devi pass "Device instance"
184 devi_config_str='
185 include "../d_min"
186 d0 at root
188 check_devi()
190 local f=ioconf.c
192 sed -ne '/^struct cfdriver \* const cfdriver_list_initial\[\]/,/^};/p' $f >tmp.cfdriver
193 sed -ne '/^struct cfdata cfdata\[\]/,/^};/p' $f >tmp.cfdata
195 grep -q '^CFDRIVER_DECL(d, ' $f &&
196 grep -q '&d_cd,' tmp.cfdriver &&
197 grep -q '^extern struct cfattach d_ca;$' $f &&
198 grep -q '^static const struct cfiattrdata \* const d_attrs\[\]' $f &&
199 grep -q '^static const struct cfiattrdata icf_iattrdata' $f &&
200 grep -q '{ "d",' tmp.cfdata &&
203 devi_body() {
204 test_output devi
207 # Check minimal kernel config(1) output
208 test_case min pass "Minimal config"
209 check_min_files()
211 test -e Makefile &&
212 test -e config_file.h &&
213 test -e config_time.src &&
214 test -e ioconf.c &&
215 test -e ioconf.h &&
216 test -e locators.h &&
217 test -e swapregress.c &&
218 test -h machine &&
219 test -h regress &&
222 check_min_makefile()
224 local f=Makefile
226 grep -q '^%' $f >tmp.template
228 grep -q '^MACHINE=regress$' $f &&
229 grep -q '^PARAM=-DMAXUSERS=4$' $f &&
230 grep -q '^all: regress$' $f &&
231 grep -q '^regress:' $f &&
232 [ ! -s tmp.template ] &&
235 check_min()
237 check_min_files &&
238 check_min_makefile &&
241 min_body() {
242 test_output min
245 atf_init_test_cases()
247 atf_add_test_case shadow_instance
248 atf_add_test_case loop
249 atf_add_test_case loop2
250 atf_add_test_case pseudo_parent
251 atf_add_test_case postponed_orphan
252 atf_add_test_case no_pseudo
253 atf_add_test_case deffs_redef
254 atf_add_test_case undefined_opt
255 atf_add_test_case no_undefined_opt
256 atf_add_test_case select
257 atf_add_test_case no_select
258 atf_add_test_case devi
259 atf_add_test_case min