Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
making the sources for the instrumentation be present in the distribution
[simgrid.git] / checkall
1 #! /usr/bin/perl
2
3 use strict;
4 $ENV{LC_ALL} = "C"; # avoid NLS nuisance
5
6 my @fail;
7 my @xfail;
8 my @pass;
9 my @xpass;
10 my @skip;
11
12 my $dir;
13
14 open LOG,(">checkall.log") || die "Cannot open log file: $!";
15
16 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
17 print LOG "Build started on $hour:$min:$sec $mon/$mday/$year\n";
18 print LOG "Current svn version is: ".qx(svnversion)."\n\n";
19
20 print LOG "\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n";
21 print LOG "XXX Include config.log since it contains valuable information XXX\n";
22 print LOG "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n";
23 open CFG,"<config.log" || die "Cannot open config.log: $!*";
24 while (<CFG>) {
25     print LOG "$_";
26 }
27 close CFG;
28
29 print LOG "\nXXXXXXXXXXXXXXXX\n";
30 print LOG "XXX Run make XXX\n";
31 print LOG "XXXXXXXXXXXXXXXX\n";
32 open MAKE,("make 2>&1 |") || die "Cannot fork a make: $!";
33 while (<MAKE>) {
34     print     $_;
35     print LOG $_;
36 }
37 if (!close MAKE) {
38     my $str = "# The source don't compile! Go fix it before running make check #";
39     my $dashes = $str;
40     $dashes =~ s/./#/g;
41     print LOG "\n$dashes\n$str\n$dashes\n\n";
42     print     "\n$dashes\n$str\n$dashes\n\n";
43     close LOG;
44     exit 1;
45 }
46     
47 print LOG "\nXXXXXXXXXXXXXXXXXXXXXX\n";
48 print LOG "XXX Run make check XXX\n";
49 print LOG "XXXXXXXXXXXXXXXXXXXXXX\n";
50 open CHECK,("make -k check 2>&1 |") || die "Cannot fork a make check: $!";
51 while (<CHECK>) {
52     print     $_;
53     print LOG $_;
54     chomp;
55     if (/Entering directory .([^']*)'/) { #})){
56       $dir = $1;
57       $dir =~ s|$ENV{PWD}/||;
58     }
59     push @pass, "$dir/$1"   if (/^PASS: (.*)$/);
60     push @xpass,"$dir/$1"   if (/^XPASS: (.*)$/);  
61     push @fail, "$dir/$1"   if (/^FAIL: (.*)$/);
62     push @xfail,"$dir/$1"   if (/^XFAIL: (.*)$/);   
63     push @skip, "$dir/$1"   if (/^SKIP: (.*)$/);
64 }
65 close CHECK;
66
67 my $all = scalar @fail + scalar @xfail + scalar @pass + scalar @xpass + scalar @skip;
68 my $banner;
69
70 if (scalar @fail == 0) {
71     if (scalar @xfail == 0) {
72         $banner="All $all tests passed. Congratulation.";
73     } else {
74         $banner="All $all tests behaved as expected (".(scalar @xfail)." expected failures)";
75     }
76 } elsif (scalar @xpass == 0) {
77     $banner=(scalar @fail)." of $all tests failed"; 
78 } else {
79     $banner=(scalar @fail+scalar @xpass)." of $all tests did not behave as expected (".(scalar @xpass)." unexpected passes)"; 
80 }
81 $banner = "# $banner #";
82 my $dashes = $banner;
83 $dashes =~ s/./X/g;
84 print LOG "\n$dashes\n$banner\n$dashes\n\n";
85 print     "\n$dashes\n$banner (full logs in checkall.log)\n$dashes\n\n";
86
87 if (scalar @pass) {
88     print LOG "* ".(scalar @pass)." passed tests:\n";
89     map {print LOG "  $_\n"} @pass;
90 }
91 if (scalar @skip) {
92     print LOG "* ".(scalar @skip)." skipped tests:\n";
93     print     "* ".(scalar @skip)." skipped tests:\n";
94     map {print "  $_\n";print LOG "  $_\n"} @skip;
95 }
96 if (scalar @xpass) {
97     print LOG "* ".(scalar @xpass)." unexpected pass:\n";
98     print     "* ".(scalar @xpass)." unexpected pass:\n";
99     map {print "  $_\n";print LOG "  $_\n"} @xpass;
100 }
101 if (scalar @xfail) {
102     print LOG "* ".(scalar @xfail)." expected failures:\n";
103     print     "* ".(scalar @xfail)." expected failures:\n";
104     map {print "  $_\n";print LOG "  $_\n"} @xfail;
105 }
106 if (scalar @fail) {
107     print LOG "* ".(scalar @fail)." failed tests:\n";
108     print     "* ".(scalar @fail)." failed tests:\n";
109     map {print "  $_\n";print LOG "  $_\n"} @fail;
110 }
111
112 exit scalar @fail == 0;