From c119e07ea8001ba944e6d9c33e4e73f98fe750ee Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Thu, 29 Mar 2001 18:52:25 +0000 Subject: [PATCH] Added public scripts. --- TODO | 1 - bin/ev | 7 ++++--- bin/lib | 33 +++++++++++++++++++++++++++------ config | 3 --- examples/problems/sum/config | 3 +++ public/check | 20 ++++++++++++++++++++ public/compile | 19 +++++++++++++++++++ public/submit | 25 +++++++++++++++++++++++++ 8 files changed, 98 insertions(+), 13 deletions(-) create mode 100644 public/check create mode 100644 public/compile create mode 100644 public/submit diff --git a/TODO b/TODO index d9fbb87..e0ef740 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,3 @@ -submit, compile, test (submit bez odevzdani) check pascal -static ? quotas diff --git a/bin/ev b/bin/ev index 0a462bf..0ddd6d3 100755 --- a/bin/ev +++ b/bin/ev @@ -29,22 +29,23 @@ locate-source compile # Perform the tests +PTSFILE=$TDIR/points for TEST in $TESTS ; do ( [ -f $PDIR/$TEST.config ] && . $PDIR/$TEST.config exec >$TDIR/$TEST.log - PTSFILE=$TDIR/$TEST.pts pstart "Test $TEST ($POINTS_PER_TEST points)... " echo "Test $TEST ($POINTS_PER_TEST points)" + echo >>$PTSFILE -n "$TEST " if [ ! -f $TDIR/$PROBLEM ] ; then echo >$PTSFILE "0 Compile error." die "No executable file" fi - $TEST_RUN_METHOD || exit 0 + test-run || exit 0 syntax-check || exit 0 output-check || exit 0 echo "Test completed OK ($POINTS_PER_TEST points)" - echo >$PTSFILE "$POINTS_PER_TEST OK" + echo >>$PTSFILE "$POINTS_PER_TEST OK" pend "OK" ) done diff --git a/bin/lib b/bin/lib index 48c1a8f..2e805f8 100644 --- a/bin/lib +++ b/bin/lib @@ -93,7 +93,7 @@ EOF function locate-source { - pstart "Locating source... " + pstart "Finding source... " for a in $EXTENSIONS ; do if [ -f $SDIR/$PROBLEM.$a ] ; then [ -z "$SRCN" ] || die "Multiple source files found: $SDIR/$PROBLEM.$a and $SDIR/$SRCN. Please fix." @@ -128,6 +128,7 @@ function compile echo "Compiler input files:" ls -Al $BOXDIR + echo "Compiler output:" if ! $BOXCMD $COMP_SANDBOX_OPTS -- $CCMD 2>$TDIR/compile.out ; then COMPILE_MSG="`cat $TDIR/compile.out`" pend "FAILED: $COMPILE_MSG" @@ -151,7 +152,7 @@ function compile # Running of test program with file input/output -function test-run-with-files +function test-run { pcont " " box-clean @@ -171,7 +172,7 @@ function test-run-with-files TEST_MSG="`cat $TDIR/exec.out`" pend "$TEST_MSG" echo "$TEST_MSG" - echo >$PTSFILE "0 $TEST_MSG" + echo >>$PTSFILE "0 $TEST_MSG" return 1 fi cat $TDIR/exec.out @@ -181,7 +182,7 @@ function test-run-with-files if [ ! -s $BOXDIR/$PROBLEM.out ] ; then pend "No output file." echo "No output file." - echo >$PTSFILE "0 No output." + echo >>$PTSFILE "0 No output." return 1 fi cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out @@ -198,7 +199,7 @@ function syntax-check $SCHECK && return 0 pend "Wrong syntax." echo "Wrong syntax." - echo >$PTSFILE "0 Wrong syntax." + echo >>$PTSFILE "0 Wrong syntax." return 1 } @@ -213,6 +214,26 @@ function output-check $OCHECK && return 0 pend "Wrong answer." echo "Wrong answer." - echo >$PTSFILE "0 Wrong answer." + echo >>$PTSFILE "0 Wrong answer." return 1 } + +# Setup of public commands + +function public-setup +{ + PDIR=$MO_PUBLIC/problems/$PROBLEM + SDIR=. + TDIR=~/.test + [ -d $PDIR ] || die "Unknown problem $PROBLEM" + + pstart "Initializing... " + mkdir -p $TDIR + rm -rf $TDIR/* + BOXDIR=~/.box + mkdir -p $BOXDIR + rm -rf $BOXDIR/* + BOXCMD="$MO_PUBLIC/bin/box -c$BOXDIR" + exec >log + pend "OK (see 'log' for details)" +} diff --git a/config b/config index edc6da2..07a1370 100644 --- a/config +++ b/config @@ -25,9 +25,6 @@ COMP_pas="$COMP_p" # Sandbox options used when compiling COMP_SANDBOX_OPTS='-m65536 -t60 -w -e' -# Shell command used to run the tests -TEST_RUN_METHOD="test-run-with-files" - # Sandbox options used when testing TEST_SANDBOX_OPTS='-a2 -f -m$MEM_LIMIT -t$TIME_LIMIT -w' # For stdio tasks append '-i$PROBLEM.in -o$PROBLEM.out' diff --git a/examples/problems/sum/config b/examples/problems/sum/config index 9bcc2bc..cab1bc2 100644 --- a/examples/problems/sum/config +++ b/examples/problems/sum/config @@ -4,6 +4,9 @@ # A list of all tests TESTS="1 2" +# Test with example input +SAMPLE_TEST=1 + # Number of points per test POINTS_PER_TEST=1 diff --git a/public/check b/public/check new file mode 100644 index 0000000..37fce30 --- /dev/null +++ b/public/check @@ -0,0 +1,20 @@ +# The Evaluator -- Public Checking Script +# (c) 2001 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 "$1" ] || die "Usage: check " +PROBLEM=$1 +public-setup +. $PDIR/config +locate-source +compile +TEST=$SAMPLE_TEST +PTSFILE=$TDIR/points +pstart "Checking on sample input: " +test-run +syntax-check +pend "OK" diff --git a/public/compile b/public/compile new file mode 100644 index 0000000..b640c89 --- /dev/null +++ b/public/compile @@ -0,0 +1,19 @@ +# The Evaluator -- Public Compilation Script +# (c) 2001 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 "$1" ] || die "Usage: compile " +PROBLEM=$1 +public-setup +. $PDIR/config +locate-source +if compile ; then + mv $TDIR/$PROBLEM . +else + echo >&2 + sed &2 '1,/^Compiler output:/d;/^Compiler output files:/,$d;/^Exited /d' +fi diff --git a/public/submit b/public/submit new file mode 100644 index 0000000..15dd217 --- /dev/null +++ b/public/submit @@ -0,0 +1,25 @@ +# The Evaluator -- Public Submit Script +# (c) 2001 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 "$1" ] || die "Usage: submit " +PROBLEM=$1 +public-setup +. $PDIR/config +locate-source +compile +TEST=$SAMPLE_TEST +PTSFILE=$TDIR/points +pstart "Checking on sample input: " +test-run +syntax-check +pend "OK" +pstart "Submiting: " +mkdir -p ~/.submit/$PROBLEM +rm -rf ~/.submit/$PROBLEM/* +cp $SRCN ~/.submit/$PROBLEM/ +pend "OK" -- 2.39.5