]> mj.ucw.cz Git - eval.git/blobdiff - bin/ev
Added checking of contest time.
[eval.git] / bin / ev
diff --git a/bin/ev b/bin/ev
index ed2dc6738f1d5ed68f59ecf950a45472290c2d7a..554e5dc874778df2d980539088e1d30365475242 100755 (executable)
--- a/bin/ev
+++ b/bin/ev
@@ -1,65 +1,52 @@
+#!/bin/bash
 # The Evaluator -- Master Control Script
-# (c) 2001 Martin Mares <mj@ucw.cz>
+# (c) 2001--2004 Martin Mares <mj@ucw.cz>
 
 set -e
-cd
+if [ ! -f config -o ! -f bin/lib ] ; then
+       echo "Unable to find evaluator files!"
+       exit 1
+fi
 . bin/lib
 . config
-[ -n "$TEST_USER" ] || die "TEST_USER not set. Please fix."
-[ -d $MO_ROOT/$TEST_USER ] || die "TEST_USER set incorrectly. Please fix."
-[ -n "$2" ] || die "Usage: ev <contestant> <problem>"
-CT=$1
-PROBLEM=$2
-. bin/lib
 
-# Initialize the testing directory
-echo >&2 "Testing contestant $CT, problem $PROBLEM"
-echo >&2
-PDIR=problems/$PROBLEM
-SDIR=solutions/$CT/$PROBLEM
-TDIR=testing/$CT/$PROBLEM
-. bin/task-init
+[ -n "$2" -a -z "$4" ] || die "Usage: ev <contestant> <problem> [<program>]"
+CONTESTANT=$1
+PROBLEM=$2
+dir-init
+log-init
 . $PDIR/config
+box-init
 
-# Set up logging
-exec >>$TDIR/log
-HAVE_LOG=1
+# Compile the program
+locate-source $3
+compile || true
 
-# Compile the solution
-( . bin/task-compile )
+# Initialize the points file
+PTSFILE=$TDIR/points
+>$PTSFILE
+
+function test-verdict
+{
+       if [ $1 == 0 ] ; then
+               pend "$2"
+       else
+               pend "$2 ($1 points)"
+       fi
+       echo >>$PTSFILE "$TEST $1 $2"
+       exit 0
+}
 
 # Perform the tests
 for TEST in $TESTS ; do
        (
-       pstart "Test $TEST: "
        [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config
        exec >$TDIR/$TEST.log
-       PTSFILE=$TDIR/$TEST.pts
-       if [ ! -f $TDIR/compile.out ] ; then
-               echo >$PTSFILE "0 --"
-               die "No source file"
-       fi
-       if [ ! -f $TDIR/$PROBLEM ] ; then
-               echo >$PTSFILE "0 CE"
-               die "No executable file"
-       fi
-       pcont "<init> "
-       box-init
-       echo "Executable file: $TDIR/$PROBLEM"
-       cp $TDIR/$PROBLEM $BOXDIR/
-       echo "Input: $TDIR/$PROBLEM"
-       cp $PDIR/$TEST.in $BOXDIR/$PROBLEM.in
-       echo "Input files:"
-       ls -Al $BOXDIR
-       echo "Timeout: $TIME_LIMIT s"
-       echo "Memory: $MEM_LIMIT KB"
-       BOXOPTS="`eval echo $TEST_SANDBOX_OPTS`"
-       echo "Sandbox options: $BOXOPTS"
-
-       pcont "<run> "
-
-       echo "Test completed OK ($POINTS_PER_TEST points)"
-       echo >$PTSFILE "$POINTS_PER_TEST OK"
-       pend "OK"
+       pstart "Test $TEST... "
+       echo "Test $TEST ($POINTS_PER_TEST points)"
+       test-run
+       syntax-check
+       output-check
+       die "You must never see this message."
        )
 done