diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-05 18:37:14 +0000 |
commit | ea648e70a989cca190cd7403fe892fd2dcc290b4 (patch) | |
tree | e2b6b1c647da68b0d4d66082835e256eb30970e8 /unit/atf-src/bootstrap/t_atf_config.at | |
parent | Initial commit. (diff) | |
download | bind9-upstream.tar.xz bind9-upstream.zip |
Adding upstream version 1:9.11.5.P4+dfsg.upstream/1%9.11.5.P4+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'unit/atf-src/bootstrap/t_atf_config.at')
-rw-r--r-- | unit/atf-src/bootstrap/t_atf_config.at | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/unit/atf-src/bootstrap/t_atf_config.at b/unit/atf-src/bootstrap/t_atf_config.at new file mode 100644 index 0000000..a863169 --- /dev/null +++ b/unit/atf-src/bootstrap/t_atf_config.at @@ -0,0 +1,108 @@ +dnl +dnl Automated Testing Framework (atf) +dnl +dnl Copyright (c) 2007 The NetBSD Foundation, Inc. +dnl All rights reserved. +dnl +dnl Redistribution and use in source and binary forms, with or without +dnl modification, are permitted provided that the following conditions +dnl are met: +dnl 1. Redistributions of source code must retain the above copyright +dnl notice, this list of conditions and the following disclaimer. +dnl 2. Redistributions in binary form must reproduce the above copyright +dnl notice, this list of conditions and the following disclaimer in the +dnl documentation and/or other materials provided with the distribution. +dnl +dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND +dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, +dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY +dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +dnl + +AT_SETUP([atf-config: querying of build-time variables]) +AT_TESTED(atf-config) + +all_vars="atf_arch \ + atf_build_cc \ + atf_build_cflags \ + atf_build_cpp \ + atf_build_cppflags \ + atf_build_cxx \ + atf_build_cxxflags \ + atf_confdir \ + atf_includedir \ + atf_libdir \ + atf_libexecdir \ + atf_machine \ + atf_pkgdatadir \ + atf_shell \ + atf_workdir" +all_vars_no=15 + +dnl List all variables. +AT_CHECK([atf-config], [0], [stdout], []) +AT_CHECK([COUNT_LINES(stdout, ${all_vars_no})], [0], [], []) +for v in ${all_vars}; do + AT_CHECK([grep "${v}" stdout], [0], [ignore], []) +done + +dnl Query a single variable and test terse mode. +for v in ${all_vars}; do + AT_CHECK([atf-config ${v}], [0], [stdout], []) + AT_CHECK([COUNT_LINES(stdout, 1)], [0], [], []) + AT_CHECK([grep "${v}" stdout], [0], [ignore], []) + AT_CHECK([cut -d ' ' -f 3- stdout], [0], [stdout], []) + AT_CHECK([mv stdout expout], [0], [], []) + AT_CHECK([atf-config -t ${v}], [0], [expout], []) +done + +dnl Query several variables. +AT_CHECK([atf-config atf_libexecdir atf_pkgdatadir], [0], [stdout], []) +AT_CHECK([grep 'atf_libexecdir' stdout], [0], [ignore], []) +AT_CHECK([grep 'atf_pkgdatadir' stdout], [0], [ignore], []) +AT_CHECK([COUNT_LINES(stdout, 2)], [0], [ignore], []) + +dnl Query a non-existent variable. +AT_CHECK([atf-config non_existent], [1], [], [stderr]) +AT_CHECK([grep 'Unknown variable.*non_existent' stderr], [0], [ignore], []) + +dnl Query an existent and non-existent variable. +for v in ${all_vars}; do + AT_CHECK([atf-config ${v} non_existent], [1], [], [stderr]) + AT_CHECK([grep 'Unknown variable.*non_existent' stderr], + [0], [ignore], []) + AT_CHECK([atf-config non_existent ${v}], [1], [], [stderr]) + AT_CHECK([grep 'Unknown variable.*non_existent' stderr], + [0], [ignore], []) +done + +dnl Override every variable through the environment. +for v in ${all_vars}; do + V=$(echo ${v} | tr '@<:@a-z@:>@' '@<:@A-Z@:>@') + AT_CHECK([env ${V}=testval atf-config], [0], [stdout], []) + AT_CHECK([mv stdout all], [0], [], []) + + AT_CHECK([grep "^${v} : " all], [0], [stdout], []) + AT_CHECK([mv stdout affected], [0], [], []) + AT_CHECK([grep -v "^${v} : " all], [0], [stdout], []) + AT_CHECK([mv stdout unaffected], [0], [], []) + + AT_CHECK([COUNT_LINES(affected, 1)], [0], [ignore], []) + AT_CHECK([COUNT_LINES(unaffected, $((${all_vars_no} - 1)))], + [0], [ignore], []) + + AT_CHECK([grep "^${v} : testval$" affected], [0], [ignore], []) + AT_CHECK([grep ' : testval$' unaffected], [1], [], []) +done + +AT_CLEANUP() + +dnl vim: syntax=m4:expandtab:shiftwidth=4:softtabstop=4 |