-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests
executable file
·124 lines (109 loc) · 3.16 KB
/
runtests
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
118
119
120
121
122
123
124
#!/bin/sh
# Run each test and compare
# against known good output
# Build our ROMs if needed
if [ ! -f ucode.rom ]
then make
fi
# Try to use each example source file
for i in Examples/example*s
do
# Work out the output and error file names
out=`echo $i | sed 's/example/out.example/'`
err=`echo $i | sed 's/example/err.example/'`
trial=`echo $i | sed 's/.*example/trial/'`
# echo $i $out $err $trial
# We can't do anything if there's no file to test against
if [ ! -f "$out" -a ! -f "$err" ]
then echo "Can't run test on $i, no output or error file!"
# Output file: assemble the source, run it and
# capture the output, and compare it against
# the known-good output
else if [ -f "$out" ]
then
# Print the test name, assemble it
echo -n $i
./cas $i
./csim > $trial
# Compare this agains the correct output
cmp -s "$out" "$trial"
# If different, announce failure
# and print out the difference
if [ "$?" -eq "1" ]
then echo ": failed"
diff -c "$out" "$trial"
echo
# No failure, so announce success
else echo ": OK"
fi
# Error file: assemble the source and
# capture the error messages. Compare
# against the known-bad output. Same
# mechanism as before
else if [ -f "$err" ]
then
echo -n $i
./cas $i 2> "$trial"
cmp -s "$err" "$trial"
if [ "$?" -eq "1" ]
then echo ": failed"
diff -c "$err" "$trial"
echo
else echo ": OK"
fi
fi
fi
fi
rm -f instr.rom $trial
done
# Try to use each example source file
for i in Examples/ramexample*s
do
# Work out the output and error file names
out=`echo $i | sed 's/example/out.example/'`
err=`echo $i | sed 's/example/err.example/'`
trial=`echo $i | sed 's/.*example/trial/'`
# echo $i $out $err $trial
# We can't do anything if there's no file to test against
if [ ! -f "$out" -a ! -f "$err" ]
then echo "Can't run test on $i, no output or error file!"
# Output file: assemble the source, run it and
# capture the output, and compare it against
# the known-good output
else if [ -f "$out" ]
then
# Print the test name, assemble it
echo -n $i
./cas $i
./csim -l > $trial
# Compare this agains the correct output
cmp -s "$out" "$trial"
# If different, announce failure
# and print out the difference
if [ "$?" -eq "1" ]
then echo ": failed"
diff -c "$out" "$trial"
echo
# No failure, so announce success
else echo ": OK"
fi
# Error file: assemble the source and
# capture the error messages. Compare
# against the known-bad output. Same
# mechanism as before
else if [ -f "$err" ]
then
echo -n $i
./cas $i 2> "$trial"
cmp -s "$err" "$trial"
if [ "$?" -eq "1" ]
then echo ": failed"
diff -c "$err" "$trial"
echo
else echo ": OK"
fi
fi
fi
fi
rm -f instr.rom $trial
done