693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# Copyright (c) 2007 The NetBSD Foundation, Inc.
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# All rights reserved.
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews#
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# Redistribution and use in source and binary forms, with or without
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# modification, are permitted provided that the following conditions
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# are met:
0c27b3fe77ac1d5094ba3521e8142d9e7973133fMark Andrews# 1. Redistributions of source code must retain the above copyright
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# notice, this list of conditions and the following disclaimer.
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# 2. Redistributions in binary form must reproduce the above copyright
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# notice, this list of conditions and the following disclaimer in the
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# documentation and/or other materials provided with the distribution.
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews#
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
693d70f96fc2b3c1830580edcc29146afd6a9f61Mark Andrews# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
76b242bb778a350076d8f2889c8b9b4c4c70969aMark Andrews# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrewsatf_test_case has
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrewshas_head()
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews{
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews atf_set "descr" "Verifies that atf_config_has works"
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews}
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrewshas_body()
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews{
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews
017aa9aef63aaef6a370c180f6290b8388deda01Mark Andrews atf_check -s eq:0 -o match:'foo not found' -e ignore -x \
"TEST_VARIABLE=foo ${h} config_has"
atf_check -s eq:0 -o match:'foo found' -e ignore -x \
"TEST_VARIABLE=foo ${h} -v foo=bar config_has"
echo "Checking for deprecated variables"
atf_check -s eq:0 -o match:'workdir not found' -e ignore -x \
"TEST_VARIABLE=workdir ${h} config_has"
}
atf_test_case get
get_head()
{
atf_set "descr" "Verifies that atf_config_get works"
}
get_body()
{
h="$(atf_get_srcdir)/misc_helpers -s $(atf_get_srcdir)"
echo "Querying an undefined variable"
( atf_config_get "undefined" ) >out 2>err && \
atf_fail "Getting an undefined variable succeeded"
grep 'not find' err || \
atf_fail "Getting an undefined variable did not report an error"
echo "Querying an undefined variable using a default value"
v=$(atf_config_get "undefined" "the default value")
[ "${v}" = "the default value" ] || \
atf_fail "Default value does not work"
atf_check -s eq:0 -o match:'foo = bar' -e ignore -x \
"TEST_VARIABLE=foo ${h} -v foo=bar config_get"
atf_check -s eq:0 -o match:'foo = baz' -e ignore -x \
"TEST_VARIABLE=foo ${h} -v foo=baz config_get"
}
atf_init_test_cases()
{
atf_add_test_case has
atf_add_test_case get
}
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4