X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=public%2Fcheck;h=152884d2aaf674806a742552a5c129c84910f407;hb=325264b9d0d300e7701a8c2df1300508f448ae0e;hp=ce9a86b9453622b16e15d7d7278a943dc02aef6e;hpb=0ef7fd9921eb6018b54793ced6592d15979edbc0;p=eval.git diff --git a/public/check b/public/check old mode 100644 new mode 100755 index ce9a86b..152884d --- a/public/check +++ b/public/check @@ -1,40 +1,69 @@ +#!/bin/bash # The Evaluator -- Public Checking Script -# (c) 2001--2004 Martin Mares +# (c) 2001--2007 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 function test-verdict { pend "$2" - exit 0 + if [ $1 == 0 ] ; then + exit 1 + else + exit 0 + fi } if [ $TASK_TYPE == open-data ] ; then - [ -n "$2" ] || die "You need to specify test number for open data problems." - TEST=$2 + [ -n "$TEST" ] || die "You need to specify test number for open data problems." pstart "Checking $TEST: " - open-locate + open-locate $SRCFILE ln $SRCN $TDIR/$TEST.out syntax-check test-result 1 OK else - [ -z "$2" ] || die "Test number should be given only for open data 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 - ) + ) || RC=1 done + exit $RC fi