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