X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=bin%2Flib;h=9c49f9e9fac26982925a13ab61c9df97b490f978;hb=d99e7d3fac37d35fa3e4b688e91f40f4af4ae70f;hp=b912be78b49eb3dd7d80079838faf8188d82391d;hpb=6493c533ffbb60605df2c8cbbb0a3493f8431bba;p=moe.git diff --git a/bin/lib b/bin/lib index b912be7..9c49f9e 100644 --- a/bin/lib +++ b/bin/lib @@ -208,6 +208,31 @@ function test-result P=`cat $TDIR/$TEST.pts` rm $TDIR/$TEST.pts fi + + # Translate signal numbers to readable strings + SG=${M#Caught fatal signal } + SG=${SG#Committed suicide by signal } + if [ "$SG" != "$M" ] ; then + SG=`perl -MConfig -e '@s=split / /,$Config{sig_name}; print $s[$ARGV[0]]' $SG` + [ -z "$SG" ] || M="$M (SIG$SG)" + fi + + # Translate Free Pascal runtime errors to readable strings + RE=${M#Exited with error status } + if [ "$FREE_PASCAL_RTE" == 1 -a "$RE" != "$M" ] ; then + N="Runtime error $RE" + case "$RE" in + 200) M="$N: Division by zero" ;; + 201) M="$N: Range check error" ;; + 202) M="$N: Stack overflow" ;; + 203) M="$N: Heap overflow" ;; + 205) M="$N: Floating point overflow" ;; + 215) M="$N: Arithmetic overflow" ;; + 216) M="$N: Segmentation fault" ;; + ???) M="$N" ;; + esac + fi + echo "Verdict: $M" echo "Points: $P" test-verdict $P "$M" @@ -219,7 +244,7 @@ function test-prolog box-clean echo "Executable file: $TDIR/$PROBLEM" if [ ! -x $TDIR/$PROBLEM ] ; then - test-result 0 "Compile error." + test-result 0 "Compile error" fi cp $TDIR/$PROBLEM $BOXDIR/ BOX_EXTRAS= @@ -243,7 +268,15 @@ function test-prolog esac if [ -n "$EV_PEDANT" -a $IN_TYPE != none ] ; then pcont " " - bin/pedant <$TDIR/$TEST.in | tr '\n' ' ' >&2 + if [ "$EV_PEDANT" = 1 ] ; then + EV_PEDANT=" " + fi + bin/pedant <$TDIR/$TEST.in >$TDIR/$TEST.pedant $EV_PEDANT + if [ -s $TDIR/$TEST.pedant ] ; then + pend + sed 's/^/\t/' <$TDIR/$TEST.pedant >&2 + pstart -e '\t' + fi fi case $OUT_TYPE in file) echo "Output file: $PROBLEM.out" @@ -269,13 +302,27 @@ function test-epilog echo "Sandbox contents after exit:" ls -Al $BOXDIR case ${OUT_TYPE:-$IO_TYPE} in - file) [ -f $BOXDIR/$PROBLEM.out ] || test-result 0 "No output file." + file) [ -f $BOXDIR/$PROBLEM.out ] || test-result 0 "No output file" cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out ;; - stdio) [ -f $BOXDIR/.stdout ] || test-result 0 "No output file." + stdio) [ -f $BOXDIR/.stdout ] || test-result 0 "No output file" cp $BOXDIR/.stdout $TDIR/$TEST.out ;; esac + + if [ -n "$OUTPUT_FILTER" -a "$OUT_TYPE" != none -a -z "$EV_NOFILTER" ] ; then + pcont " " + FILTER=`eval echo \"$OUTPUT_FILTER\"` + echo "Output filter command: $FILTER" + mv $TDIR/$TEST.out $TDIR/$TEST.raw + if ! eval $FILTER 2>$TMPDIR/exec.out ; then + cat $TMPDIR/exec.out + MSG=`tail -1 $TMPDIR/exec.out` + if [ -z "$MSG" ] ; then MSG="Filter failed" ; fi + test-result 0 "$MSG" + fi + cat $TMPDIR/exec.out + fi } # Running of test program with file input/output @@ -314,6 +361,14 @@ function test-run-interactive test-epilog } +# "Running" of open-data problems + +function test-run-open-data +{ + [ -f $SDIR/$TEST.out ] || test-result 0 "No solution" + ln $SDIR/$TEST.out $TDIR/$TEST.out +} + # Syntax checks function syntax-check @@ -321,12 +376,12 @@ function syntax-check [ -n "$SYNTAX_CHECK" ] || return 0 [ -z "$EV_NOCHECK" ] || return 0 pcont " " - SCHECK=`eval echo $SYNTAX_CHECK` + SCHECK=`eval echo \"$SYNTAX_CHECK\"` echo "Syntax check command: $SCHECK" if ! eval $SCHECK 2>$TMPDIR/exec.out ; then cat $TMPDIR/exec.out MSG=`tail -1 $TMPDIR/exec.out` - if [ -z "$MSG" ] ; then MSG="Wrong syntax." ; fi + if [ -z "$MSG" ] ; then MSG="Wrong syntax" ; fi test-result 0 "$MSG" fi cat $TMPDIR/exec.out @@ -340,12 +395,12 @@ function output-check 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 - OCHECK=`eval echo $OUTPUT_CHECK` + 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 + if [ -z "$MSG" ] ; then MSG="Wrong answer" ; fi test-result 0 "$MSG" fi cat $TMPDIR/exec.out @@ -389,5 +444,5 @@ function open-locate else SRCN=$SDIR/$PROBLEM$TEST.out fi - [ -f $SRCN ] || fatal "Output file $SRCN not found" + [ -f "$SDIR/$SRCN" ] || fatal "Output file $SRCN not found" }