X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=public%2Fcheck;h=6a8012f2bcfefee60ab3c2c174d8cba91a867614;hb=65517c0cd75d3c846d8e8304c414e9d63d155ecc;hp=fee56b67666d2cce99a791eae322de66eb539bba;hpb=bda1c385638cb870492497a118557d7240975e0a;p=moe.git diff --git a/public/check b/public/check old mode 100644 new mode 100755 index fee56b6..6a8012f --- a/public/check +++ b/public/check @@ -1,21 +1,71 @@ +#!/bin/bash # The Evaluator -- Public Checking Script -# (c) 2001 Martin Mares +# (c) 2001--2008 Martin Mares 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 " +function usage +{ + die "Usage: check [-s ] []" +} + +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 -locate-source -compile -PTSFILE=$TDIR/points -for TEST in $SAMPLE_TESTS ; do - pstart "Checking on sample input $TEST: " - test-run + +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: " + test-config + open-locate "$SRCFILE" + try-ln "$SDIR/$SRCN" $TDIR/$TEST.out syntax-check - pend "OK" -done + test-result $POINTS_PER_TEST OK +else + [ -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-config + test-run + syntax-check + output-check + ) || RC=1 + done + exit $RC +fi