]> mj.ucw.cz Git - eval.git/commitdiff
Judges now compile and they use build/tester for the tests.
authorMartin Mares <mj@ucw.cz>
Thu, 15 May 2008 09:56:25 +0000 (11:56 +0200)
committerMartin Mares <mj@ucw.cz>
Thu, 15 May 2008 09:56:25 +0000 (11:56 +0200)
.gitignore
Makefile
TODO
judge/Makefile
judge/filter-cmt.t
judge/io.t
judge/judge-tok.t
judge/tester [deleted file]
judge/token.t

index 4b9f334ebf80a2167bb9867c9da648a9cacb0a01..d9524f1af0f13591a0a655712fd5102ac3b1d4e0 100644 (file)
@@ -1,12 +1,6 @@
-bin/box
-bin/pedant
-bin/iwrapper
-bin/md5crypt
-box
 certs
 problems
 solutions
 testing
 tmp
 userlist
-src/syscall-table.h
index af3658aba8866caf73a14fe0a512d2b56305f094..79a1193d1cdf41cdb6bd2a6d19cbdb3ced0bd7b2 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -19,11 +19,14 @@ include $(s)/build/Maketop
 ifdef CONFIG_UCW_LIBS
 include $(s)/lib/Makefile
 include $(s)/sherlock/Makefile
+# Disable built-in tests of these libraries
+TESTS=
 endif
 
 include $(s)/box/Makefile
 include $(s)/utils/Makefile
 include $(s)/eval/Makefile
+include $(s)/judge/Makefile
 
 # And finally the default rules of the build system
 include $(s)/build/Makebottom
diff --git a/TODO b/TODO
index 32173204274c5d193fda9f74fe23d6496ff1bbaa..f709cdfe8768aec8806685395978d86b1c1b903c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,3 +1,5 @@
+Convert md5crypt to use MD5 from libucw
+
 Evaluator
 ~~~~~~~~~
 score: better formatting of the score table
index 1478b496aa798ba80a546bea212201dc9678fa73..e9adf41e5c33505024262f52f9aff83b4f8464d9 100644 (file)
@@ -1,30 +1,16 @@
-#CC=gcc-4.1.1
-CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Wundef -Wredundant-decls -Winline $(DEBUG) -std=gnu99
-CFLAGS+=-Wno-pointer-sign -Wdisabled-optimization -Wno-missing-field-initializers
+# Makefile for MO-Eval judges
+# (c) 2008 Martin Mares <mj@ucw.cz>
 
-all: test-io test-tok judge-tok judge-shuff filter-cmt
+DIRS+=judge
+JDIR=$(o)/judge
+PROGS+=$(addprefix $(JDIR)/,test-io test-tok judge-tok judge-shuff filter-cmt)
+JLIB=$(addprefix $(o)/judge/,utils.o io.o token.o)
 
-JLIB=utils.o io.o token.o
+$(JDIR)/test-io: $(JDIR)/test-io.o $(JLIB)
+$(JDIR)/test-tok: $(JDIR)/test-tok.o $(JLIB)
+$(JDIR)/judge-tok: $(JDIR)/judge-tok.o $(JLIB)
+$(JDIR)/judge-tok: LDLIBS+=-lm
+$(JDIR)/judge-shuff: $(JDIR)/judge-shuff.o $(JLIB)
+$(JDIR)/filter-cmt: $(JDIR)/filter-cmt.o $(JLIB)
 
-test-io: test-io.o $(JLIB)
-test-tok: test-tok.o $(JLIB)
-judge-tok: judge-tok.o $(JLIB)
-judge-tok: LDLIBS+=-lm
-judge-shuff: judge-shuff.o $(JLIB)
-filter-cmt: filter-cmt.o $(JLIB)
-
-tests: $(addsuffix .test,io token filter-cmt judge-tok)
-io.test: test-io
-token.test: test-tok
-filter-cmt.test: filter-cmt
-judge-tok.test: judge-tok
-
-%.test: %.t tester
-       ./tester $<
-
-clean::
-       rm -f `find . -name "*~" -or -name "*.[oa]" -or -name "\#*\#" -or -name TAGS -or -name core`
-       rm -f test-io test-tok judge-tok judge-shuff filter-cmt
-       rm -rf tmp
-
-.PHONY: all clean distclean
+TESTS+=$(addprefix $(JDIR)/,io.test token.test judge-tok.test filter-cmt.test)
index 67adf9a8c9e4d76acaa451d6c5cbd577b75fe8bd..09e4b17c534d5b909e06f3cc1f1b4becfec62023 100644 (file)
@@ -1,6 +1,6 @@
 # Test cases for filter-cmt.c
 
-Run:   ./filter-cmt
+Run:   bin/filter-cmt
 In:    abc//comment
        de///fgh
        //full-line comment
index ed9f46a9f9ac6b6bb63fe2e301c8a978f376bd51..995636b0438e801be1a255061653ce5acf1e4fab 100644 (file)
@@ -1,6 +1,6 @@
 # Test cases for io.c
 
-Run:   ./test-io
+Run:   bin/test-io
 In:    abc
        def
 Out:   abc
