submit, compile, test (submit bez odevzdani)
+check pascal
+-static ?
quotas
# 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"
function box-clean
{
[ -n "$BOXCMD" ] || die "box-init not called"
- # FIXME: Dot files
rm -rf $BOXDIR/*
}
return 1
fi
cat $TDIR/compile.out
+ rm $TDIR/compile.out
echo "Compiler output files:"
ls -Al $BOXDIR
if [ ! -f $BOXDIR/$PROBLEM ] ; then
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 "<syntax> "
+ 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 "<check> "
+ 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
}
# 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'
# Per-task config
+# All variables can be overriden in test-specific <test>.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'
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;
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();
-c <dir>\tChange directory to <dir> first\n\
-e\t\tPass full environment of parent process\n\
-f\t\tFilter system calls (-ff=very restricted)\n\
+-i <file>\tRedirect stdin from <file>\n\
-m <size>\tLimit address space to <size> KB\n\
+-o <file>\tRedirect stdout to <file>\n\
-t <time>\tStop after <time> seconds\n\
-v\t\tBe verbose\n\
-w\t\tMeasure wall clock time instead of run time\n\
uid_t uid;
char *cwd = NULL;
- while ((c = getopt(argc, argv, "a:c:efm:t:vw")) >= 0)
+ while ((c = getopt(argc, argv, "a:c:efi:m:o:t:vw")) >= 0)
switch (c)
{
case 'a':
case 'f':
filter_syscalls++;
break;
+ case 'i':
+ redir_stdin = optarg;
+ break;
case 'm':
memory_limit = atol(optarg);
break;
+ case 'o':
+ redir_stdout = optarg;
+ break;
case 't':
timeout = atol(optarg);
break;