forked from ShanghaitechGeekPie/oj-baseimage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
28 lines (25 loc) · 817 Bytes
/
run
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
#!/usr/bin/env bash
cd /judge
mkdir output
if [ -f /judge/tests/last ] ; then
TOTAL=$(cat /judge/tests/last)
echo "$((TOTAL+1)) total test cases"
else
echo "/judge/tests/last not found" 1>&2
exit 1
fi
for INDEX in $(seq -s " " 0 ${TOTAL}) ; do
touch "/judge/tests/input/${INDEX}"
if [ -f "/judge/tests/req/${INDEX}" ] ; then
RESOURCE=$(cat "/judge/tests/req/${INDEX}")
elif [ -f "/judge/tests/req/default" ] ; then
RESOURCE=$(cat "/judge/tests/req/default")
else
echo "resource constraint for ${INDEX} not found" 1>&2
exit 1
fi
mkdir /test -p
chown 1000:1000 /test
./run.py "/judge/tests/input/${INDEX}" "/judge/output/stdout${INDEX}" "/dev/null" ${RESOURCE} || echo $? > /judge/output/err${INDEX}
mv /test "output/${INDEX}"
done