]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/atf/bootstrap/t_atf_config.at
Merge ATF 0.16 from vendor/atf/dist.
[FreeBSD/FreeBSD.git] / contrib / atf / bootstrap / t_atf_config.at
1 dnl
2 dnl Automated Testing Framework (atf)
3 dnl
4 dnl Copyright (c) 2007 The NetBSD Foundation, Inc.
5 dnl All rights reserved.
6 dnl
7 dnl Redistribution and use in source and binary forms, with or without
8 dnl modification, are permitted provided that the following conditions
9 dnl are met:
10 dnl 1. Redistributions of source code must retain the above copyright
11 dnl    notice, this list of conditions and the following disclaimer.
12 dnl 2. Redistributions in binary form must reproduce the above copyright
13 dnl    notice, this list of conditions and the following disclaimer in the
14 dnl    documentation and/or other materials provided with the distribution.
15 dnl
16 dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
17 dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18 dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19 dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
21 dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
23 dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26 dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27 dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 dnl
29
30 AT_SETUP([atf-config: querying of build-time variables])
31 AT_TESTED(atf-config)
32
33 all_vars="atf_arch \
34           atf_build_cc \
35           atf_build_cflags \
36           atf_build_cpp \
37           atf_build_cppflags \
38           atf_build_cxx \
39           atf_build_cxxflags \
40           atf_confdir \
41           atf_includedir \
42           atf_libdir \
43           atf_libexecdir \
44           atf_machine \
45           atf_pkgdatadir \
46           atf_shell \
47           atf_workdir"
48 all_vars_no=15
49
50 dnl List all variables.
51 AT_CHECK([atf-config], [0], [stdout], [])
52 AT_CHECK([COUNT_LINES(stdout, ${all_vars_no})], [0], [], [])
53 for v in ${all_vars}; do
54     AT_CHECK([grep "${v}" stdout], [0], [ignore], [])
55 done
56
57 dnl Query a single variable and test terse mode.
58 for v in ${all_vars}; do
59     AT_CHECK([atf-config ${v}], [0], [stdout], [])
60     AT_CHECK([COUNT_LINES(stdout, 1)], [0], [], [])
61     AT_CHECK([grep "${v}" stdout], [0], [ignore], [])
62     AT_CHECK([cut -d ' ' -f 3- stdout], [0], [stdout], [])
63     AT_CHECK([mv stdout expout], [0], [], [])
64     AT_CHECK([atf-config -t ${v}], [0], [expout], [])
65 done
66
67 dnl Query several variables.
68 AT_CHECK([atf-config atf_libexecdir atf_pkgdatadir], [0], [stdout], [])
69 AT_CHECK([grep 'atf_libexecdir' stdout], [0], [ignore], [])
70 AT_CHECK([grep 'atf_pkgdatadir' stdout], [0], [ignore], [])
71 AT_CHECK([COUNT_LINES(stdout, 2)], [0], [ignore], [])
72
73 dnl Query a non-existent variable.
74 AT_CHECK([atf-config non_existent], [1], [], [stderr])
75 AT_CHECK([grep 'Unknown variable.*non_existent' stderr], [0], [ignore], [])
76
77 dnl Query an existent and non-existent variable.
78 for v in ${all_vars}; do
79     AT_CHECK([atf-config ${v} non_existent], [1], [], [stderr])
80     AT_CHECK([grep 'Unknown variable.*non_existent' stderr],
81              [0], [ignore], [])
82     AT_CHECK([atf-config non_existent ${v}], [1], [], [stderr])
83     AT_CHECK([grep 'Unknown variable.*non_existent' stderr],
84              [0], [ignore], [])
85 done
86
87 dnl Override every variable through the environment.
88 for v in ${all_vars}; do
89     V=$(echo ${v} | tr '@<:@a-z@:>@' '@<:@A-Z@:>@')
90     AT_CHECK([env ${V}=testval atf-config], [0], [stdout], [])
91     AT_CHECK([mv stdout all], [0], [], [])
92
93     AT_CHECK([grep "^${v} : " all], [0], [stdout], [])
94     AT_CHECK([mv stdout affected], [0], [], [])
95     AT_CHECK([grep -v "^${v} : " all], [0], [stdout], [])
96     AT_CHECK([mv stdout unaffected], [0], [], [])
97
98     AT_CHECK([COUNT_LINES(affected, 1)], [0], [ignore], [])
99     AT_CHECK([COUNT_LINES(unaffected, $((${all_vars_no} - 1)))],
100              [0], [ignore], [])
101
102     AT_CHECK([grep "^${v} : testval$" affected], [0], [ignore], [])
103     AT_CHECK([grep ' : testval$' unaffected], [1], [], [])
104 done
105
106 AT_CLEANUP()
107
108 dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4