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
|
#!/bin/sh
top_srcdir=@abs_top_srcdir@
top_builddir=@abs_top_builddir@
wd="${top_srcdir}/samples/data"
run_test() {
name=$1
shift
expect_status=$1
shift
input_file=$1
shift
cmd=$1
shift
export XERCESC_NLS_HOME=${top_builddir}/src
builddir=$(pwd)
if [ ! -d observed ]; then
mkdir -p observed
fi
output="${builddir}/observed/${name}.log"
test_status=fail
cd "$wd"
if [ -n "$input_file" ]; then
echo "Running ${top_builddir}/$cmd $@ < "$input_file" > \"$output\" 2> \"$output\" $input"
"${top_builddir}/$cmd" "$@" < "$input_file" > "$output" 2> "$output" $input && test_status=pass
else
echo "Running ${top_builddir}/$cmd $@ > \"$output\" 2> \"$output\" $input"
"${top_builddir}/$cmd" "$@" > "$output" 2> "$output" $input && test_status=pass
fi
echo "Result: $test_status"
if [ "$expect_status" != "$test_status" ]; then
echo "$name: Expected $expect_status status but got $test_status status" >&2
if [ "$expect_status" = pass ]; then
exit 1
fi
exit 0
fi
cd "$builddir"
# Replace timings in output
sed -i -e 's;\( *[0-9][0-9]* *ms *\);{timing removed};' "$output"
exp=$(cat "${srcdir}/expected/${name}.log")
obs=$(cat "$output")
echo "------"
echo "obs=$obs"
echo "------"
echo "exp=$exp"
echo "------"
# If the observed and expected logs differ, output a diff and fail
if [ "$exp" != "$obs" ]; then
diff -u "${srcdir}/expected/${name}.log" "$output"
echo "Observed output does not match expected output" >&2
if [ "$expect_status" = pass ]; then
exit 1
fi
exit 0
fi
if [ "$expect_status" = pass ]; then
exit 0
fi
exit 1
}
|