[2] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | use strict; no strict 'vars';
|
---|
| 3 |
|
---|
| 4 | ########################################################################
|
---|
| 5 | # Configuration options.
|
---|
| 6 |
|
---|
| 7 | # Your compiler
|
---|
| 8 | $compiler = './comp';
|
---|
| 9 |
|
---|
| 10 | # Name of the log file.
|
---|
| 11 | $log = 'test-runs-log';
|
---|
| 12 |
|
---|
| 13 | # Verbose log (includes output for succesful runs)?
|
---|
| 14 | $verbose = 0;
|
---|
| 15 |
|
---|
| 16 | # List of tops of directory trees with tests.
|
---|
| 17 | $testdir = '../tests/';
|
---|
| 18 | $dirfile = $testdir.'dirs';
|
---|
| 19 |
|
---|
| 20 | ########################################################################
|
---|
| 21 |
|
---|
| 22 |
|
---|
| 23 | $me = `whoami`;
|
---|
| 24 | chomp($me);
|
---|
| 25 | $templog = '/tmp/' . $me . '-log';
|
---|
| 26 |
|
---|
| 27 | system("rm -f $log");
|
---|
| 28 |
|
---|
| 29 | if (! -x $compiler) {
|
---|
| 30 | die ("Cannot execute \"$compiler\"");
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | $success = 0;
|
---|
| 34 | $failure = 0;
|
---|
| 35 |
|
---|
| 36 | $| = 1;
|
---|
| 37 | open(TESTS, "find `cat $dirfile` -type f -name '*.p?' 2> /dev/null |") or die;
|
---|
| 38 | undef $/;
|
---|
| 39 | $_ = <TESTS>;
|
---|
| 40 | @test = split;
|
---|
| 41 | close(TESTS);
|
---|
| 42 |
|
---|
| 43 | foreach $test (@test) {
|
---|
| 44 | if (! -r $test) {
|
---|
| 45 | print STDERR "Skipping unreadable test $test\n";
|
---|
| 46 | }
|
---|
| 47 |
|
---|
| 48 | print STDERR "Doing test $test\n";
|
---|
| 49 | system("echo Doing test $test >> $log");
|
---|
| 50 |
|
---|
| 51 | $test =~ m/^.*\.p([01])$/;
|
---|
| 52 | $expected = $1;
|
---|
| 53 |
|
---|
| 54 | # Call the compiler; all output to $templog
|
---|
| 55 | system("$compiler < $test 2> $templog > $templog");
|
---|
| 56 |
|
---|
| 57 | $exitval = $? >> 8;
|
---|
| 58 | if ($exitval == $expected) {
|
---|
| 59 | $success++;
|
---|
| 60 | system("echo Succeeded >> $log");
|
---|
| 61 | if ($verbose) {
|
---|
| 62 | system("cat $templog >> $log");
|
---|
| 63 | }
|
---|
| 64 | } else {
|
---|
| 65 | print "Failed test \"$test\" with exitcode $exitval \n";
|
---|
| 66 | system("cat $templog >> $log");
|
---|
| 67 | system("echo Failed test $test with exitcode $exitval >> $log");
|
---|
| 68 | $failure++;
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | open(RES, "| tee -a $log");
|
---|
| 73 | print RES "\n\n";
|
---|
| 74 | print RES "#tests: ", $success + $failure, "\n";
|
---|
| 75 | print RES "#successes: $success\n";
|
---|
| 76 | print RES "#failures: $failure\n";
|
---|
| 77 | printf RES "Success rate: %3.2f %%\n", (100 * $success / ($success + $failure));
|
---|
| 78 | close(RES);
|
---|
| 79 |
|
---|
| 80 | exit ($failure == 0);
|
---|