NetBSD-5.0.2/dist/atf/atf-sh/atf.init.subr
#
# Automated Testing Framework (atf)
#
# Copyright (c) 2007, 2008 The NetBSD Foundation, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND
# CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
# INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
# IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#
# File: atf.init.subr
#
# Initialization for a test program. A verbatim copy of this file is
# stuck at the very beginning of each test program, so it has to be
# kept as simple as possible to minimize the possible need of rebuilding
# a huge amount of test programs, which could happen after modifying
# this file.
#
Prog_Name=${0##*/}
#
# _atf_find_in_path program
#
# Looks for a program in the path and prints the full path to it or
# nothing if it could not be found. It also returns true in case of
# success.
#
_atf_find_in_path()
{
_prog="${1}"
_oldifs=${IFS}
IFS=:
for _dir in ${PATH}
do
if [ -x ${_dir}/${_prog} ]; then
IFS=${_oldifs}
echo ${_dir}/${_prog}
return 0
fi
done
IFS=${_oldifs}
return 1
}
#
# Look for atf-config to deduce where the atf.*.subr files are stored
# in the system.
#
Atf_Config=`_atf_find_in_path atf-config`
if [ -z "${Atf_Config}" ]; then
echo "${Prog_Name}: ERROR: Cannot locate atf-config in PATH" 1>&2
exit 128
fi
Atf_Pkgdatadir=`${Atf_Config} -t atf_pkgdatadir`
# vim: syntax=sh:expandtab:shiftwidth=4:softtabstop=4