2 dnl Automated Testing Framework (atf)
4 dnl Copyright (c) 2007 The NetBSD Foundation, Inc.
5 dnl All rights reserved.
7 dnl Redistribution and use in source and binary forms, with or without
8 dnl modification, are permitted provided that the following conditions
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.
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.
30 AT_SETUP([atf-config: querying of build-time variables])
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], [])
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], [])
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], [])
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], [])
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],
82 AT_CHECK([atf-config non_existent ${v}], [1], [], [stderr])
83 AT_CHECK([grep 'Unknown variable.*non_existent' stderr],
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], [], [])
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], [], [])
98 AT_CHECK([COUNT_LINES(affected, 1)], [0], [ignore], [])
99 AT_CHECK([COUNT_LINES(unaffected, $((${all_vars_no} - 1)))],
102 AT_CHECK([grep "^${v} : testval$" affected], [0], [ignore], [])
103 AT_CHECK([grep ' : testval$' unaffected], [1], [], [])
108 dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4