From: Martin Mares Date: Thu, 29 Mar 2001 18:15:15 +0000 (+0000) Subject: Basically works. X-Git-Tag: python-dummy-working~536 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=666506e10535397d92733c7b6df0421c18708d04;p=moe.git Basically works. --- diff --git a/TODO b/TODO index fab6f88..d9fbb87 100644 --- a/TODO +++ b/TODO @@ -1,2 +1,4 @@ submit, compile, test (submit bez odevzdani) +check pascal +-static ? quotas diff --git a/bin/ev b/bin/ev index c25f97a..0a462bf 100755 --- a/bin/ev +++ b/bin/ev @@ -31,21 +31,18 @@ compile # Perform the tests for TEST in $TESTS ; do ( - pstart "Test $TEST... " [ -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)" - if [ ! -f $TDIR/compile.out ] ; then - echo >$PTSFILE "0 --" - die "No source file" - fi if [ ! -f $TDIR/$PROBLEM ] ; then - echo >$PTSFILE "0 CE" + echo >$PTSFILE "0 Compile error." die "No executable file" fi $TEST_RUN_METHOD || exit 0 - + syntax-check || exit 0 + output-check || exit 0 echo "Test completed OK ($POINTS_PER_TEST points)" echo >$PTSFILE "$POINTS_PER_TEST OK" pend "OK" diff --git a/bin/lib b/bin/lib index 090e752..e61cce2 100644 --- a/bin/lib +++ b/bin/lib @@ -59,7 +59,6 @@ function box-init function box-clean { [ -n "$BOXCMD" ] || die "box-init not called" - # FIXME: Dot files rm -rf $BOXDIR/* } @@ -133,6 +132,7 @@ function compile return 1 fi cat $TDIR/compile.out + rm $TDIR/compile.out echo "Compiler output files:" ls -Al $BOXDIR if [ ! -f $BOXDIR/$PROBLEM ] ; then @@ -168,17 +168,48 @@ function test-run-with-files TEST_MSG="`cat $TDIR/exec.out`" pend "$TEST_MSG" echo "$TEST_MSG" - # FIXME: Better recognition of run-time errors - echo >$PTSFILE "0 RT" + echo >$PTSFILE "0 $TEST_MSG" return 1 fi + cat $TDIR/exec.out + rm $TDIR/exec.out echo "Output files:" ls -Al $BOXDIR - if [ ! -f $BOXDIR/$PROBLEM.out ] ; then + if [ ! -s $BOXDIR/$PROBLEM.out ] ; then pend "No output file." echo "No output file." - echo >$PTSFILE "0 NO" + echo >$PTSFILE "0 No output." return 1 fi - cp $BOXDIR/$PROBLEM.out $TDIR/$PROBLEM.out + cp $BOXDIR/$PROBLEM.out $TDIR/$TEST.out +} + +# Syntax checks + +function syntax-check +{ + [ -n "$SYNTAX_CHECK" ] || return 0 + pcont " " + SCHECK="`eval echo $SYNTAX_CHECK`" + echo "Syntax check command: $SCHECK" + $SCHECK && return 0 + pend "Wrong syntax." + echo "Wrong syntax." + echo >$PTSFILE "0 Wrong syntax." + return 1 +} + +# Output checks + +function output-check +{ + pcont " " + ln $PDIR/$TEST.out $TDIR/$TEST.ok + OCHECK="`eval echo $OUTPUT_CHECK`" + echo "Output check command: $OCHECK" + $OCHECK && return 0 + pend "Wrong answer." + echo "Wrong answer." + echo >$PTSFILE "0 Wrong answer." + return 1 } diff --git a/config b/config index 8115ea5..edc6da2 100644 --- a/config +++ b/config @@ -10,15 +10,24 @@ TEST_USERS="mo-test1 mo-test2" # Currently used test user TEST_USER=mo-eval -# Compilation commands +### all of the following variables can be overriden in per-task config file + +# Known source file extensions EXTENSIONS="c C cpp p pas" + +# For each source extension, we must give compiler command COMP_c='/usr/bin/gcc -o $EXE $SRC' COMP_C='/usr/bin/g++ -o $EXE $SRC' COMP_cpp="$COMP_C" COMP_p='/usr/bin/fpc -o $EXE $SRC' COMP_pas="$COMP_p" + +# Sandbox options used when compiling COMP_SANDBOX_OPTS='-m65536 -t60 -w -e' -# Testing commands +# 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 6cd4c6d..9bcc2bc 100644 --- a/examples/problems/sum/config +++ b/examples/problems/sum/config @@ -1,8 +1,23 @@ # Per-task config +# All variables can be overriden in test-specific .config +# A list of all tests TESTS="1 2" + +# Number of points per test POINTS_PER_TEST=1 + +# List of extra files needed for compilation EXTRAS="extras.h" -TEST_EXTRAS="extras.h" + +# Time limit in seconds TIME_LIMIT=10 + +# Memory limit in kilobytes MEM_LIMIT=16384 + +# Command used to check output syntax (optional) +SYNTAX_CHECK='grep -v -- - $TDIR/$TEST.out' + +# Command used to check output correctness +OUTPUT_CHECK='diff -bBu $TDIR/$TEST.ok $TDIR/$TEST.out' diff --git a/src/box.c b/src/box.c index 2558a3e..b76fd8a 100644 --- a/src/box.c +++ b/src/box.c @@ -35,6 +35,7 @@ static int use_wall_clock; static int file_access; static int verbose; static int memory_limit; +static char *redir_stdin, *redir_stdout; static pid_t box_pid; static int is_ptraced; @@ -419,6 +420,18 @@ box_inside(int argc, char **argv) memcpy(args, argv, argc * sizeof(char *)); args[argc] = NULL; + if (redir_stdin) + { + close(0); + if (open(redir_stdin, O_RDONLY) != 0) + die("open(\"%s\"): %m", redir_stdin); + } + if (redir_stdout) + { + close(1); + if (open(redir_stdout, O_WRONLY | O_CREAT | O_TRUNC, 0666) != 1) + die("open(\"%s\"): %m", redir_stdout); + } close(2); dup(1); setpgrp(); @@ -449,7 +462,9 @@ Options:\n\ -c \tChange directory to first\n\ -e\t\tPass full environment of parent process\n\ -f\t\tFilter system calls (-ff=very restricted)\n\ +-i \tRedirect stdin from \n\ -m \tLimit address space to KB\n\ +-o \tRedirect stdout to \n\ -t