X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=eval%2Flibeval.sh;h=676dbef399f3b6ea2ddd5df1029ef95c747b694c;hb=28d1cfeba6612733f7626aa9fa6163a2a6970bf6;hp=852bca86efbe5176451e231762e40ef5339f4df0;hpb=77ea607d3756e358a35e669b3bc2236027d5bf1e;p=eval.git diff --git a/eval/libeval.sh b/eval/libeval.sh index 852bca8..676dbef 100644 --- a/eval/libeval.sh +++ b/eval/libeval.sh @@ -111,11 +111,12 @@ function box-clean function dir-init { pstart "Initializing... " - HDIR=. - PDIR=problems/$PROBLEM - SDIR=solutions/$CONTESTANT/$PROBLEM - TDIR=testing/$CONTESTANT/$PROBLEM - TMPDIR=tmp + [ -z "$HDIR" ] && HDIR=. + PDIR=$HDIR/problems/$PROBLEM + SDIR=$HDIR/solutions/$CONTESTANT/$PROBLEM + TDIR=$HDIR/testing/$CONTESTANT/$PROBLEM + TMPDIR=$HDIR/tmp/ + [ -d $PDIR ] || die "Problem $PROBLEM not known" [ -d $SDIR ] || fatal "Solution of $PROBLEM not found" mkdir -p $TDIR $TMPDIR @@ -124,6 +125,7 @@ function dir-init cat >$TDIR/log </dev/null` || SG= [ -z "$SG" ] || M="$M (SIG$SG)" fi # Translate runtime errors to readable strings RE=${M#Exited with error status } if [ -n "$EXIT_CODE_HOOK" -a "$RE" != "$M" ] ; then - NEWMSG=`$EXIT_CODE_HOOK $RE` + NEWMSG=`$EXIT_CODE_HOOK $RE` || NEWMSG= if [ -n "$NEWMSG" ] ; then M="Runtime error $RE: $NEWMSG" fi @@ -303,6 +305,15 @@ function test-prolog ;; none) echo "Input file: " ;; + dir) echo "Input file: files in directory $PDIR/$TEST.in/" + [ -d $PDIR/$TEST.in ] || die "Not a directory: $PDIR/$TEST.in" + # TODO: recursive ln to $TDIR + cp -r $PDIR/$TEST.in $TDIR/$TEST.in + cp -r $PDIR/$TEST.in/* $BOXDIR/ + # Can have .stdin, but empty by default + touch $BOXDIR/.stdin + BOX_EXTRAS="$BOX_EXTRAS -i.stdin" + ;; *) die "Unknown IN_TYPE $IN_TYPE" ;; esac @@ -380,7 +391,10 @@ function test-run-file pcont " " BOXOPTS=$(expand-var TEST_SANDBOX_OPTS) echo "Sandbox options: $BOXOPTS" - if ! $BOXCMD $BOXOPTS -- ./$PROBLEM 2>$TMPDIR/exec.out ; then + EXECMD=$(expand-var TEST_EXEC_CMD) + [ -z "$EXECMD" ] || echo "Exec command: $EXECMD" + [ -z "$EXECMD" ] && EXECMD="./$PROBLEM" + if ! $BOXCMD $BOXOPTS -- $EXECMD 2>$TMPDIR/exec.out ; then cat $TMPDIR/exec.out MSG=`tail -1 $TMPDIR/exec.out` test-result 0 "$MSG" @@ -399,7 +413,10 @@ function test-run-interactive echo "Sandbox options: $BOXOPTS" ICCMD=$(expand-var IA_CHECK) echo "Interactive checker: $ICCMD" - if ! $HDIR/bin/iwrapper $BOXCMD $BOXOPTS -- ./$PROBLEM @@ $ICCMD 2>$TMPDIR/exec.out ; then + EXECMD=$(expand-var TEST_EXEC_CMD) + [ -z "$EXECMD" ] || echo "Exec command: $EXECMD" + [ -z "$EXECMD" ] && EXECMD="./$PROBLEM" + if ! $HDIR/bin/iwrapper $BOXCMD $BOXOPTS -- $EXECMD @@ $ICCMD 2>$TMPDIR/exec.out ; then cat $TMPDIR/exec.out MSG="`head -1 $TMPDIR/exec.out`" test-result 0 "$MSG" @@ -413,7 +430,7 @@ function test-run-interactive function test-run-open-data { [ -f $SDIR/$TEST.out ] || test-result 0 "No solution" - ln $SDIR/$TEST.out $TDIR/$TEST.out + try-ln $SDIR/$TEST.out $TDIR/$TEST.out } # Syntax checks @@ -441,7 +458,7 @@ function output-check MSG= if [ -n "$OUTPUT_CHECK" -a "$OUT_TYPE" != none -a -z "$EV_NOCHECK" ] ; then pcont " " - [ -f $PDIR/$TEST.out ] && ln $PDIR/$TEST.out $TDIR/$TEST.ok + [ -f $PDIR/$TEST.out ] && try-ln $PDIR/$TEST.out $TDIR/$TEST.ok OCHECK=$(expand-var OUTPUT_CHECK) echo "Output check command: $OCHECK" if ! eval $OCHECK 2>$TMPDIR/exec.out ; then