1# Copyright (c) 2007 The NetBSD Foundation, Inc. 2# All rights reserved. 3# 4# Redistribution and use in source and binary forms, with or without 5# modification, are permitted provided that the following conditions 6# are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 13# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND 14# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, 15# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY 18# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 20# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 26create_files() 27{ 28 mkdir tmp 29 touch tmp/datafile 30} 31 32atf_test_case default 33default_head() 34{ 35 atf_set "descr" "Checks that the program can find its files if" \ 36 "executed from the same directory" 37} 38default_body() 39{ 40 create_files 41 42 for hp in $(get_helpers); do 43 h=${hp##*/} 44 cp ${hp} tmp 45 atf_check -s eq:0 -o ignore -e ignore -x \ 46 "cd tmp && ./${h} srcdir_exists" 47 atf_check -s eq:1 -o empty -e ignore "${hp}" -r res srcdir_exists 48 atf_check -s eq:0 -o ignore -e empty grep "Cannot find datafile" res 49 done 50} 51 52atf_test_case libtool 53libtool_head() 54{ 55 atf_set "descr" "Checks that the program can find its files if" \ 56 "executed from the source directory and if it" \ 57 "was built with libtool" 58} 59libtool_body() 60{ 61 create_files 62 mkdir tmp/.libs 63 64 for hp in $(get_helpers c_helpers cpp_helpers); do 65 h=${hp##*/} 66 cp ${hp} tmp 67 cp ${hp} tmp/.libs 68 atf_check -s eq:0 -o ignore -e ignore -x \ 69 "cd tmp && ./.libs/${h} srcdir_exists" 70 atf_check -s eq:1 -o empty -e ignore "${hp}" -r res srcdir_exists 71 atf_check -s eq:0 -o ignore -e empty grep "Cannot find datafile" res 72 done 73 74 for hp in $(get_helpers c_helpers cpp_helpers); do 75 h=${hp##*/} 76 cp ${hp} tmp 77 cp ${hp} tmp/.libs/lt-${h} 78 atf_check -s eq:0 -o ignore -e ignore -x \ 79 "cd tmp && ./.libs/lt-${h} srcdir_exists" 80 atf_check -s eq:1 -o empty -e ignore "${hp}" -r res srcdir_exists 81 atf_check -s eq:0 -o ignore -e empty grep "Cannot find datafile" res 82 done 83} 84 85atf_test_case sflag 86sflag_head() 87{ 88 atf_set "descr" "Checks that the program can find its files when" \ 89 "using the -s flag" 90} 91sflag_body() 92{ 93 create_files 94 95 for hp in $(get_helpers); do 96 h=${hp##*/} 97 cp ${hp} tmp 98 atf_check -s eq:0 -o ignore -e ignore -x \ 99 "cd tmp && ./${h} -s $(pwd)/tmp \ 100 srcdir_exists" 101 atf_check -s eq:1 -o empty -e save:stderr "${hp}" -r res srcdir_exists 102 atf_check -s eq:0 -o ignore -e empty grep "Cannot find datafile" res 103 atf_check -s eq:0 -o ignore -e ignore \ 104 "${hp}" -s "$(pwd)"/tmp srcdir_exists 105 done 106} 107 108atf_test_case relative 109relative_head() 110{ 111 atf_set "descr" "Checks that passing a relative path through -s" \ 112 "works" 113} 114relative_body() 115{ 116 create_files 117 118 for hp in $(get_helpers); do 119 h=${hp##*/} 120 cp ${hp} tmp 121 122 for p in tmp tmp/. ./tmp; do 123 echo "Helper is: ${h}" 124 echo "Using source directory: ${p}" 125 126 atf_check -s eq:0 -o ignore -e ignore \ 127 "./tmp/${h}" -s "${p}" srcdir_exists 128 atf_check -s eq:1 -o empty -e save:stderr "${hp}" -r res \ 129 srcdir_exists 130 atf_check -s eq:0 -o ignore -e empty grep "Cannot find datafile" res 131 atf_check -s eq:0 -o ignore -e ignore \ 132 "${hp}" -s "${p}" srcdir_exists 133 done 134 done 135} 136 137atf_init_test_cases() 138{ 139 atf_add_test_case default 140 atf_add_test_case libtool 141 atf_add_test_case sflag 142 atf_add_test_case relative 143} 144 145# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4 146