X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=public%2Fcheck;h=51b627186acc3f5149338fdd7d50a4ceb7ed75d3;hb=e663f0222d8299a6b802cc35983858cfeca13a70;hp=ea6512da50b354fe89879a728611e0392aa77d8d;hpb=210b070496ef912a3b4745477b609b150b013d6b;p=eval.git diff --git a/public/check b/public/check old mode 100644 new mode 100755 index ea6512d..51b6271 --- a/public/check +++ b/public/check @@ -1,32 +1,71 @@ +#!/bin/bash # The Evaluator -- Public Checking Script -# (c) 2001 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 -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: " + [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config + open-locate "$SRCFILE" + try-ln "$SDIR/$SRCN" $TDIR/$TEST.out syntax-check - pend "OK" + test-result $POINTS_PER_TEST 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: " + [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config test-run syntax-check output-check - pend "OK" + ) || RC=1 done + exit $RC fi