Remove building with NOCRYPTO option
[minix3.git] / external / bsd / atf / dist / tools / atf-config_test.sh
blob5d6505a4176ec3436e3dbde88e03cffd8274eac2
2 # Automated Testing Framework (atf)
4 # Copyright (c) 2007 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 all_vars="atf_arch \
31 atf_build_cc \
32 atf_build_cflags \
33 atf_build_cpp \
34 atf_build_cppflags \
35 atf_build_cxx \
36 atf_build_cxxflags \
37 atf_confdir \
38 atf_includedir \
39 atf_libdir \
40 atf_libexecdir \
41 atf_machine \
42 atf_pkgdatadir \
43 atf_shell \
44 atf_workdir"
45 all_vars_no=15
47 atf_test_case list_all
48 list_all_head()
50 atf_set "descr" "Tests that at atf-config prints all expected" \
51 "variables, and not more"
53 list_all_body()
55 atf_check -s eq:0 -o save:stdout -e empty atf-config
56 atf_check -s eq:0 -o empty -e empty \
57 test "$(wc -l stdout | awk '{ print $1 }')" = "${all_vars_no}"
58 for v in ${all_vars}; do
59 atf_check -s eq:0 -o ignore -e empty grep "${v}" stdout
60 done
63 atf_test_case query_one
64 query_one_head()
66 atf_set "descr" "Tests that querying a single variable works"
68 query_one_body()
70 for v in ${all_vars}; do
71 atf_check -s eq:0 -o save:stdout -o match:"${v}" -e empty \
72 atf-config "${v}"
73 atf_check -s eq:0 -o empty -e empty \
74 test "$(wc -l stdout | awk '{ print $1 }')" = 1
75 done
78 atf_test_case query_one_terse
79 query_one_terse_head()
81 atf_set "descr" "Tests that querying a single variable in terse mode" \
82 "works"
84 query_one_terse_body()
86 for v in ${all_vars}; do
87 atf_check -s eq:0 -o save:stdout -o match:"${v}" -e empty \
88 atf-config "${v}"
89 atf_check -s eq:0 -o empty -e empty \
90 test "$(wc -l stdout | awk '{ print $1 }')" = 1
91 atf_check -s eq:0 -o save:stdout -e empty cut -d ' ' -f 3- stdout
92 atf_check -s eq:0 -o empty -e empty mv stdout expout
93 atf_check -s eq:0 -o file:expout -e empty atf-config -t "${v}"
94 done
97 atf_test_case query_multiple
98 query_multiple_head()
100 atf_set "descr" "Tests that querying multiple variables works"
102 query_multiple_body()
104 atf_check -s eq:0 -o save:stdout -o match:'atf_libexecdir' \
105 -o match:'atf_shell' -e empty atf-config atf_libexecdir atf_shell
106 atf_check -s eq:0 -o empty -e empty \
107 test "$(wc -l stdout | awk '{ print $1 }')" = 2
110 atf_test_case query_unknown
111 query_unknown_head()
113 atf_set "descr" "Tests that querying an unknown variable delivers" \
114 "the correct error"
116 query_unknown_body()
118 atf_check -s eq:1 -o empty -e match:'Unknown variable.*non_existent' \
119 atf-config non_existent
122 atf_test_case query_mixture
123 query_mixture_head()
125 atf_set "descr" "Tests that querying a known and an unknown variable" \
126 "delivers the correct error"
128 query_mixture_body()
130 for v in ${all_vars}; do
131 atf_check -s eq:1 -o empty -e match:'Unknown variable.*non_existent' \
132 atf-config "${v}" non_existent
133 atf_check -s eq:1 -o empty -e match:'Unknown variable.*non_existent' \
134 atf-config non_existent "${v}"
135 done
138 atf_test_case override_env
139 override_env_head()
141 atf_set "descr" "Tests that build-time variables can be overriden" \
142 "through their corresponding environment variables"
144 override_env_body()
146 for v in ${all_vars}; do
147 V=$(echo ${v} | tr '[a-z]' '[A-Z]')
148 atf_check -s eq:0 -o save:stdout -e empty -x "${V}=testval atf-config"
149 atf_check -s eq:0 -o empty -e empty mv stdout all
151 atf_check -s eq:0 -o save:stdout -e empty grep "^${v} : " all
152 atf_check -s eq:0 -o empty -e empty mv stdout affected
153 atf_check -s eq:0 -o save:stdout -e empty grep -v "^${v} : " all
154 atf_check -s eq:0 -o empty -e empty mv stdout unaffected
156 atf_check -s eq:0 -o empty -e empty \
157 test "$(wc -l affected | awk '{ print $1 }')" = 1
158 atf_check -s eq:0 -o empty -e empty \
159 test "$(wc -l unaffected | awk '{ print $1 }')" = \
160 "$((${all_vars_no} -1))"
162 atf_check -s eq:0 -o ignore -e empty grep "^${v} : testval$" affected
163 atf_check -s eq:1 -o empty -e empty grep ' : testval$' unaffected
164 done
167 atf_init_test_cases()
169 atf_add_test_case list_all
171 atf_add_test_case query_one
172 atf_add_test_case query_one_terse
173 atf_add_test_case query_multiple
174 atf_add_test_case query_unknown
175 atf_add_test_case query_mixture
177 atf_add_test_case override_env
180 # vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4