1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
# $Id: check-common.sh.in,v 1.5 2008/10/20 17:39:13 rockyb Exp $
# -*- shell-script -*-
srcdir=@srcdir@
builddir=@builddir@
[ -z "$SH" ] && SH=@SH_PROG@
export top_builddir=@abs_top_builddir@
export top_srcdir=@abs_top_srcdir@
export abs_top_srcdir=@abs_top_srcdir@
export host_os=@host_os@
check_output() {
testfile=$1
rightfile=$2
# Bourne sh
# set -o noglob
@DIFF@ @DIFF_OPTS@ "$testfile" "$rightfile" && rm -f "$testfile"
return $?
}
# Run the debugger on test program $1 with (optional) zshdb options $2
# using commandfile $3. We assume $top_builddir, $top_srcdir and
# $TEST_NAME have been set previously
run_debugger() {
debugged_script=$1
bashdb_opts=${2:-"-B --no-init -q -L ${top_builddir}"}
cmdfile=${3:-"${top_builddir}/test/data/${TEST_NAME}.cmd"}
$SH -- ${top_builddir}/bashdb $bashdb_opts -x "$cmdfile" "$debugged_script"
}
TEST_FILE="${top_builddir}/test/${TEST_NAME}.check"
RIGHT_FILE="${top_srcdir}/test/data/${TEST_NAME}.right"
TEST_FILTERED_FILE="/tmp/${TEST_NAME}-filtered.check"
RIGHT_FILTERED_FILE="/tmp/${TEST_NAME}-filtered.right"
run_test_check() {
short_script_name=${1:-$TEST_NAME}
debugged_script="${top_srcdir}/test/example/${short_script_name}.sh"
(cd $srcdir && run_debugger "$debugged_script" 2>&1 >"$TEST_FILE" </dev/null)
check_output "$TEST_FILE" "$RIGHT_FILE"
# Return code tells testing mechanism whether passed or not.
exit $?
}
|