]> mj.ucw.cz Git - eval.git/blobdiff - bin/lib
Renamed log() to msg() in order to avoid compiler warnings.
[eval.git] / bin / lib
diff --git a/bin/lib b/bin/lib
index faf6d038d830561453d4a53395beaae29a398f4f..237a89139141f97ee4d9608cd9e00c92faa4d210 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -44,6 +44,11 @@ function fatal
        exit 1
 }
 
+function try-ln
+{
+       ln $1 $2 2>/dev/null || cp $1 $2
+}
+
 # Sandbox subroutines
 
 function box-init
@@ -220,12 +225,12 @@ function test-prolog
        OUT_TYPE=${OUT_TYPE:-$IO_TYPE}
        case $IN_TYPE in
                file)   echo "Input file: $PROBLEM.in (from $PDIR/$TEST.in)"
-                       ln $PDIR/$TEST.in $TDIR/$TEST.in
+                       try-ln $PDIR/$TEST.in $TDIR/$TEST.in
                        cp $PDIR/$TEST.in $BOXDIR/$PROBLEM.in
-                       BOX_EXTRAS="$BOX_EXTRAS -i/dev/null"
+                       [ $TASK_TYPE == interactive ] || BOX_EXTRAS="$BOX_EXTRAS -i/dev/null"
                        ;;
                stdio)  echo "Input file: <stdin> (from $PDIR/$TEST.in)"
-                       ln $PDIR/$TEST.in $TDIR/$TEST.in
+                       try-ln $PDIR/$TEST.in $TDIR/$TEST.in
                        cp $PDIR/$TEST.in $BOXDIR/.stdin
                        BOX_EXTRAS="$BOX_EXTRAS -i.stdin"
                        ;;
@@ -236,7 +241,7 @@ function test-prolog
        esac
        case $OUT_TYPE in
                file)   echo "Output file: $PROBLEM.out"
-                       BOX_EXTRAS="$BOX_EXTRAS -o/dev/null"
+                       [ $TASK_TYPE == interactive ] || BOX_EXTRAS="$BOX_EXTRAS -o/dev/null"
                        ;;
                stdio)  echo "Output file: <stdout>"
                        BOX_EXTRAS="$BOX_EXTRAS -o.stdout"
@@ -296,7 +301,7 @@ function test-run-interactive
        echo "Interactive checker: $ICCMD"
        if ! $HDIR/bin/iwrapper $BOXCMD $BOXOPTS -- ./$PROBLEM @@ $ICCMD 2>$TMPDIR/exec.out ; then
                cat $TMPDIR/exec.out
-               MSG="`tail -1 $TMPDIR/exec.out`"
+               MSG="`head -1 $TMPDIR/exec.out`"
                test-result 0 "$MSG"
        fi
        cat $TMPDIR/exec.out
@@ -324,19 +329,21 @@ function syntax-check
 
 function output-check
 {
-       [ -n "$OUTPUT_CHECK" ] || return 0
-       pcont "<check> "
-       [ -f $PDIR/$TEST.out ] && ln $PDIR/$TEST.out $TDIR/$TEST.ok
-       OCHECK=`eval echo $OUTPUT_CHECK`
-       echo "Output check command: $OCHECK"
-       if ! eval $OCHECK 2>$TMPDIR/exec.out ; then
+       MSG=
+       if [ -n "$OUTPUT_CHECK" -a "$OUT_TYPE" != none ] ; then
+               pcont "<check> "
+               [ -f $PDIR/$TEST.out ] && ln $PDIR/$TEST.out $TDIR/$TEST.ok
+               OCHECK=`eval echo $OUTPUT_CHECK`
+               echo "Output check command: $OCHECK"
+               if ! eval $OCHECK 2>$TMPDIR/exec.out ; then
+                       cat $TMPDIR/exec.out
+                       MSG=`tail -1 $TMPDIR/exec.out`
+                       if [ -z "$MSG" ] ; then MSG="Wrong answer." ; fi
+                       test-result 0 "$MSG"
+               fi
                cat $TMPDIR/exec.out
                MSG=`tail -1 $TMPDIR/exec.out`
-               if [ -z "$MSG" ] ; then MSG="Wrong answer." ; fi
-               test-result 0 "$MSG"
        fi
-       cat $TMPDIR/exec.out
-       MSG=`tail -1 $TMPDIR/exec.out`
        if [ -z "$MSG" ] ; then MSG="OK" ; fi
        test-result $POINTS_PER_TEST "$MSG"
 }