]> mj.ucw.cz Git - eval.git/blobdiff - public/check
Rewritten measuring of time.
[eval.git] / public / check
old mode 100644 (file)
new mode 100755 (executable)
index ea6512d..152884d
@@ -1,32 +1,69 @@
+#!/bin/bash
 # The Evaluator -- Public Checking Script
-# (c) 2001 Martin Mares <mj@ucw.cz>
+# (c) 2001--2007 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 "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
+. $MO_ROOT/bin/lib
+. $MO_ROOT/config
 
-[ -n "$1" ] || die "Usage: check <problem> [<file>]"
+function usage
+{
+       die "Usage: check [-s <source-file>] <problem> [<test-number>]"
+}
+
+SRCFILE=
+while getopts "s:" opt ; do
+       case $opt in
+               s)      SRCFILE="$OPTARG"
+                       ;;
+               *)      usage
+                       ;;
+       esac
+done
+shift $(($OPTIND-1))
+[ -n "$1" ] || usage
 PROBLEM=$1
+TEST=
+shift
+if [ -n "$1" ] ; then
+       TEST="$1"
+       shift
+fi
+[ -z "$1" ] || usage
+
 public-setup
 . $PDIR/config
-PTSFILE=$TDIR/points
-if [ -n "$OPEN_DATA_PROBLEM" ] ; then
-       [ -n "$2" ] || die "You need to specify test number for open data problems."
-       TEST=$2
-       open-locate
+
+function test-verdict
+{
+       pend "$2"
+       if [ $1 == 0 ] ; then
+               exit 1
+       else
+               exit 0
+       fi
+}
+
+if [ $TASK_TYPE == open-data ] ; then
+       [ -n "$TEST" ] || die "You need to specify test number for open data problems."
        pstart "Checking $TEST: "
+       open-locate $SRCFILE
+       ln $SRCN $TDIR/$TEST.out
        syntax-check
-       pend "OK"
+       test-result 1 OK
 else
-       [ -z "$2" ] || die "No test number should be specified for normal problems."
-       locate-source
+       [ -z "$TEST" ] || die "Test number should be given only for open data problems."
+       locate-source $SRCFILE
        compile
+       RC=0
        for TEST in $SAMPLE_TESTS ; do
+               (
                pstart "Checking on sample input $TEST: "
                test-run
                syntax-check
                output-check
-               pend "OK"
+               ) || RC=1
        done
+       exit $RC
 fi