-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtestcgen.sh
More file actions
executable file
·117 lines (106 loc) · 3.63 KB
/
Copy pathtestcgen.sh
File metadata and controls
executable file
·117 lines (106 loc) · 3.63 KB
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
RUNTIME_FILE=/Users/zellyn/go/src/github.com/zellyn/gocool/resources/trap.handler
tempfoo=`basename $0`
rm -rf $TMPDIR/$tempfoo.*
OUTDIR=`mktemp -d -t ${tempfoo}`
./buildparser.sh || exit 1
go build cmd/codegen/codegen.go || exit 1
FILES='abort casevoid dispatchvoidlet dispatch-void-dynamic mod-param dispatch-void-static interaction-attrinit-method while-val shadow-let-let shadow-attr-let many_objects_on_heap case-none shadow-case-let shadow-let-case shadow-attr-case case-order shadow-formal-let shadow-attr-formal letinit shadow-formal-case eval-order-self let-nested bigexpr eval-order-args sequence fibo simple-gc assignment-val basic-init string-methods newbasic init-order-self basicequality calls init-order-super fact dispatch-override-dynamic copy-self-dispatch multiple-dispatch selftypeattribute new-self-dispatch dispatch-override-static recclass scoping typename primes new-st override-basic exp init-default objectequality multiple-static-dispatch bool eval-order-arith copy-self-init new-self-init not hairyscary cells override sort_list book_list c lam lam-gc bigexample nested-arith'
[[ $# -gt 0 ]] && FILES="${@:1}"
CORRECT=0
INCORRECT=0
BADNAME=''
BADWANT=''
BADGOT=''
gcfilter()
{
perl -p -e 's/Garbage collecting \.\.\.\n//; s/Major \.\.\.\n//'
}
succeed ()
{
CORRECT=$((CORRECT+1))
echo " ok"
return 0
}
fail ()
{
INCORRECT=$((INCORRECT+1))
echo " FAIL"
if [[ $BADNAME == '' ]]
then
BADNAME=$1
BADWANT=$2
BADGOT=$3
BADGCFLAGS=$4
fi
return 1
}
echo "WITHOUT GARBAGE COLLECTION"
GCFLAGS=""
for i in $FILES
do
echo -n "$i..."
./codegen $GCFLAGS testdata/codegen/$i.cl > $OUTDIR/$i.s || exit 1
OUTWANT=$OUTDIR/$i.want.out
OUTGOT=$OUTDIR/$i.got.out
testdata/codegen/PA5-filter < testdata/codegen/$i.cl.out > $OUTWANT
spim -exception_file $RUNTIME_FILE -file $OUTDIR/$i.s | testdata/codegen/PA5-filter > $OUTGOT
if cmp -s $OUTWANT $OUTGOT
then
succeed
else
fail $i $OUTWANT $OUTGOT "$GCFLAGS"
fi
done
echo "WITH NORMAL GARBAGE COLLECTION"
GCFLAGS="-usegc"
for i in $FILES
do
echo -n "$i..."
./codegen $GCFLAGS testdata/codegen/$i.cl > $OUTDIR/$i.s || exit 1
OUTWANT=$OUTDIR/$i.want.out
OUTGOT=$OUTDIR/$i.got.out
testdata/codegen/PA5-filter < testdata/codegen/$i.cl.out > $OUTWANT
spim -exception_file $RUNTIME_FILE -file $OUTDIR/$i.s | gcfilter | testdata/codegen/PA5-filter > $OUTGOT
if cmp -s $OUTWANT $OUTGOT
then
succeed
else
fail $i $OUTWANT $OUTGOT "$GCFLAGS"
fi
done
if [[ ($INCORRECT == 0) && ($NOSLOW == "") ]]
then
echo "WITH COLLECT-ALWAYS GARBAGE COLLECTION"
GCFLAGS="-usegc -testgc"
for i in $FILES
do
echo -n "$i..."
./codegen $GCFLAGS testdata/codegen/$i.cl > $OUTDIR/$i.s || exit 1
OUTWANT=$OUTDIR/$i.want.out
OUTGOT=$OUTDIR/$i.got.out
testdata/codegen/PA5-filter < testdata/codegen/$i.cl.out > $OUTWANT
spim -exception_file $RUNTIME_FILE -file $OUTDIR/$i.s | gcfilter | testdata/codegen/PA5-filter > $OUTGOT
if cmp -s $OUTWANT $OUTGOT
then
succeed
else
fail $i $OUTWANT $OUTGOT "$GCFLAGS"
break
fi
done
fi
if [[ $INCORRECT == 0 ]]
then
echo "($CORRECT/$((CORRECT+INCORRECT)))"
echo "ok"
else
echo -e "\nFirst failure: $BADNAME"
diff -u $BADWANT $BADGOT
echo "cat -n testdata/codegen/$BADNAME.cl"
echo "go build cmd/codegen/codegen.go && ./codegen $BADGCFLAGS testdata/codegen/$BADNAME.cl > $BADNAME.s && spim -exception_file $PWD/resources/trap.handler -file $BADNAME.s"
echo "($CORRECT/$((CORRECT+INCORRECT)))"
echo "FAIL"
exit 1
fi
rm -r $OUTDIR
rm -f ./codegen