1dnl 2dnl Automated Testing Framework (atf) 3dnl 4dnl Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. 5dnl All rights reserved. 6dnl 7dnl Redistribution and use in source and binary forms, with or without 8dnl modification, are permitted provided that the following conditions 9dnl are met: 10dnl 1. Redistributions of source code must retain the above copyright 11dnl notice, this list of conditions and the following disclaimer. 12dnl 2. Redistributions in binary form must reproduce the above copyright 13dnl notice, this list of conditions and the following disclaimer in the 14dnl documentation and/or other materials provided with the distribution. 15dnl 16dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 17dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 18dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 19dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 21dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 23dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 25dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 26dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 27dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28dnl 29 30AT_SETUP([atf-config: querying of build-time variables]) 31AT_TESTED(atf-config) 32 33all_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" 48all_vars_no=15 49 50dnl List all variables. 51AT_CHECK([atf-config], [0], [stdout], []) 52AT_CHECK([COUNT_LINES(stdout, ${all_vars_no})], [0], [], []) 53for v in ${all_vars}; do 54 AT_CHECK([grep "${v}" stdout], [0], [ignore], []) 55done 56 57dnl Query a single variable and test terse mode. 58for 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], []) 65done 66 67dnl Query several variables. 68AT_CHECK([atf-config atf_libexecdir atf_pkgdatadir], [0], [stdout], []) 69AT_CHECK([grep 'atf_libexecdir' stdout], [0], [ignore], []) 70AT_CHECK([grep 'atf_pkgdatadir' stdout], [0], [ignore], []) 71AT_CHECK([COUNT_LINES(stdout, 2)], [0], [ignore], []) 72 73dnl Query a non-existent variable. 74AT_CHECK([atf-config non_existent], [1], [], [stderr]) 75AT_CHECK([grep 'Unknown variable.*non_existent' stderr], [0], [ignore], []) 76 77dnl Query an existent and non-existent variable. 78for 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], []) 85done 86 87dnl Override every variable through the environment. 88for 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], [], []) 104done 105 106AT_CLEANUP() 107 108dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4 109