This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runSuite
executable file
·60 lines (56 loc) · 1.86 KB
/
runSuite
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
#!/bin/bash
# runSuite suite-file program
# runSuite runs program on each test in the test suite and
# (takes in the args if there is .args)
# reports on any tests whose output does not match the expected output.
# prints an informative error message to stderr and
# abort with 1 when:
# incorrect number of command line arguments
# abort with 2 when:
# missing .in files
# abort with 3 when:
# .in is not a regular file
# abort with 4 when:
# .in is unreadable
MASK="Ulalaulalaulaulau"
usage () {
echo "Incorrect number of command line arugments.
Usage: runSuite suite-file program" >&2
exit 1
}
if [ ${#} -ne 2 ]; then
usage
fi
for word in $(cat $1); do
if [ ! -e ${word}.in -o ! -e ${word}.out ]; then
if [ ! -e ${word}.in ]; then
echo "The file ${word}.in does not exist." >&2;fi
if [ ! -e ${word}.out ]; then
echo "The file ${word}.out does not exist." >&2;fi
exit 2
elif [ ! -f ${word}.in -o ! -f ${word}.out ]; then
if [ ! -f ${word}.in ]; then
echo "The file ${word}.in is not a regular file." >&2;fi
if [ ! -f ${word}.out ]; then
echo "The file ${word}.out is not a regular file." >&2;fi
exit 3
elif [ ! -r ${word}.in -o ! -r ${word}.out ]; then
if [ ! -r ${word}.in ]; then
echo "The file ${word}.in is not readable." >&2;fi
if [ ! -r ${word}.out ]; then
echo "The file ${word}.out is not readable." >&2;fi
exit 4
else
add1=/tmp/$MASK$word.tmp
touch $add1
ARGS=''
if [ -e ${word}.args ]; then ARGS=$(cat ${word}.args); fi
"$2" $ARGS < "${word}.in" > $add1
if ! diff -q $add1 "$word".out &>/dev/null; then
echo -e "Test failed: $word\nInput:\n$(cat $word.in)"
echo -e "Expected:\n$(cat $word.out)"
echo -e "Actual:\n$(cat $add1)"
fi
rm $add1
fi
done