aboutsummaryrefslogtreecommitdiff
path: root/boca-1.5.0/doc/problemexamples/problemtemplate/run
diff options
context:
space:
mode:
Diffstat (limited to 'boca-1.5.0/doc/problemexamples/problemtemplate/run')
-rwxr-xr-xboca-1.5.0/doc/problemexamples/problemtemplate/run/c29
-rwxr-xr-xboca-1.5.0/doc/problemexamples/problemtemplate/run/cpp24
-rwxr-xr-xboca-1.5.0/doc/problemexamples/problemtemplate/run/java83
3 files changed, 69 insertions, 67 deletions
diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/run/c b/boca-1.5.0/doc/problemexamples/problemtemplate/run/c
index d65ed58..75720ee 100755
--- a/boca-1.5.0/doc/problemexamples/problemtemplate/run/c
+++ b/boca-1.5.0/doc/problemexamples/problemtemplate/run/c
@@ -65,16 +65,11 @@ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
echo "parameter problem"
exit 43
fi
-name=`basename "$1"`
-if [ ! -x "$name" ]; then
+if [ ! -x "$1" ]; then
echo "$1 not found (or is not in the current dir) or it's not executable"
exit 44
fi
-if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then
- echo "WARNING: executable file extension is not .exe"
-fi
-input=`basename "$2"`
-if [ ! -r "$input" ]; then
+if [ ! -r "$2" ]; then
echo "$2 not found (or is not in the current dir) or it's not readable"
exit 45
fi
@@ -92,22 +87,24 @@ else
fi
nruns=1
-if [ "$4" != "" -a "$4" -gt "0" ]; then
-nruns=$4
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
fi
maxm=512000
-if [ "$5" != "" -a "$5" -gt "0" ]; then
-maxm=${5}000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
fi
-rm -f stdin0 2>/dev/null
-mv "$input" stdin0
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
-rm -f run.exe 2>/dev/null
-mv "$name" run.exe
file run.exe | grep -iq "statically linked"
if [ "$?" != "0" ]; then
- echo "Aborting because $name is not statically linked"
+ echo "Aborting because $1 is not statically linked"
exit 47
fi
diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp b/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp
index 9b2d092..e5c7620 100755
--- a/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp
+++ b/boca-1.5.0/doc/problemexamples/problemtemplate/run/cpp
@@ -69,10 +69,6 @@ if [ ! -x "$1" ]; then
echo "$1 not found or it's not executable"
exit 44
fi
-name="$1"
-if [ "${name##*.}" != "exe" -a "${name##*.}" != "EXE" ]; then
- echo "WARNING: executable file extension is not .exe"
-fi
if [ ! -r "$2" ]; then
echo "$2 not found or it's not readable"
exit 45
@@ -91,22 +87,24 @@ else
fi
nruns=1
-if [ "$4" != "" -a "$4" -gt "0" ]; then
-nruns=$4
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
fi
maxm=512000
-if [ "$5" != "" -a "$5" -gt "0" ]; then
-maxm=${5}000
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}000
+ fi
fi
-rm -f stdin0 2>/dev/null
-mv "$2" stdin0
+cp "$2" stdin0 2>/dev/null
+cp "$1" run.exe 2>/dev/null
-rm -f run.exe 2>/dev/null
-mv "$name" run.exe
file run.exe | grep -iq "statically linked"
if [ "$?" != "0" ]; then
- echo "Aborting because $name is not statically linked"
+ echo "Aborting because $1 is not statically linked"
exit 47
fi
diff --git a/boca-1.5.0/doc/problemexamples/problemtemplate/run/java b/boca-1.5.0/doc/problemexamples/problemtemplate/run/java
index 945f15d..c24d842 100755
--- a/boca-1.5.0/doc/problemexamples/problemtemplate/run/java
+++ b/boca-1.5.0/doc/problemexamples/problemtemplate/run/java
@@ -65,6 +65,12 @@ if [ "$1" == "" -o "$2" == "" -o "$3" == "" ]; then
echo "parameter problem"
exit 43
fi
+if [ -r run.exe ]; then
+ mv run.exe run.jar
+fi
+if [ -r "$1" ]; then
+ mv "$1" run.jar
+fi
if [ ! -r run.jar ]; then
echo "ERROR: file run.jar not found - possible error during compilation"
exit 1
@@ -79,8 +85,7 @@ fi
if [ "${name##*.}" == "CLASS" ]; then
name=`basename "$1" .CLASS`
fi
-input=`basename "$2"`
-if [ ! -r "$input" ]; then
+if [ ! -r "$2" ]; then
echo "$2 not found (or is not in the current dir) or it's not readable"
exit 45
fi
@@ -98,16 +103,20 @@ else
fi
nruns=1
-if [ "$4" != "" -a "$4" -gt "0" ]; then
-nruns=$4
+if [ "$4" != "" ]; then
+ if [ "$4" -gt "0" ]; then
+ nruns=$4
+ fi
fi
maxm=512
-if [ "$5" != "" -a "$5" -gt "0" ]; then
-maxm=${5}
+if [ "$5" != "" ]; then
+ if [ "$5" -gt "0" ]; then
+ maxm=${5}
+ fi
fi
-rm -f stdin0 2>/dev/null
-mv "$input" stdin0
+rm -f runit.retcode 2>/dev/null
+cp "$2" stdin0 2>/dev/null
cdir=`pwd`
echo "Current directory is $cdir" >&2
@@ -116,46 +125,44 @@ if [ $? == 0 ]; then
cdir=`echo $cdir | sed "s/.*\/bocajail//"`
cat <<EOF > runit.sh
#!/bin/bash
+cd "$cdir"
[ -f /proc/cpuinfo ] || /bin/mount -t proc proc /proc
#/bin/mount --bind /dev /dev
[ -d /sys/kernel ] || /bin/mount -t sysfs sysfs /sys
java=`which java`
-[ -x "$java" ] || java=/usr/bin/java
-if [ ! -x $java ]; then
- echo "$java not found or it's not executable"
+[ -x "\$java" ] || java=/usr/bin/java
+if [ ! -x \$java ]; then
+ echo "\$java not found or it's not executable"
exit 47
fi
export CLASSPATH=.:./run.jar:$CLASSPATH
-cd $cdir
-$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- $java -Xmx${maxm}M -Xms${maxm}M "$name"
+$sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -ostdout0 -estderr0 -U$bocau -G$bocag -n0 -C. -f20000 -d20000000 -m20000000 -- \$java -Xmx${maxm}M -Xms${maxm}M "$name"
echo \$? > runit.retcode
-/bin/umount /proc 2>/dev/null
-#/bin/umount /dev
-/bin/umount /sys 2>/dev/null
+if [ ! -d /bocajail ]; then
+ /bin/umount /proc 2>/dev/null
+ #/bin/umount /dev
+ /bin/umount /sys 2>/dev/null
+fi
EOF
- chmod 755 runit.sh
- chroot /bocajail $cdir/runit.sh
- ret=`cat runit.retcode`
- if [ "$ret" == "" ]; then
- echo "Execution error - check autojudging"
- exit 49
- fi
- if [ $ret -gt 10 ]; then
- echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
- exit 9
- fi
- else
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
- echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
-# $java "$name" < stdin0
- $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name"
- ret=$?
- fi
- if [ $ret -gt 10 ]; then
- echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
- ret=9
+ chmod 755 runit.sh
+ chroot /bocajail "$cdir/runit.sh"
+ if [ -r runit.retcode ]; then
+ ret=`cat runit.retcode`
fi
+ if [ "$ret" == "" ]; then
+ echo "Execution error - check autojudging"
+ exit 49
+ fi
+else
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ echo "CODE NOT BEING CHROOTED. DO NOT RUN THIS ON THE MAIN SERVER" >&2
+ $sf -r$nruns -t$time -T$ttime -istdin0 -F256 -u256 -U$bocau -G$bocag -ostdout0 -estderr0 -n0 -C. -d20000000 -m20000000 -- $java -cp run.jar -Xmx${maxm}M -Xms${maxm}M "$name"
+ ret=$?
+fi
+if [ $ret -gt 10 ]; then
+ echo "> > > > > > > Nonzero return code - possible runtime error - I'M GUESSING IT IS RUNTIME ERROR < < < < < < < <"
+ ret=9
fi
if [ -f stdout0 ]; then
cat stdout0