-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradescript
More file actions
executable file
·63 lines (53 loc) · 1.62 KB
/
gradescript
File metadata and controls
executable file
·63 lines (53 loc) · 1.62 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
#!/bin/sh
dir=/home/plank/cs360/labs/labb
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=bonding
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
./$program `cat $ge/$enum.txt` > tmp-$enum-test-stdout.txt 2> tmp-$enum-test-stderr.txt
call="./$program "`cat $ge/$enum.txt`" > tmp-$enum-test-stdout.txt 2> tmp-$enum-test-stderr.txt"
nm=`cat $ge/$enum.txt | awk '{ print $2*3 }'`
out=`wc tmp-$enum-test-stdout.txt | awk '{ print $1 }'`
err=`wc tmp-$enum-test-stderr.txt | awk '{ print $1 }'`
if [ $out != $nm -o $err != 0 ]; then
echo "Problem $enum is incorrect."
echo ""
if [ $out != $nm ]; then
echo "Your standard output should have $nm lines, but it has $out."
fi
if [ $err != 0 ]; then
echo "Your standard error was not empty."
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 "Try putting some verbosity statements into your code to debug it."
echo "Please remember to delete 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
fi