Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
eeb67cd5a60350139aa62b11d1d6893b143007db
[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 if (-e "CMakeLists.txt") { # launched from dart
15     chdir "..";
16 }
17
18 open LOG,(">checkall.log") || die "Cannot open log file: $!";
19
20 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
21 print LOG "Build started on $hour:$min:$sec $mon/$mday/$year\n";
22 print LOG "Current svn version is: ".qx(svnversion)."\n\n";
23 open MAKE,("make 2>&1 |") || die "Cannot fork a make: $!";
24 while (<MAKE>) {
25     print     $_;
26     print LOG $_;
27 }
28 if (!close MAKE) {
29     my $str = "# The source don't compile! Go fix it before running make check #";
30     my $dashes = $str;
31     $dashes =~ s/./#/g;
32     print LOG "\n$dashes\n$str\n$dashes\n\n";
33     print     "\n$dashes\n$str\n$dashes\n\n";
34     close LOG;
35     exit 1;
36 }
37     
38 open CHECK,("make -k check 2>&1 |") || die "Cannot fork a make check: $!";
39 while (<CHECK>) {
40     print     $_;
41     print LOG $_;
42     chomp;
43     if (/Entering directory .([^']*)'/) { #})){
44       $dir = $1;
45       $dir =~ s|$ENV{PWD}/||;
46     }
47     push @pass, "$dir/$1"   if (/^PASS: (.*)$/);
48     push @xpass,"$dir/$1"   if (/^XPASS: (.*)$/);  
49     push @fail, "$dir/$1"   if (/^FAIL: (.*)$/);
50     push @xfail,"$dir/$1"   if (/^XFAIL: (.*)$/);   
51     push @skip, "$dir/$1"   if (/^SKIP: (.*)$/);
52 }
53 close CHECK;
54
55 my $all = scalar @fail + scalar @xfail + scalar @pass + scalar @xpass + scalar @skip;
56 my $banner;
57
58 if (scalar @fail == 0) {
59     if (scalar @xfail == 0) {
60         $banner="All $all tests passed. Congratulation.";
61     } else {
62         $banner="All $all tests behaved as expected (".(scalar @xfail)." expected failures)";
63     }
64 } elsif (scalar @xpass == 0) {
65     $banner=(scalar @fail)." of $all tests failed"; 
66 } else {
67     $banner=(scalar @fail+scalar @xpass)." of $all tests did not behave as expected (".(scalar @xpass)." unexpected passes)"; 
68 }
69 $banner = "# $banner #";
70 my $dashes = $banner;
71 $dashes =~ s/./#/g;
72 print LOG "\n$dashes\n$banner\n$dashes\n\n";
73 print     "\n$dashes\n$banner (full logs in checkall.log)\n$dashes\n\n";
74
75 if (scalar @skip) {
76     print LOG "* ".(scalar @skip)." skipped tests:\n";
77     print     "* ".(scalar @skip)." skipped tests:\n";
78     map {print "  $_\n";print LOG "  $_\n"} @skip;
79 }
80 if (scalar @xpass) {
81     print LOG "* ".(scalar @xpass)." unexpected pass:\n";
82     print     "* ".(scalar @xpass)." unexpected pass:\n";
83     map {print "  $_\n";print LOG "  $_\n"} @xpass;
84 }
85 if (scalar @xfail) {
86     print LOG "* ".(scalar @xfail)." expected failures:\n";
87     print     "* ".(scalar @xfail)." expected failures:\n";
88     map {print "  $_\n";print LOG "  $_\n"} @xfail;
89 }
90 if (scalar @fail) {
91     print LOG "* ".(scalar @fail)." failed tests:\n";
92     print     "* ".(scalar @fail)." failed tests:\n";
93     map {print "  $_\n";print LOG "  $_\n"} @fail;
94 }
95
96 exit scalar @fail == 0;