2017-02-22 19:54:58 +00:00
|
|
|
#!/bin/sh
|
2011-07-05 11:52:06 -07:00
|
|
|
|
2013-01-15 11:45:40 -08:00
|
|
|
if [ ! -z "$srcdir" ]; then
|
2017-02-22 15:53:21 +00:00
|
|
|
compare_ir=`pwd`/tests/compare_ir.py
|
2013-01-15 11:45:40 -08:00
|
|
|
else
|
2017-02-22 15:53:21 +00:00
|
|
|
compare_ir=./compare_ir.py
|
2013-01-15 11:45:40 -08:00
|
|
|
fi
|
|
|
|
|
|
2017-02-23 13:15:42 +00:00
|
|
|
if [ -z "$PYTHON2" ]; then
|
|
|
|
|
PYTHON2=python2
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
which $PYTHON2 >/dev/null
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "Could not find python2. Make sure that PYTHON2 variable is correctly set."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
2011-07-05 11:52:06 -07:00
|
|
|
total=0
|
|
|
|
|
pass=0
|
|
|
|
|
|
2014-05-27 21:23:04 -04:00
|
|
|
echo "====== Generating tests ======"
|
|
|
|
|
for dir in tests/*/; do
|
|
|
|
|
if [ -e "${dir}create_test_cases.py" ]; then
|
|
|
|
|
cd $dir; $PYTHON2 create_test_cases.py; cd ..
|
|
|
|
|
fi
|
|
|
|
|
echo "$dir"
|
|
|
|
|
done
|
|
|
|
|
|
2011-07-05 11:52:06 -07:00
|
|
|
echo "====== Testing optimization passes ======"
|
|
|
|
|
for test in `find . -iname '*.opt_test'`; do
|
|
|
|
|
echo -n "Testing $test..."
|
|
|
|
|
(cd `dirname "$test"`; ./`basename "$test"`) > "$test.out" 2>&1
|
|
|
|
|
total=$((total+1))
|
2013-01-15 11:45:40 -08:00
|
|
|
if $PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out" >/dev/null 2>&1; then
|
2011-07-05 11:52:06 -07:00
|
|
|
echo "PASS"
|
|
|
|
|
pass=$((pass+1))
|
|
|
|
|
else
|
|
|
|
|
echo "FAIL"
|
2013-01-15 11:45:40 -08:00
|
|
|
$PYTHON2 $PYTHON_FLAGS $compare_ir "$test.expected" "$test.out"
|
2011-07-05 11:52:06 -07:00
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "$pass/$total tests returned correct results"
|
|
|
|
|
echo ""
|
|
|
|
|
|
2017-02-22 19:54:58 +00:00
|
|
|
if [ $pass = $total ]; then
|
2011-07-05 11:52:06 -07:00
|
|
|
exit 0
|
|
|
|
|
else
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|