summaryrefslogtreecommitdiff
path: root/bin/check_build_logs
blob: 8f18c13fafb7f9381e9ed6be5bd18c9ee90d69ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
    & eval 'exec perl -S $0 $argv:q'
    if 0;

# $Id$
#
# Reviews build logs and reports problems, via stdout or mail.

$usage="$0 [-l log directory] [-m mail recipient(s)]\n";

####
#### Configuration parameters.
####
$subject = 'ACE+TAO build results';
$find = 'find';
$mail = "mail -s '$subject'";

$ostype = $ENV{'OSTYPE'}  ||  `/bin/uname -s`;
if ( "$ostype" =~ /(solaris)|(SunOS)/i ) {
  $find = '/pkg/gnu/bin/find';
  $mail = "/pkg/mh/bin/mhmail -subject '$subject'";
}


$log_directory = '/project/danzontmp/levine/build-logs';
$mail_recipients = '';

####
#### Process command line args.
####
while ($#ARGV >= $[) {
  if ($ARGV[0] eq '-l') {
    if ($ARGV[1] =~ /^\w+$/) {
      $log_directory = $ARGV[1];
      shift;
    } else {
      print STDERR "$0:  must provide argument for -l option\n";
      die $usage;
    }
  } elsif ($ARGV[0] eq '-m') {
    if ($ARGV[1] =~ /^[\w@\.]+$/) {
      $mail_recipients = $ARGV[1];
      shift;
    } else {
      print STDERR "$0:  must provide argument for -m option\n";
      die $usage;
    }
  } elsif ($ARGV[0] eq '-?') {
    print "$usage";
    exit;
  } else {
    print "$0: unknown arg: $ARGV[0]\n";
    print "$usage";
    exit 1;
  }
  shift;
}


####
#### Find the log files.
####
chdir $log_directory  ||
  die "$0: unable to cd to \"$log_directory\"\n";

($log_files = ( `$find . -name '*.log' -daystart -ctime 0 -print` )) =~
  tr [\n] [ ];


####
#### Grep the log files for problems.
####
@output = ();
open (EGREP, "egrep -n \'Error|errors|[^a]Stop|No rule to make|\(undefined symb\)|[Ww]arn|not exist|core dumped|: #[0-9]|cxx:\' $log_files |")  ||
  die "$0: unable to open egrep\n";
while (<EGREP>) {
  push @output, $_ unless /calls, 0 errors$/  ||  /Found non-pic R_SPARC/;
}
close EGREP;


####
#### Produce output, if there were any problems.
####
if ($#output > -1) {

  if ("$mail_recipients") {
    open (MAIL, "| $mail $mail_recipients")  ||
      die "$0: unable to open pipe to $mail\n";
    select MAIL;
  }

  print "This is an automatically generated message.\n\n";
  print "Log files are in $log_directory.\n\n";

  print @output;

  close MAIL if "$mail_recipients";
}