if [ ! -z "$srcdir" ]; then
testdir=$srcdir/glcpp/tests
+ outdir=`pwd`/glcpp/tests
glcpp=`pwd`/glcpp/glcpp
else
testdir=.
+ outdir=.
glcpp=../glcpp
fi
;;
"--testdir="*)
testdir="${option#--testdir=}"
+ outdir="${outdir}/${option#--testdir=}"
;;
*)
echo "Unrecognized option: $option" >&2
pass=0
clean=0
+mkdir -p $outdir
+
echo "====== Testing for correctness ======"
for test in $testdir/*.c; do
- printf "Testing $test..."
- $glcpp $(test_specific_args $test) < $test > $test.out 2>&1
+ out=$outdir/${test##*/}.out
+
+ printf "Testing $test... > $out ($test.expected) "
+ $glcpp $(test_specific_args $test) < $test > $out 2>&1
total=$((total+1))
- if cmp $test.expected $test.out >/dev/null 2>&1; then
+ if cmp $test.expected $out >/dev/null 2>&1; then
echo "PASS"
pass=$((pass+1))
else
echo "FAIL"
- diff -u $test.expected $test.out
+ diff -u $test.expected $out
fi
done
for file in "$testdir"/*.c; do
base=$(basename "$file")
tr "\n" "\r" < "$file" > subtest-cr/"$base"
- cp subtest-lf/"$base".out subtest-cr/"$base".expected
+ cp `pwd`/glcpp/tests/subtest-lf/"$base".out subtest-cr/"$base".expected
done
run_test "${glcpp_test} --testdir=subtest-cr"
for file in "$testdir"/*.c; do
base=$(basename "$file")
sed -e 's/$/\r/' < "$file" > subtest-cr-lf/"$base"
- cp subtest-lf/"$base".out subtest-cr-lf/"$base".expected
+ cp `pwd`/glcpp/tests/subtest-lf/"$base".out subtest-cr-lf/"$base".expected
done
run_test "${glcpp_test} --testdir=subtest-cr-lf"
for file in "$testdir"/*.c; do
base=$(basename "$file")
sed -e 's/$/\r/' < "$file" | tr "\n\r" "\r\n" > subtest-lf-cr/"$base"
- cp subtest-lf/"$base".out subtest-lf-cr/"$base".expected
+ cp `pwd`/glcpp/tests/subtest-lf/"$base".out subtest-lf-cr/"$base".expected
done
run_test "${glcpp_test} --testdir=subtest-lf-cr"