index 79943a4549e49496882148e49b030546128b061e..109c5a46cbdfdb7442ecd019b10f1496f35576e5 100644 (file)
@@ -2,7 +2,7 @@
 
 # Identical input and output
 Name:  ok
-Run:   ./judge-tok $1 $2
+Run:   bin/judge-tok $1 $2
 In1:   abc d e fgh
        ijk lmn
 In2:   abc d e fgh
@@ -10,7 +10,7 @@ In2:  abc d e fgh
 
 # Differences in whitespaces are OK
 Name:  ws
-Run:   ./judge-tok $1 $2
+Run:   bin/judge-tok $1 $2
 In1:   abc       d e fgh  
           ijk  lmn
 In2:   abc d  e fgh
@@ -18,7 +18,7 @@ In2:  abc d  e fgh
 
 # Differences in line breaks are not
 Name:  lines1
-Run:   ./judge-tok $1 $2
+Run:   bin/judge-tok $1 $2
 In1:   abc  d
        e fgh  
           ijk  lmn
@@ -28,7 +28,7 @@ Exit: 1
 
 # ... unless the -n switch is given
 Name:  lines2
-Run:   ./judge-tok -n $1 $2
+Run:   bin/judge-tok -n $1 $2
 In1:   abc   d
        e fgh  
           ijk  lmn
@@ -37,7 +37,7 @@ In2:  abc d e fgh
 
 # Trailing empty lines are also not OK
 Name:  trail1
-Run:   echo >>$1 && ./judge-tok $1 $2
+Run:   echo >>$1 && bin/judge-tok $1 $2
 In1:   abc d e fgh
        ijk lmn
 In2:   abc d e fgh
@@ -46,7 +46,7 @@ Exit: 1
 
 # ... unless -t is given
 Name:  trail1
-Run:   echo >>$1 && ./judge-tok -t $1 $2
+Run:   echo >>$1 && bin/judge-tok -t $1 $2
 In1:   abc d e fgh
        ijk lmn
 In2:   abc d e fgh
@@ -54,7 +54,7 @@ In2:  abc d e fgh
 
 # Differences in case are not
 Name:  case1
-Run:   ./judge-tok $1 $2
+Run:   bin/judge-tok $1 $2
 In1:   abc d e FGH
        IJK lmn
 In2:   abc d e fgh
@@ -63,7 +63,7 @@ Exit: 1
 
 # ... unless -i is given
 Name:  case2
-Run:   ./judge-tok -i $1 $2
+Run:   bin/judge-tok -i $1 $2
 In1:   abc d e FGH
        IJK lmn
 In2:   abc d e fgh
@@ -71,7 +71,7 @@ In2:  abc d e fgh
 
 # By default, we compare everything literal
 Name:  real1
-Run:   ./judge-tok $1 $2
+Run:   bin/judge-tok $1 $2
 In1:   0.1000001
        1.
        1e-50
@@ -84,7 +84,7 @@ Exit: 1
 
 # ... but if -r is given, we allow small differences
 Name:  real2
-Run:   ./judge-tok -r $1 $2
+Run:   bin/judge-tok -r $1 $2
 In1:   0.1000001
        1.
        1e-50
