Logo AND Algorithmique Numérique Distribuée

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