-
Notifications
You must be signed in to change notification settings - Fork 0
/
grading-script.sh
116 lines (108 loc) · 2.33 KB
/
grading-script.sh
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
#!/bin/bash
# ./grading-script.sh <test-dir> <grading-scheme.txt>
test_dir="$1"
scheme="$2"
# Set up scratch space for grading
dir="grading"
mkdir -p $dir
cp *.h *.cpp Makefile $dir
# Check for cheating
token=`mktemp XXXXXXXXXXXXXXXXXXXXXXXX`
rm $token
sed -i -e "s/diff:/$token/" -e "s/time:/$token/" $dir/main.cpp
g++ -Wall -g -O3 -std=c++11 -M -x c++ - < minigl.cpp | tr ' \\' '\n' | grep . | sort -u > $dir/actual_include.txt
g++ -Wall -g -O3 -std=c++11 -M -x c++ - <<EOF | tr ' \\' '\n' | grep . | sort -u > $dir/max_include.txt
#include "minigl.h"
#include <cstdlib>
#include <csignal>
#include <csetjmp>
#include <cstdarg>
#include <typeinfo>
#include <bitset>
#include <functional>
#include <utility>
#include <ctime>
#include <cstddef>
#include <new>
#include <memory>
#include <climits>
#include <cfloat>
#include <limits>
#include <exception>
#include <stdexcept>
#include <cassert>
#include <cerrno>
#include <cctype>
#include <cwctype>
#include <cstring>
#include <cwchar>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>
#include <valarray>
#include <numeric>
#include <iosfwd>
#include <ios>
#include <istream>
#include <ostream>
#include <iostream>
#include <fstream>
#include <sstream>
#include <strstream>
#include <iomanip>
#include <streambuf>
#include <cstdio>
#include <locale>
#include <clocale>
#include <ciso646>
#include <assert.h>
#include <complex.h>
#include <ctype.h>
#include <errno.h>
#include <fenv.h>
#include <float.h>
#include <inttypes.h>
#include <iso646.h>
#include <limits.h>
#include <locale.h>
#include <math.h>
#include <setjmp.h>
#include <signal.h>
#include <stdalign.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <tgmath.h>
#include <time.h>
#include <uchar.h>
#include <wchar.h>
#include <wctype.h>
EOF
if comm -23 $dir/actual_include.txt $dir/max_include.txt | grep . ; then
echo "FAIL: forbidden include"
exit 1
fi
# Compile project
{
pushd $dir
if ! make -j ; then
echo "FAIL: Did not compile"
exit 1
fi
popd >/dev/null
}
# Check results against grading criteria
./grading-helper.pl $dir "$test_dir" "$scheme" $token