Skip to content

Commit fe3c6e5

Browse files
committed
judge script moved to base image
1 parent 4caeb2a commit fe3c6e5

File tree

12 files changed

+1175
-46
lines changed

12 files changed

+1175
-46
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM alpine:3.11.5
2+
3+
RUN apk add --no-cache gcc musl-dev bash
4+
5+
COPY ./runguard /usr/src/runguard
6+
RUN gcc /usr/src/runguard/runguard.c -o /bin/runguard
7+
8+
COPY ./judge.sh ./bin/judge.sh
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env bash
2+
3+
#######################################
4+
# Computes hash recursively for all the
5+
# files in the directory
6+
# Arguments:
7+
# - dir
8+
# Outputs:
9+
# - Hash
10+
#######################################
11+
function getDirHash {
12+
if [[ -z $SOLUTION ]]; then
13+
find $1 -type f -exec md5sum {} \; | awk '{print $1}' | md5sum
14+
else
15+
find $1 -path $1/$SOLUTION -prune -o -type f -exec md5sum {} \; | awk '{print $1}' | md5sum
16+
fi
17+
}
18+
19+
#######################################
20+
# Build the project and runs the test
21+
# scripts
22+
# Arguments:
23+
# - Solution Directory
24+
# Outputs:
25+
# Produces following files
26+
# - result.code
27+
# - result.stderr
28+
# - build.stderr
29+
# - run.stdout
30+
# - run.stderr
31+
#######################################
32+
function buildAndRun {
33+
currentDir=$(pwd)
34+
cd $1
35+
36+
/bin/setup.sh
37+
/bin/build.sh 1> $currentDir/build.stdout 2> $currentDir/build.stderr
38+
runguard \
39+
-t $TIME \
40+
-E result.code \
41+
-T result.time \
42+
/bin/run.sh 1> $currentDir/run.stdout 2> $currentDir/run.stderr
43+
}
44+
45+
SOLUTION=""
46+
TIME=20
47+
while getopts ":s:t:" opt; do
48+
case $opt in
49+
s) SOLUTION="$OPTARG"
50+
;;
51+
t) TIME="$OPTARG"
52+
;;
53+
\?) echo "Invalid option -$OPTARG" >&2
54+
;;
55+
esac
56+
done
57+
58+
# Verify Hashes
59+
problemHash=$(getDirHash ./problem)
60+
solutionHash=$(getDirHash ./solution)
61+
62+
if [[ $problemHash != $solutionHash ]]; then
63+
echo "25" > result.code
64+
echo "Solution modified test directory" > result.stderr
65+
exit 1
66+
fi
67+
68+
69+
buildAndRun ./solution
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* Runguard config for use with CodeRunner. Includes all necessary
2+
* DOMJudge constants from config.h.
3+
* Assumes all tests will be done as the Linux user "coderunner".
4+
* It is assumed CHROOT will not be used so the CHROOT_PREFIX
5+
* is not meaningfully set.
6+
*/
7+
8+
#ifndef _RUNGUARD_CONFIG_
9+
#define _RUNGUARD_CONFIG_
10+
11+
#define DOMJUDGE_VERSION "3"
12+
#define REVISION "3.3"
13+
14+
#define VALID_USERS "codingblocks,domjudge,jobe,jobe00,jobe01,jobe02,jobe03,jobe04,jobe05,jobe06,jobe07,jobe08,jobe09,jobe10,jobe11,jobe12,jobe13,jobe14,jobe15,jobe16,jobe17,jobe18,jobe19"
15+
16+
#define CHROOT_PREFIX "/var/www/jobe/chrootjail"
17+
18+
#endif /* _RUNGUARD_CONFIG_ */

0 commit comments

Comments
 (0)