-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun-test.sh
executable file
·65 lines (57 loc) · 1.69 KB
/
run-test.sh
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
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "run-test.sh all <Interpreter path>"
echo "run-test.sh <Test-path> <Interpreter path>"
echo "eg) ./run-test.sh ./test/binary_tree/ ~/swpp202001-interpreter/sf-interpreter"
exit 1
fi
INTERPRETER="$2"
if [[ "$1" == "all" ]]
then
TEST="./test/"
else
TEST=$1
fi
echo "--- Start Test.. ---"
set -e
res="./test-score.log"
touch -c $res
if [[ "$1" == "all" ]]; then
echo "TEST RESULT:" > $res
for dir in `find $TEST -maxdepth 1 -type d | cut -c 8-` ; do
echo "== Run Test on ${TEST}${dir} =="
echo "#### $dir ####" >> $res
echo " " >> $res
ll=`find ${TEST}${dir} -name "*.ll"`
./sf-compiler $ll -o tmp.s
END=`find ${TEST}${dir}/test/ -name "input*.txt" | wc -l`
for i in $(seq 1 $END) ; do
input="./${TEST}${dir}/test/input${i}.txt"
output="./${TEST}${dir}/test/output${i}.txt"
echo "-- input${i} --" # To STDOUT
echo "== input${i} ==" >> $res # To output file
cat $input | $INTERPRETER tmp.s | diff $output -
cat sf-interpreter.log >> $res
echo " " >> $res
done
done
else
dir="$1"
echo "TEST RESULT:" > $res
echo "== Run Test on ${dir} =="
echo "#### $dir ####" >> $res
echo " " >> $res
ll=`find $dir -name "*.ll"`
./sf-compiler $ll -o tmp.s
END=`find ${dir}test/ -name "input*.txt" | wc -l`
for i in $(seq 1 $END) ; do
input="./${dir}test/input${i}.txt"
output="./${dir}test/output${i}.txt"
echo "-- input${i} --" # To STDOUT
echo "== input${i} ==" >> $res # To output file
cat $input | $INTERPRETER tmp.s | diff $output -
cat sf-interpreter.log >> $res
echo " " >> $res
done
fi
rm -f tmp.s sf-interpreter.log