]> mj.ucw.cz Git - moe.git/blob - eval/ev.sh
5750f0b64bc60168b47d71fcd09390cb023c3e45
[moe.git] / eval / ev.sh
1 #!/bin/bash
2 # The Evaluator -- Master Control Script
3 # (c) 2001--2008 Martin Mares <mj@ucw.cz>
4
5 set -e
6 if [ ! -f config -o ! -f lib/libeval.sh ] ; then
7         echo "Unable to find evaluator files!"
8         exit 1
9 fi
10 . lib/libeval.sh
11 . config
12 while parse-cmdline "$1" ; do
13         shift
14 done
15
16 [ -n "$2" -a -z "$4" ] || die "Usage: ev [<var>=<value>] <contestant> <problem> [<program>]"
17 CONTESTANT=$1
18 PROBLEM=$2
19 dir-init
20 log-init
21 . $PDIR/config
22 box-init
23
24 # Compile the program
25 if [ $TASK_TYPE != open-data ] ; then
26         locate-source `if [ -n "$3" ] ; then echo $SDIR/$3 ; fi`
27         compile || true
28 fi
29
30 # Initialize the points file
31 PTSFILE=$TDIR/points
32 >$PTSFILE
33
34 function test-verdict
35 {
36         if [ $1 == 0 ] ; then
37                 pend "$2"
38         else
39                 pend "$2 ($1 points)"
40         fi
41         echo >>$PTSFILE "$TEST $1 $2"
42         exit 0
43 }
44
45 # Perform the tests
46 [ -z "$EV_SAMPLE" ] || TESTS="$SAMPLE_TESTS $TESTS"
47 for TEST in $TESTS ; do
48         (
49         exec >$TDIR/$TEST.log
50         test-config
51         pstart "Test $TEST... "
52         echo "Test $TEST ($POINTS_PER_TEST points)"
53         test-run
54         syntax-check
55         output-check
56         die "You must never see this message."
57         )
58 done