]> mj.ucw.cz Git - moe.git/commitdiff
Added public scripts.
authorMartin Mares <mj@ucw.cz>
Thu, 29 Mar 2001 18:52:25 +0000 (18:52 +0000)
committerMartin Mares <mj@ucw.cz>
Thu, 29 Mar 2001 18:52:25 +0000 (18:52 +0000)
TODO
bin/ev
bin/lib
config
examples/problems/sum/config
public/check [new file with mode: 0644]
public/compile [new file with mode: 0644]
public/submit [new file with mode: 0644]

diff --git a/TODO b/TODO
index d9fbb8705e98c74b2807d5f549ec7dfc86d6ae6e..e0ef7405b079fecb84ff6c91406bd5869752cbd6 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
-submit, compile, test (submit bez odevzdani)
 check pascal
 -static ?
 quotas
diff --git a/bin/ev b/bin/ev
index 0a462bf40f4a0a56689f85b4641b2847be2c4030..0ddd6d365a8678299e7aca5794ca21b4a6025522 100755 (executable)
--- a/bin/ev
+++ b/bin/ev
@@ -29,22 +29,23 @@ locate-source
 compile
 
 # Perform the tests
+PTSFILE=$TDIR/points
 for TEST in $TESTS ; do
        (
        [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
        exec >$TDIR/$TEST.log
-       PTSFILE=$TDIR/$TEST.pts
        pstart "Test $TEST ($POINTS_PER_TEST points)... "
        echo "Test $TEST ($POINTS_PER_TEST points)"
+       echo >>$PTSFILE -n "$TEST "
        if [ ! -f $TDIR/$PROBLEM ] ; then
                echo >$PTSFILE "0 Compile error."
                die "No executable file"
        fi
-       $TEST_RUN_METHOD || exit 0
+       test-run || exit 0
        syntax-check || exit 0
        output-check || exit 0
        echo "Test completed OK ($POINTS_PER_TEST points)"
-       echo >$PTSFILE "$POINTS_PER_TEST OK"
+       echo >>$PTSFILE "$POINTS_PER_TEST OK"
        pend "OK"
        )
 done
diff --git a/bin/lib b/bin/lib
index 48c1a8f254d0b21f37344c7589c67cef063accb1..2e805f8ccd6887d5835874c2874e179e04c98d36 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -93,7 +93,7 @@ EOF
 
 function locate-source
 {
-       pstart "Locating source... "
+       pstart "Finding source... "
        for a in $EXTENSIONS ; do
                if [ -f $SDIR/$PROBLEM.$a ] ; then
                        [ -z "$SRCN" ] || die "Multiple source files found: $SDIR/$PROBLEM.$a and $SDIR/$SRCN. Please fix."
@@ -128,6 +128,7 @@ function compile
 
        echo "Compiler input files:"
        ls -Al $BOXDIR
+       echo "Compiler output:"
        if ! $BOXCMD $COMP_SANDBOX_OPTS -- $CCMD 2>$TDIR/compile.out ; then
                COMPILE_MSG="`cat $TDIR/compile.out`"
                pend "FAILED: $COMPILE_MSG"
@@ -151,7 +152,7 @@ function compile
 
 # Running of test program with file input/output
 
-function test-run-with-files
+function test-run
 {
        pcont "<init> "
        box-clean
@@ -171,7 +172,7 @@ function test-run-with-files
                TEST_MSG="`cat $TDIR/exec.out`"
                pend "$TEST_MSG"
                echo "$TEST_MSG"
-               echo >$PTSFILE "0 $TEST_MSG"
+               echo >>$PTSFILE "0 $TEST_MSG"
                return 1
        fi
        cat $TDIR/exec.out
@@ -181,7 +182,7 @@ function test-run-with-files
        if [ ! -s $BOXDIR/$PROBLEM.out ] ; then
                pend "No output file."
                echo "No output file."
-               echo >$PTSFILE "0 No output."
+               echo >>$PTSFILE "0 No output."
                return 1
        fi
        cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out
@@ -198,7 +199,7 @@ function syntax-check
        $SCHECK && return 0
        pend "Wrong syntax."
        echo "Wrong syntax."
-       echo >$PTSFILE "0 Wrong syntax."
+       echo >>$PTSFILE "0 Wrong syntax."
        return 1
 }
 
@@ -213,6 +214,26 @@ function output-check
        $OCHECK && return 0
        pend "Wrong answer."
        echo "Wrong answer."
-       echo >$PTSFILE "0 Wrong answer."
+       echo >>$PTSFILE "0 Wrong answer."
        return 1
 }
+
+# Setup of public commands
+
+function public-setup
+{
+       PDIR=$MO_PUBLIC/problems/$PROBLEM
+       SDIR=.
+       TDIR=~/.test
+       [ -d $PDIR ] || die "Unknown problem $PROBLEM"
+
+       pstart "Initializing... "
+       mkdir -p $TDIR
+       rm -rf $TDIR/*
+       BOXDIR=~/.box
+       mkdir -p $BOXDIR
+       rm -rf $BOXDIR/*
+       BOXCMD="$MO_PUBLIC/bin/box -c$BOXDIR"
+       exec >log
+       pend "OK  (see 'log' for details)"
+}
diff --git a/config b/config
index edc6da2a3023c021845404b5545d1d4d99190386..07a1370ede7f72add0c5bc89730d656a282a6490 100644 (file)
--- a/config
+++ b/config
@@ -25,9 +25,6 @@ COMP_pas="$COMP_p"
 # Sandbox options used when compiling
 COMP_SANDBOX_OPTS='-m65536 -t60 -w -e'
 
-# Shell command used to run the tests
-TEST_RUN_METHOD="test-run-with-files"
-
 # Sandbox options used when testing
 TEST_SANDBOX_OPTS='-a2 -f -m$MEM_LIMIT -t$TIME_LIMIT -w'
 # For stdio tasks append '-i$PROBLEM.in -o$PROBLEM.out'
index 9bcc2bc2602e6a3e712fc8e8808b4a923ae790f6..cab1bc200e2d4c0106ad3aa4ff01faa145ddb4b4 100644 (file)
@@ -4,6 +4,9 @@
 # A list of all tests
 TESTS="1 2"
 
+# Test with example input
+SAMPLE_TEST=1
+
 # Number of points per test
 POINTS_PER_TEST=1
 
diff --git a/public/check b/public/check
new file mode 100644 (file)
index 0000000..37fce30
--- /dev/null
@@ -0,0 +1,20 @@
+# The Evaluator -- Public Checking Script
+# (c) 2001 Martin Mares <mj@ucw.cz>
+
+set -e
+[ -n "$MO_PUBLIC" -a -d "$MO_PUBLIC" ] || { echo >&2 "MO_PUBLIC not set, giving up." ; exit 1 ; }
+. $MO_PUBLIC/bin/lib
+. $MO_PUBLIC/config
+
+[ -n "$1" ] || die "Usage: check <problem>"
+PROBLEM=$1
+public-setup
+. $PDIR/config
+locate-source
+compile
+TEST=$SAMPLE_TEST
+PTSFILE=$TDIR/points
+pstart "Checking on sample input: "
+test-run
+syntax-check
+pend "OK"
diff --git a/public/compile b/public/compile
new file mode 100644 (file)
index 0000000..b640c89
--- /dev/null
@@ -0,0 +1,19 @@
+# The Evaluator -- Public Compilation Script
+# (c) 2001 Martin Mares <mj@ucw.cz>
+
+set -e
+[ -n "$MO_PUBLIC" -a -d "$MO_PUBLIC" ] || { echo >&2 "MO_PUBLIC not set, giving up." ; exit 1 ; }
+. $MO_PUBLIC/bin/lib
+. $MO_PUBLIC/config
+
+[ -n "$1" ] || die "Usage: compile <problem>"
+PROBLEM=$1
+public-setup
+. $PDIR/config
+locate-source
+if compile ; then
+       mv $TDIR/$PROBLEM .
+else
+       echo >&2
+       sed <log >&2 '1,/^Compiler output:/d;/^Compiler output files:/,$d;/^Exited /d'
+fi
diff --git a/public/submit b/public/submit
new file mode 100644 (file)
index 0000000..15dd217
--- /dev/null
@@ -0,0 +1,25 @@
+# The Evaluator -- Public Submit Script
+# (c) 2001 Martin Mares <mj@ucw.cz>
+
+set -e
+[ -n "$MO_PUBLIC" -a -d "$MO_PUBLIC" ] || { echo >&2 "MO_PUBLIC not set, giving up." ; exit 1 ; }
+. $MO_PUBLIC/bin/lib
+. $MO_PUBLIC/config
+
+[ -n "$1" ] || die "Usage: submit <problem>"
+PROBLEM=$1
+public-setup
+. $PDIR/config
+locate-source
+compile
+TEST=$SAMPLE_TEST
+PTSFILE=$TDIR/points
+pstart "Checking on sample input: "
+test-run
+syntax-check
+pend "OK"
+pstart "Submiting: "
+mkdir -p ~/.submit/$PROBLEM
+rm -rf ~/.submit/$PROBLEM/*
+cp $SRCN ~/.submit/$PROBLEM/
+pend "OK"