diff --git a/judge/tester b/judge/tester
deleted file mode 100755 (executable)
index d467b98..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-#!/usr/bin/perl
-# A simple unit testing script
-# (c) 2004--2007 Martin Mares <mj@ucw.cz>
-# (c) 2007 Pavel Charvat <pchar@ucw.cz>
-
-# Tests in the test file have a syntax similar to mail headers,
-# individual test case are separated by blank lines and they can contain
-# the following fields:
-#
-#      Name:   name of the case (default: sequence number since start of file)
-#      Run:    command to run (default: command from the previous test case)
-#              This can be an arbitrary shell pipeline, sequences $0 to $9 are
-#              replaced by file names of In<N> or Out<N> files (see below).
-#      In:     lines to pass to the program as standard input
-#      Out:    lines to expect at the program's standard output
-#      In<N>:  lines to pass to the program as input file <N>
-#      Out<N>: lines to expect from the program in output file <N>
-#              Both In<N> and Out<N> can be specified simultaneously if we
-#              are testing a program which modifies some of its input files.
-#      Exit:   expected exit code of the program (default: 0)
-
-use Getopt::Long;
-
-my $verbose = 0;
-my $rundir = ".";
-GetOptions("verbose!" => \$verbose,
-          "rundir=s" => \$rundir)
-       or die "Usage: tester [--verbose] [--rundir=<dir>] <tests>\n";
-
-my @tests = ();
-my $tt;
-my $append_to;
-
-while (<>) {
-       /^#/ && next;
-       if (/^\s*$/) {
-               $tt = undef;
-               $append_to = undef;
-       } elsif (defined($append_to) && /^\s+(.*)$/) {
-               $$append_to .= "\n$1";
-       } elsif (my ($n,$v) = /^(\w+):\s+(.*)$/) {
-               if (!$tt) {
-                       $tt = {};
-                       push @tests, $tt;
-               }
-               ($tt->{$n}) && die "$n already defined";
-               $tt->{$n} = $v;
-               $append_to = \($tt->{$n});
-       } else {
-               die "Test script syntax error";
-       }
-}
-
-if (! -d "$rundir/tmp") {
-       mkdir "$rundir/tmp" or die "Unable to create $rundir/tmp: $!";
-}
-
-my $i = 0;
-my $errors = 0;
-my $prev_run = undef;
-TEST: foreach $tt (@tests) {
-       $i++;
-       my $name = $tt->{'Name'} || $i;
-       print "Test $name: ";
-       $run = ($tt->{'Run'} || $prev_run) or die "Don't know what to run";
-       $prev_run = $run;
-
-       my @out_files = ();
-       my @out_checks = ();
-       my $redirs = "";
-
-       if (defined $tt->{'In'}) {
-               my $ifi = "tmp/test$i.in";
-               open X, ">$rundir/$ifi" or die "Unable to create $ifi";
-               print X $tt->{'In'}, "\n";
-               close X;
-               $redirs .= " <$ifi";
-       } else {
-               $redirs .= " </dev/null";
-       }
-       if (defined $tt->{'Out'}) {
-               my $ofi = "tmp/test$i.out";
-               unlink "$rundir/$ofi";
-               $redirs .= " >$ofi";
-               push @out_files, $ofi;
-               push @out_checks, $tt->{'Out'};
-       } else {
-               $redirs .= " >/dev/null";
-       }
-       foreach my $arg (0..9) {
-               my $f = "tmp/test$i.$arg";
-               if (defined $tt->{"Out$arg"}) {
-                       unlink "$rundir/$f";
-                       push @out_files, $f;
-                       push @out_checks, $tt->{"Out$arg"};
-               }
-               if (defined $tt->{"In$arg"}) {
-                       open X, ">$rundir/$f" or die "Unable to create $f";
-                       print X $tt->{"In$arg"}, "\n";
-                       close X;
-               }
-       }
-       $run =~ s/\$(\d)/tmp\/test$i.$1/g;
-       print "(running $run) " if $verbose;
-       system "cd $rundir && ( $run ) $redirs";
-       if ($? % 256) {
-               print "FAILED with status code $?\n";
-               $errors++;
-               next;
-       }
-       my $ec = $? / 256;
-       my $expect_ec = $tt->{'Exit'} || 0;
-       if ($ec != $expect_ec) {
-               print "FAILED: unexpected exit code $ec\n";
-               $errors++;
-               next;
-       }
-
-       for (my $i=0; $i<=$#out_files; $i++) {
-               my $ofi = $out_files[$i];
-               open X, "<$rundir/$ofi" or die "Unable to read $ofi";
-               my $out;
-               {
-                       local $/ = undef;
-                       $out = <X>;
-               }
-               close X;
-               if ($out ne $out_checks[$i] . "\n") {
-                       print "FAILED (see $ofi)\n";
-                       $errors++;
-                       next TEST;
-               }
-       }
-
-       system "rm $rundir/tmp/test$i.*";
-       print "OK\n";
-}
-
-exit !!$errors;
index 4f4aa2e1aa69ded4d96ceb30a95555580328e433..2171c5da076430850adfd775c9a0760f01cc3646 100644 (file)
@@ -4,7 +4,7 @@
 
 # A simple test case with several spaces
 Name:  std
-Run:   ./test-tok
+Run:   bin/test-tok
 In:       abc   
        10  20   30
 Out:   <abc>
@@ -14,7 +14,7 @@ Out:  <abc>
 
 # The same test case in line mode
 Name:  std-l
-Run:   ./test-tok -l
+Run:   bin/test-tok -l
 In:       abc   
        10  20   30
 Out:   <abc>
@@ -26,31 +26,31 @@ Out:        <abc>
 
 # An unterminated line
 Name:  unterm
-Run:   tr -d '\n' | ./test-tok
+Run:   tr -d '\n' | bin/test-tok
 In:    abc
 Out:   <abc>
 
 # An unterminated line in line mode
 Name:  unterm-l
-Run:   tr -d '\n' | ./test-tok -l
+Run:   tr -d '\n' | bin/test-tok -l
 In:    abc
 Out:   <abc>
 
 # Small token size limit, but fits
 Name:  big1
-Run:   ./test-tok -s
+Run:   bin/test-tok -s
 In:    abcdefghijklmnop
 Out:   <abcdefghijklmnop>
 
 # Small token size limit, does not fit
 Name:  big2
-Run:   ./test-tok -s
+Run:   bin/test-tok -s
 In:    abcdefghijklmnopq
 Exit:  1
 
 # Testing parsers
 Name:  parse1
-Run:   ./test-tok -vl
+Run:   bin/test-tok -vl
 In:    abcdef
        0 5 -5
 Out:   <abcdef>
@@ -62,7 +62,7 @@ Out:  <abcdef>
 
 # More parsing: integer extremes
 Name:  parse2
-Run:   ./test-tok -v
+Run:   bin/test-tok -v
 In:    -2147483647 2147483647
        -2147483648 2147483648
        -4294967295 4294967295