2 # A simple unit testing script
3 # (c) 2004 Martin Mares <mj@ucw.cz>
4 # (c) 2007 Pavel Charvat <pchar@ucw.cz>
15 } elsif (defined($append_to) && /^\s+(.*)$/) {
16 $$append_to .= "\n$1";
17 } elsif (my ($n,$v) = /^(\w+):\s+(.*)$/) {
22 ($tt->{$n}) && die "$n already defined";
24 $append_to = \($tt->{$n});
26 die "Test script syntax error";
33 foreach $tt (@tests) {
36 $run = ($tt->{'Run'} || $prev_run) or die "Don't know what to run";
39 if (defined $tt->{'In'}) {
40 $ifi = "tmp/test$i.in";
41 open X, ">run/$ifi" or die "Unable to create $ifi";
42 print X $tt->{'In'}, "\n";
46 $run .= " </dev/null";
48 if (defined $tt->{'Out'}) {
49 $ofi = "tmp/test$i.out";
53 $run .= " >/dev/null";
55 system "cd run && ( $run )";
57 print "FAILED with exit code $?\n";
61 if (defined $tt->{'Out'}) {
62 open X, "<run/$ofi" or die "Unable to read $ofi";
69 if ($out ne $tt->{'Out'} . "\n") {
70 print "FAILED (see $ofi)\n";