#! /usr/bin/perl
-
+#
+# analyze_results
+#
# Script to analyze failed build logs. Look for specific regexps to
# classify things
+#
+#
+# (c) 2018 Steve McIntyre <steve@einval.com> GPL v2+
use strict;
use warnings;
+use POSIX qw(strftime);
+use Data::Dumper;
-my $logs = "/home/build/logs";
-my $logs_fail = "$logs/FAIL";
+my $name = "analyze_results";
+my $repo = "https://git.einval.com/cgi-bin/gitweb.cgi?p=buildd-scripts.git";
+my $hostname;
+my $date;
+my $time_start = time();
+my $time_end;
+my $time_taken;
my $num_fail = 0;
+my $lines_read = 0;
my $existing_bugs = 0;
+use constant {
+ ERR_ARCH_MISMATCH => 1,
+ ERR_INFRA => 2,
+ ERR_BD_PROBLEM => 3,
+ ERR_DETECT_WRONG_ARCH => 4,
+ ERR_CRASH => 5,
+ ERR_BUILD_PROBLEM => 6,
+ ERR_TEST_PROBLEM => 7,
+ ERR_BUILD_TIMEOUT => 8,
+};
+
+my @err_descriptions;
+$err_descriptions [ERR_ARCH_MISMATCH] = "Architecture mismatches";
+$err_descriptions [ERR_INFRA] = "Infrastructure errors";
+$err_descriptions [ERR_BD_PROBLEM] = "Problems with build-deps";
+$err_descriptions [ERR_DETECT_WRONG_ARCH] = "Builds detected wrong architecture";
+$err_descriptions [ERR_CRASH] = "Crashes detected";
+$err_descriptions [ERR_BUILD_PROBLEM] = "Problems detected during build phase";
+$err_descriptions [ERR_TEST_PROBLEM] = "Problems detected during test phase";
+$err_descriptions [ERR_BUILD_TIMEOUT] = "Package builds timed out";
+
# Known failure modes to look for
my @logcheck = (
{
message => 'Architecture mismatch',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_ARCH_MISMATCH,
},
{
string => 'not in arch list or does not match any',
message => 'Architecture mismatch',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_ARCH_MISMATCH,
+ },
+ {
+ # "binary build with no binary artifacts found" -> no packages
+ # built. Why not picked up already above?.
+ # Stop working on this log at this point
+ string => 'binary build with no binary artifacts found',
+ message => 'No binaries built',
+ check => 1,
+ stop => 1,
+ type => ERR_ARCH_MISMATCH,
},
{
string => 'schroot.*File is not owned by user root',
message => 'Schroot setup failure',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_INFRA,
},
{
string => 'No space left on device',
message => 'Build ran out of disk space',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_INFRA,
},
{
- string => 'aarch64-unknown-linux-gnu',
- message => 'Wrong arch detected',
+ string => 'The system has no more ptys',
+ message => 'Build ran out of ptys',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_INFRA,
},
{
- string => 'binutils-aarch64',
+ string => 'aarch64-unknown-linux-gnu',
message => 'Wrong arch detected',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_DETECT_WRONG_ARCH,
},
{
- string => 'lib.linux-aarch64',
+ string => 'binutils-aarch64',
message => 'Wrong arch detected',
- check => 1,
+ check => 0,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_DETECT_WRONG_ARCH,
},
{
- # "binary build with no binary artifacts found" -> no packages
- # built. Why not picked up already above?.
- # Stop working on this log at this point
- string => 'binary build with no binary artifacts found',
- message => 'No binaries built',
+ string => 'lib.linux-aarch64',
+ message => 'Wrong arch detected',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_DETECT_WRONG_ARCH,
},
{
# "Bus error" -> alignment bug
message => 'Alignment problem',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_CRASH,
},
{
# "Segmentation fault" -> code problem
message => 'Segmentation fault when installing RESULT',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_CRASH,
},
{
# "Segmentation fault" -> code problem
message => 'Segmentation fault',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_CRASH,
},
{
# "Illegal instruction" -> bad build target?
message => 'Illegal instruction when installing RESULT',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_CRASH,
},
{
# "Illegal instruction" -> bad build target?
message => 'Illegal instruction',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_CRASH,
},
{
# Installing build-deps failed
message => 'Build-dep failed to install (RESULT)',
check => 1,
stop => 0,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BD_PROBLEM,
},
{
# Installing build-deps failed
message => 'Pbuilder build-deps failed',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BD_PROBLEM,
},
{
# Installing build-deps failed
message => 'Build-deps failed',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BD_PROBLEM,
},
{
# Installing build-deps failed
message => 'Missing build-dep (RESULT)',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BD_PROBLEM,
},
{
# Build failed - missing build-dep?
message => 'Build-deps not satisfiable',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BD_PROBLEM,
+ },
+ {
+ # Build failed
+ string => 'dpkg-source: error: unrepresentable changes to source',
+ message => 'dpkg-source failure',
+ check => 1,
+ stop => 1,
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed - missing build-dep?
message => 'Build failure: missing library - missing build-dep?',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed - missing build-dep?
message => 'Build failure: missing header - missing build-dep?',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed - missing build-dep?
message => 'Build failure - missing build-dep?',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed - can't exec something...
message => 'Build failure (missing binary)',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed
- string => 'BUILD FAILED',
+ string => 'BUILD FAIL',
message => 'Build failure (java/javadoc)',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed
message => 'Build failure (other)',
check => 1,
stop => 0,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed
string => '^make.*\*\*\*.* \[debian/rules.*Error \d+$',
message => 'Build failure (other)',
check => 1,
- stop => 0,
- timeout => 0, # This is a real error, not a build timeout
+ stop => 1,
+ type => ERR_BUILD_PROBLEM,
+ },
+ {
+ # Build failure
+ string => 'dh_auto_build:.*returned exit code \d+',
+ message => 'Build failure (other)',
+ check => 1,
+ stop => 1,
+ type => ERR_BUILD_PROBLEM,
+ },
+ {
+ # Build failure
+ string => 'dh_auto_clean:.*returned exit code \d+',
+ message => 'Build failure (clean failed)',
+ check => 1,
+ stop => 1,
+ type => ERR_BUILD_PROBLEM,
+ },
+ {
+ # Build failure
+ string => 'dh_auto_install:.*returned exit code \d+',
+ message => 'Build failure (install failed)',
+ check => 1,
+ stop => 1,
+ type => ERR_BUILD_PROBLEM,
+ },
+ {
+ # Build failure
+ string => 'dh_auto_configure:.*returned exit code \d+',
+ message => 'Build failure (configure failed)',
+ check => 1,
+ stop => 1,
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed
- string => 'dpkg-source: error: unrepresentable changes to source',
- message => 'dpkg-source failure',
+ string => '^debian/.*recipe for target.*failed',
+ message => 'Build failure (other)',
check => 1,
stop => 1,
- timeout => 0, # This is a real error, not a build timeout
+ type => ERR_BUILD_PROBLEM,
},
{
# Build failed
message => 'Build failure (other)',
check => 0,
stop => 1,
+ type => ERR_BUILD_PROBLEM,
},
{
# Test failure
message => 'Python EPERM test failure',
check => 1,
stop => 1,
+ type => ERR_TEST_PROBLEM,
},
{
# Test failure
message => 'Test failure',
check => 1,
stop => 1,
+ type => ERR_TEST_PROBLEM,
},
{
# Timeout. pbuilder is too dumb to do this properly :-(
message => 'Pbuilder build timeout',
check => 1,
stop => 1,
- timeout => 1, # This is a build timeout. If this happened
- # before other errors, then we should retry
+ type => ERR_BUILD_TIMEOUT,
},
{
# Timeout from sbuild
message => 'Sbuild build timeout',
check => 1,
stop => 1,
- timeout => 1, # This is a build timeout. If this happened
- # before other errors, then we should retry
+ type => ERR_BUILD_TIMEOUT,
},
);
print "<ul>\n";
while (defined (my $line = <IN>) and !$stop) {
$lineno++;
+ $lines_read++;
foreach my $checktmp (@logcheck) {
my %check = %$checktmp;
if ($check{check}) {
my $match = $1;
my $message = $check{message};
$message =~ s,RESULT,$match,g;
- $file_results{$message} = 1;
- if ($check{timeout} and $errors == 0) {
+ $file_results{$message} = $check{type};
+ if ($check{type} == ERR_BUILD_TIMEOUT and $errors == 0) {
print " <li>Line $lineno: $message\n";
print " <li>Build killed by timeout before any errors at line $lineno\n";
} else {
print "</ul>\n";
foreach my $key (keys %file_results) {
- $log_results{$key} += 1;
+ $log_results{$file_results{$key}}{$key} += 1;
# print "now have $log_results{$key} for \"$key\"\n";
}
}
print "<a name=\"summary\"</a>\n";
print "<h2>Summary of results from $num_fail failed builds:</h2>\n";
print "<ul>\n";
-print "<li>Found $existing_bugs existing bugs</li>\n";
-foreach my $key (sort { $log_results{$b} <=> $log_results{$a} } keys %log_results) {
- print " <li>Found $log_results{$key} logs showing $key\n";
+print "<li> Found $existing_bugs existing bugs in the Debian BTS</li>\n";
+foreach my $type (sort keys %log_results) {
+ print " <h3>$err_descriptions[$type]</h3>\n";
+ my $tmp = $log_results{$type};
+ my %result = %$tmp;
+ foreach my $key (sort { $result{$b} <=> $result{$a} }keys %result) {
+ print " <li>Found $result{$key} log(s) showing $key\n";
+ }
}
print "</ul>\n";
+
+$time_end = time();
+$time_taken = $time_end - $time_start;
+$date = strftime "%a %b %e %H:%M:%S %Z %Y", localtime;
+$hostname = `hostname`;
+
+print "<hr>\n";
+print "<p>Log analysis generated on $hostname, $date.\n";
+print "<br>Output from $name - see <a href=\"$repo\">$repo</a> for source.\n";
+print "<br>Read $lines_read lines of logs and took $time_taken seconds to complete.\n";
+
print "</body>\n";
print "</html>\n";