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 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
#! /bin/sh -pe
# Regression test driver for libhsync.
# Copyright (C) 2000 by Martin Pool
# $Id: driver.sh,v 1.7 2000/08/06 12:50:36 mbp Exp $
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public License
# as published by the Free Software Foundation; either version 2.1 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# This script doesn't do anything except general setup. It should be
# passed the name of the actual script file as the first parameter.
# You can pass additional arguments to give options which are usually
# passed through. For example in most cases -D will turn on debugging
# trace.
# NB: Tests should exit with code 77 if they can't be run but haven't
# failed.
# NB: We can't rely on having the executable bit set on this script or
# any other, because CVS doesn't always update them properly.
# TODO: Rather than using source files, write some programs that
# generate random data of defined lengths. However, it should not be
# totally random: it should have some kind of autocorrelation. Also,
# perhaps generate random pairs of related files. Perhaps do this
# using genmaptest.
# Don't ever allow undefined shell variables to default
set -u
if [ $# -lt 1 ]
then
echo 'runtest: must have at least one parameter, the test script'
exit 1
fi
test_script=$1
shift
test_name=`basename $test_script .sh`
# TODO: Add more pair instructions here
delta_instr="
0,1024
0,2048
1024,1024:0,1024
0,1025
0,1
0,10
0,1000
0,2000
0,10000
0,100000
1,10
1,10000
0,2000:2000,2000:4000,100000
1,10000:0,1:10000,1000000
10,1:8,4:6,8:4,10:2,12
0,10000:0,10000:0,10000
"
# Process command-line options
trace=:
stats=
debug=
time=
for o in "$@"
do
case "$o" in
-D)
debug=-D
;;
-S)
stats=-S
;;
-x)
trace='set -x'
;;
-t)
time='time'
;;
*)
echo "unrecognized driver option $o" >&2
exit 1
;;
esac
done
if [ "${srcdir:-}" = "" ]
then
srcdir=`dirname $0`
fi
srcdir=`cd $srcdir; pwd`
builddir=`pwd`
PATH=$builddir:$srcdir:$PATH
export PATH
testdir=$srcdir/$test_name
tmpdir=$builddir/`echo $test_name | sed -e s/^test-/tmp-/`
[ -d $tmpdir ] || mkdir $tmpdir || exit 2
test_skipped () {
echo $test_name: skipped; exit 77
}
run_test () {
if $*
then
:
else
echo $test_name: failed: "$*" >&2
exit 2
fi
}
# more than this many on any one test gets boring
ntests=300
countdown () {
ntests=`expr $ntests - 1` || exit 0
}
make_input () {
cat $srcdir/COPYING
}
# make_manyfiles() {
# find $srcdir $builddir -type f |head -1000
# }
echo "$test_name"
$trace
. $test_script $*
rm -f $tmpdir/*
rmdir $tmpdir
# If nothing failed, then
exit 0
|