source: liacs/coco/assignment4/dotests@ 58

Last change on this file since 58 was 2, checked in by Rick van der Zwet, 15 years ago

Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)

  • Property svn:executable set to *
File size: 1.7 KB
RevLine 
[2]1#!/usr/bin/perl -w
2use 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`;
24chomp($me);
25$templog = '/tmp/' . $me . '-log';
26
27system("rm -f $log");
28
29if (! -x $compiler) {
30 die ("Cannot execute \"$compiler\"");
31}
32
33$success = 0;
34$failure = 0;
35
36$| = 1;
37open(TESTS, "find `cat $dirfile` -type f -name '*.p?' 2> /dev/null |") or die;
38undef $/;
39$_ = <TESTS>;
40@test = split;
41close(TESTS);
42
43foreach $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
72open(RES, "| tee -a $log");
73print RES "\n\n";
74print RES "#tests: ", $success + $failure, "\n";
75print RES "#successes: $success\n";
76print RES "#failures: $failure\n";
77printf RES "Success rate: %3.2f %%\n", (100 * $success / ($success + $failure));
78close(RES);
79
80exit ($failure == 0);
Note: See TracBrowser for help on using the repository browser.