-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradescript
More file actions
executable file
·66 lines (57 loc) · 2.15 KB
/
gradescript
File metadata and controls
executable file
·66 lines (57 loc) · 2.15 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
#!/bin/sh
dir=/home/plank/cs360/labs/lab8
ge="$dir/Gradescript-Examples"
if [ $# -ne 1 ]; then
echo 'usage: gradescript problem_number (1-100)' >&2
exit 1
fi
if [ "$1" -gt 0 -a "$1" -le 100 ]; then
enum=`echo $1 | awk '{ printf "%03d\n", $1 }'`
else
echo 'usage: gradescript problem_number (1-100)' >&2
exit 1
fi
program=jsh
if [ ! -f $program ]; then
echo "Problem $enum is incorrect."
echo ""
echo "Your program $program does not exist."
exit 0
fi
rm -f tmp-$enum-test-stdout.txt tmp-$enum-test-stderr.txt tmp-$enum-correct-stdout.txt tmp-$enum-correct-stderr.txt
/bin/sh -c "$dir/$program - < $ge/$enum-input.txt > tmp-$enum-correct-stdout.txt 2> tmp-$enum-correct-stderr.txt"
/bin/sh -c "./$program - < $ge/$enum-input.txt > tmp-$enum-test-stdout.txt 2> tmp-$enum-test-stderr.txt"
call="sh -c './$program - < $ge/$enum-input.txt > tmp-$enum-test-stdout.txt 2>tmp-$enum-test-stderr.txt'"
out=`diff tmp-$enum-correct-stdout.txt tmp-$enum-test-stdout.txt | wc | awk '{ print $1 }'`
err=`diff tmp-$enum-correct-stderr.txt tmp-$enum-test-stderr.txt | wc | awk '{ print $1 }'`
if [ $out != 0 -o $err != 0 ]; then
echo "Problem $enum is incorrect."
echo ""
if [ $out != 0 ]; then
echo "Your standard output does not match the correct one."
fi
if [ $err != 0 ]; then
echo "Your standard error does not match the correct one."
fi
echo ""
echo "TEST:"
echo ""
echo "$call"
echo ""
echo "FILES:"
echo ""
echo "Your standard output is in tmp-$enum-test-stdout.txt."
echo "Your standard error is in tmp-$enum-test-stderr.txt."
echo ""
echo "The correct standard output is in tmp-$enum-correct-stdout.txt."
echo "The correct standard error is in tmp-$enum-correct-stderr.txt."
echo ""
echo "Look at correct files and your files, perhaps run 'diff -y' on them, and figure out your mistake."
echo "Please remember to delete these files when you are finished."
else
echo "Problem $enum is correct."
echo ""
echo "Test: $call"
rm -f tmp-$enum-test-stdout.txt tmp-$enum-test-stderr.txt tmp-$enum-correct-stdout.txt tmp-$enum-correct-stderr.txt
rm -f f1.txt f2.txt f3.txt f4.txt f5.txt f6.txt f7.txt f8.txt f9.txt f0.txt
fi