Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Initialize common variable.
[simgrid.git] / teshsuite / smpi / mpich3-test / checktests
1 #! /usr/local/bin/perl
2
3 $debug   = 1;
4 $verbose = 1;
5 $ignoreBogusOutput = 0;
6 $filePattern = "runtests.*.status";
7
8 $testsPassed = 0;
9 $testsFailed = 0;
10
11 foreach $_ (@ARGV) {
12     if (/^--?ignorebogus/) {
13         $ignoreBogusOutput = 1;
14     }
15     else {
16         print STDERR "checktests [ -ignorebogus ]\n";
17         exit(1);
18     }
19 }
20
21 open( RESULTS, "ls -1 $filePattern |" ) || die "Cannot list directory using ls -1 $filePattern\n";
22
23 while (<RESULTS>) {
24     chop;
25     $statusFile = $_;
26     $resultsFile = $statusFile;
27     $resultsFile =~ s/\.status/.out/;
28
29     if ($resultsFile =~ /runtests\.([0-9]+)\.out/) {
30         $count = $1;
31     }
32     else {
33         $count = -1;
34         print STDERR "Unable to determine test number from $resultsFile!\n";
35         $testsFailed ++;
36         next;
37     }
38     open (SFD, "<$statusFile" );
39     while (<SFD>) {
40         chop;
41         $testStatus = $_;
42     }
43     close (SFD);
44     
45     if (-s $resultsFile) {
46         open (RFD, "<$resultsFile");
47         $runLine = <RFD>;
48         $sawNoerrors = 0;
49         # Successful output should contain ONLY the line No Errors
50         while (<RFD>) {
51             chop;
52             $outLine = $_;
53             if ($outLine =~ /^\s+No [Ee]rrors\s*$/) {
54                 $sawNoerrors = 1;
55             }
56             else {
57                 # To filter out output that may be added to STDOUT
58                 # by a badly behaved runtime system, you can either
59                 # add a specific filter here (preferred) or set the
60                 # -ignorebogus option (considered a workaround)
61                 # The following is an example that accepts certain
62                 # kinds of output once "No Errors" is seen.
63                 if ($sawNoerrors) {
64                     if ( /^Application [0-9]+ resources: utime .*/) {
65                         last;
66                     }
67                 }
68                 if (!$ignoreBogusOutput) {
69                     # Any extraneous output is an error
70                     $sawNoerrors = 0;
71                 }
72             }
73         }
74         close (RFD);
75         if ($sawNoerrors == 1 && $testStatus == 0) {
76             $testsPassed ++;
77         }
78         else {
79             # Test wrote No Errors but then exited with a non-zero status
80             $testsFailed ++;
81             # Output the errors
82             if ($verbose) {
83                 print STDOUT "Test $count failed:\n";
84                 print STDOUT "Test status: $testStatus\n";
85                 print STDOUT "Test output:\n";
86                 system ("cat $resultsFile" );
87             }
88         }
89     }
90     else {
91         print STDERR "No $resultsFile\n" if $debug;
92         $testsFailed ++;
93     }
94 }
95
96 print "Tests passed: $testsPassed; test failed: $testsFailed\n";