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
|
#! /bin/sh
# $Id$
basedir=`/bin/pwd`
t=./test_negative
init_test () {
# $1: Options for test_negative
# $2: Path to test record
options="$1"
input="$2"
output=`dirname $input`/`basename $input .xml`.out
if [ -f "$output" ]; then
echo "Test $input already initialized; skipping"
else
$t $options "$input" | sed "s:$basedir:/BASEDIR:" >"$output"
echo Test $input initialized.
fi
}
check_test () {
# $1: Options for test_negative
# $2: Path to test record
options="$1"
input="$2"
output=`dirname $input`/`basename $input .xml`.out
$t $options "$input" | sed -e "s:$basedir:/BASEDIR:" >current.out
if [ -f "$output" ]; then
if cmp "$output" current.out; then
echo Test $input OK
else
echo Test $input FAILED!!!
if [ $verbose -gt 0 ]; then
echo "=== ACTUAL OUTPUT ==="
cat current.out
echo "=== EXPECTED OUTPUT ==="
cat "$output"
echo "#####################################################"
fi
fi
else
echo Test $input still uninitialized
echo - OUTPUT:
cat current.out
fi
}
for_directory () {
what="$1"
shift
options="$1"
shift
while [ $# -gt 0 ]; do
input="$1"
shift
if [ -f "$input" ]; then
$what "$options" "$input"
else
if [ -d "$input" ]; then
for ent in $input/*.xml; do
for_directory $what "$options" $ent
done
else
echo "Not found: $input" >&2
fi
fi
done
}
usage () {
cat <<EOF >&2
usage: $0 [ -init -wf -verbose ] file ... dir ...
EOF
exit 1
}
action="check_test"
options=""
verbose=0
while true; do
case "x$1" in
x-init)
action="init_test"
shift
;;
x-wf)
options="$options -wf"
shift
;;
x-verbose)
verbose=1
shift
;;
x-*)
usage
;;
*)
break
;;
esac
done
if [ $# -gt 0 ]; then
for_directory $action "$options" "$@"
else
for_directory $action -wf \
data_jclark_notwf/ext-sa data_jclark_notwf/not-sa data_jclark_notwf/sa \
data_notwf/sa
for_directory $action "" \
data_jclark_invalid data_invalid
fi
|