source: branches/profile/UNIT_TESTER/log_result.pl

Last change on this file was 11260, checked in by westram, 10 years ago
  • detect interrupted tests and show early in compile log
  • Property svn:executable set to *
File size: 1.7 KB
Line 
1#!/usr/bin/perl
2use strict;
3use warnings;
4
5my $reg_summary     = qr/^UnitTester:.*\stests=([0-9]+)\s/;
6my $reg_interrupted = qr/interrupting.*deadlocked.*test/i;
7
8sub log_summary($) {
9  my ($log) = @_;
10  my $interrupted = 0;
11
12  open(LOG,$log) || die "Failed to read '$log' (Reason: $!)";
13  my $line;
14 LINE:  while (defined ($line=<LOG>)) {
15    if ($line =~ $reg_summary) {
16      my $testCount = $1;
17      if ($testCount==0) {
18        ; # looks like all tests in this module have been skipped
19      }
20      else {
21        chomp($line);
22        $line =~ s/^UnitTester:\s*//;
23        my @items = split /\s+/, $line;
24        my $module = undef;
25        my $passed = undef;
26        foreach (@items) {
27          my ($key,$value) = split /=/, $_;
28          if ($key eq 'target') {
29            $value =~ s/\.a//;
30            $module = $value;
31          }
32          elsif ($key eq 'passed') {
33            $passed = $value;
34            if ($passed eq 'ALL') { $passed = $testCount; }
35          }
36        }
37        print "- $module ($passed/$testCount)\n";
38      }
39
40      close(LOG);
41      return;
42    }
43    elsif ($line =~ $reg_interrupted) {
44      $interrupted = 1;
45      last LINE;
46    }
47  }
48
49  close(LOG);
50
51  # no summary found -> problem
52  my $module   = $log; # fallback
53  my $extraMsg = '; invalid logname';
54
55  if ($log =~ /logs\//o) {
56    my $name = $';
57    if ($name =~ /^([^\.]+)\.test/o) {
58      $module = $1;
59      $extraMsg = '';
60    }
61    else {
62      $module = $name;
63    }
64  }
65
66  my $msg = 'no summary; crashed?';
67  if ($interrupted==1) { $msg = 'interrupted; deadlock?'; }
68
69  print "- $module ($msg$extraMsg)\n";
70}
71
72sub main() {
73  my $args = scalar(@ARGV);
74  if ($args!=1) {
75    die "Usage: log_result.pl unittest.log";
76  }
77  else {
78    log_summary($ARGV[0]);
79  }
80}
81main();
Note: See TracBrowser for help on using the repository browser.