]> mj.ucw.cz Git - moe.git/blob - public/check
`md5crypt' now uses MD5 from libucw.
[moe.git] / public / check
1 #!/bin/bash
2 # The Evaluator -- Public Checking Script
3 # (c) 2001--2008 Martin Mares <mj@ucw.cz>
4
5 set -e
6 [ -n "$MO_ROOT" -a -d "$MO_ROOT" ] || { echo >&2 "MO_ROOT not set, giving up." ; exit 1 ; }
7 . $MO_ROOT/bin/lib
8 . $MO_ROOT/config
9
10 function usage
11 {
12         die "Usage: check [-s <source-file>] <problem> [<test-number>]"
13 }
14
15 SRCFILE=
16 while getopts "s:" opt ; do
17         case $opt in
18                 s)      SRCFILE="$OPTARG"
19                         ;;
20                 *)      usage
21                         ;;
22         esac
23 done
24 shift $(($OPTIND-1))
25 [ -n "$1" ] || usage
26 PROBLEM=$1
27 TEST=
28 shift
29 if [ -n "$1" ] ; then
30         TEST="$1"
31         shift
32 fi
33 [ -z "$1" ] || usage
34
35 public-setup
36 . $PDIR/config
37
38 function test-verdict
39 {
40         pend "$2"
41         if [ $1 == 0 ] ; then
42                 exit 1
43         else
44                 exit 0
45         fi
46 }
47
48 if [ $TASK_TYPE == open-data ] ; then
49         [ -n "$TEST" ] || die "You need to specify test number for open data problems."
50         pstart "Checking $TEST: "
51         test-config
52         open-locate "$SRCFILE"
53         try-ln "$SDIR/$SRCN" $TDIR/$TEST.out
54         syntax-check
55         test-result $POINTS_PER_TEST OK
56 else
57         [ -z "$TEST" ] || die "Test number should be given only for open data problems."
58         locate-source "$SRCFILE"
59         compile
60         RC=0
61         for TEST in $SAMPLE_TESTS ; do
62                 (
63                 pstart "Checking on sample input $TEST: "
64                 test-config
65                 test-run
66                 syntax-check
67                 output-check
68                 ) || RC=1
69         done
70         exit $RC
71 fi