t_config.sh revision 1.3 1 1.2 uebayasi # $NetBSD: t_config.sh,v 1.3 2014/10/31 04:54:17 uebayasi Exp $
2 1.1 jruoho #
3 1.1 jruoho # Copyright (c) 2008, 2010 The NetBSD Foundation, Inc.
4 1.1 jruoho # All rights reserved.
5 1.1 jruoho #
6 1.1 jruoho # Redistribution and use in source and binary forms, with or without
7 1.1 jruoho # modification, are permitted provided that the following conditions
8 1.1 jruoho # are met:
9 1.1 jruoho # 1. Redistributions of source code must retain the above copyright
10 1.1 jruoho # notice, this list of conditions and the following disclaimer.
11 1.1 jruoho # 2. Redistributions in binary form must reproduce the above copyright
12 1.1 jruoho # notice, this list of conditions and the following disclaimer in the
13 1.1 jruoho # documentation and/or other materials provided with the distribution.
14 1.1 jruoho #
15 1.1 jruoho # THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16 1.1 jruoho # ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17 1.1 jruoho # TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18 1.1 jruoho # PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19 1.1 jruoho # BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 1.1 jruoho # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 1.1 jruoho # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 1.1 jruoho # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 1.1 jruoho # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 1.1 jruoho # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 1.1 jruoho # POSSIBILITY OF SUCH DAMAGE.
26 1.1 jruoho #
27 1.1 jruoho
28 1.2 uebayasi run_and_check_prep()
29 1.1 jruoho {
30 1.1 jruoho local name="${1}"; shift
31 1.1 jruoho
32 1.1 jruoho mkdir compile
33 1.1 jruoho supportdir="$(atf_get_srcdir)/support"
34 1.3 uebayasi
35 1.3 uebayasi local config_str
36 1.3 uebayasi eval config_str=\$${name}_config_str
37 1.3 uebayasi if [ -n "$config_str" ]; then
38 1.3 uebayasi config="d_${name}"
39 1.3 uebayasi printf "$config_str" >"${config}"
40 1.3 uebayasi else
41 1.3 uebayasi config="$(atf_get_srcdir)/d_${name}"
42 1.3 uebayasi fi
43 1.2 uebayasi }
44 1.2 uebayasi
45 1.2 uebayasi run_and_check_pass()
46 1.2 uebayasi {
47 1.2 uebayasi local name="${1}"; shift
48 1.2 uebayasi
49 1.2 uebayasi run_and_check_prep "${name}"
50 1.1 jruoho
51 1.1 jruoho atf_check -o ignore \
52 1.1 jruoho config -s "${supportdir}" -b "compile/${name}" "${config}"
53 1.1 jruoho }
54 1.1 jruoho
55 1.1 jruoho run_and_check_fail()
56 1.1 jruoho {
57 1.1 jruoho local name="${1}"; shift
58 1.1 jruoho
59 1.2 uebayasi run_and_check_prep "${name}"
60 1.1 jruoho
61 1.1 jruoho atf_check -o ignore -e ignore -s ne:0 \
62 1.1 jruoho config -s "${supportdir}" -b "compile/${name}" "${config}"
63 1.1 jruoho }
64 1.1 jruoho
65 1.1 jruoho # Defines a test case for config(1).
66 1.1 jruoho test_case()
67 1.1 jruoho {
68 1.1 jruoho local name="${1}"; shift
69 1.1 jruoho local type="${1}"; shift
70 1.1 jruoho local descr="${*}"
71 1.1 jruoho
72 1.1 jruoho atf_test_case "${name}"
73 1.1 jruoho eval "${name}_head() { \
74 1.1 jruoho atf_set descr \"${descr}\"; \
75 1.1 jruoho atf_set require.progs \"config\"; \
76 1.1 jruoho }"
77 1.1 jruoho eval "${name}_body() { \
78 1.1 jruoho run_and_check_${type} '${name}'; \
79 1.1 jruoho }"
80 1.1 jruoho }
81 1.1 jruoho
82 1.1 jruoho test_case shadow_instance pass "Checks correct handling of shadowed instances"
83 1.1 jruoho test_case loop pass "Checks correct handling of loops"
84 1.1 jruoho test_case loop2 pass "Checks correct handling of devices that can be their" \
85 1.1 jruoho "own parents"
86 1.1 jruoho test_case pseudo_parent pass "Checks correct handling of children of pseudo" \
87 1.1 jruoho "devices (PR/32329)"
88 1.1 jruoho test_case postponed_orphan fail "Checks that config catches adding an" \
89 1.1 jruoho "instance of a child of a negated instance as error"
90 1.1 jruoho test_case no_pseudo fail "Checks that config catches ommited 'pseudo-device'" \
91 1.1 jruoho "as error (PR/34111)"
92 1.1 jruoho test_case deffs_redef fail "Checks that config doesn't allow a deffs to use" \
93 1.1 jruoho "the same name as a previous defflag/defparam"
94 1.1 jruoho
95 1.3 uebayasi # Selecting an undefined option.
96 1.3 uebayasi undefined_opt_config_str='
97 1.3 uebayasi include "../d_min"
98 1.3 uebayasi options UNDEFINED
99 1.3 uebayasi '
100 1.3 uebayasi test_case undefined_opt pass \
101 1.3 uebayasi "Checks that config allows a selection for an undefined options"
102 1.3 uebayasi
103 1.3 uebayasi # Negating an undefined option.
104 1.3 uebayasi no_undefined_opt_config_str='
105 1.3 uebayasi include "../d_min"
106 1.3 uebayasi no options UNDEFINED
107 1.3 uebayasi '
108 1.3 uebayasi test_case no_undefined_opt pass \
109 1.3 uebayasi "Checks that config allows a negation for an undefined options"
110 1.3 uebayasi
111 1.2 uebayasi # Check minimal kernel config(1) output
112 1.2 uebayasi check_min_files()
113 1.2 uebayasi {
114 1.2 uebayasi test -e Makefile &&
115 1.2 uebayasi test -e config_file.h &&
116 1.2 uebayasi test -e config_time.src &&
117 1.2 uebayasi test -e ioconf.c &&
118 1.2 uebayasi test -e ioconf.h &&
119 1.2 uebayasi test -e locators.h &&
120 1.2 uebayasi test -e swapregress.c &&
121 1.2 uebayasi test -h machine &&
122 1.2 uebayasi test -h regress &&
123 1.2 uebayasi :
124 1.2 uebayasi }
125 1.2 uebayasi
126 1.2 uebayasi check_min_makefile()
127 1.2 uebayasi {
128 1.3 uebayasi local f=Makefile
129 1.3 uebayasi
130 1.3 uebayasi grep -q '^%' $f >tmp.template
131 1.2 uebayasi
132 1.3 uebayasi grep -q '^MACHINE=regress$' $f &&
133 1.3 uebayasi grep -q '^PARAM=-DMAXUSERS=4$' $f &&
134 1.3 uebayasi grep -q '^all: regress$' $f &&
135 1.3 uebayasi grep -q '^regress:' $f &&
136 1.2 uebayasi [ ! -s tmp.template ] &&
137 1.2 uebayasi :
138 1.2 uebayasi }
139 1.2 uebayasi
140 1.2 uebayasi test_min()
141 1.2 uebayasi {
142 1.2 uebayasi local res=1
143 1.2 uebayasi
144 1.2 uebayasi run_and_check_prep min
145 1.2 uebayasi
146 1.2 uebayasi config -s "${supportdir}" -b compile/min "${config}" >/dev/null &&
147 1.2 uebayasi cd compile/min &&
148 1.2 uebayasi check_min_files &&
149 1.2 uebayasi check_min_makefile &&
150 1.2 uebayasi cd $OLDPWD &&
151 1.2 uebayasi res=0
152 1.2 uebayasi
153 1.2 uebayasi atf_check test $res -eq 0
154 1.2 uebayasi }
155 1.2 uebayasi
156 1.2 uebayasi test_case min pass "Minimal config"
157 1.2 uebayasi min_body() {
158 1.2 uebayasi test_min
159 1.2 uebayasi }
160 1.2 uebayasi
161 1.1 jruoho atf_init_test_cases()
162 1.1 jruoho {
163 1.1 jruoho atf_add_test_case shadow_instance
164 1.1 jruoho atf_add_test_case loop
165 1.1 jruoho atf_add_test_case loop2
166 1.1 jruoho atf_add_test_case pseudo_parent
167 1.1 jruoho atf_add_test_case postponed_orphan
168 1.1 jruoho atf_add_test_case no_pseudo
169 1.1 jruoho atf_add_test_case deffs_redef
170 1.3 uebayasi atf_add_test_case undefined_opt
171 1.3 uebayasi atf_add_test_case no_undefined_opt
172 1.2 uebayasi atf_add_test_case min
173 1.1 jruoho }
174