From b7828bc2cea4b3a85d423a07c32c7f9893fe0603 Mon Sep 17 00:00:00 2001 From: William King Date: Wed, 20 Oct 1999 17:21:44 +0000 Subject: [PATCH] name changed from b9tsummary.pl to b9status.pl plus changes necessary to support flexible build directory location --- bin/tests/b9status.pl | 502 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 502 insertions(+) create mode 100755 bin/tests/b9status.pl diff --git a/bin/tests/b9status.pl b/bin/tests/b9status.pl new file mode 100755 index 0000000000..abe125e665 --- /dev/null +++ b/bin/tests/b9status.pl @@ -0,0 +1,502 @@ + +# +# aggregate reports from all bind9 build environments +# write a summary of results in html format +# + +$Debug = 1; +$Home = $ENV{"HOME"}; +$DebugFile = "$Home/b9t/b9tsummary.dbg"; + +# +# level of severity at which a fatal error is considered to have occurred +# + +$HaltLevel = 2; + +$Module = "bind9"; +$HttpHostURL = "http://status.isc.org/$Module/hosts"; + +# path to directory containing host specific control info +$HomePath = "$Home/b9t/hosts"; +$WkbpFile = ".wkbp"; +$WktpFile = ".wktp"; +$RxFile = ".b9trx"; +$UnameFile = "uname"; + +# path to directory containing host specific data files and www reports +$HostPath = "/proj/build-reports/$Module/hosts"; +$ConfigFile = ".config"; +$BuildFile = ".build"; +$TestFile = ".test"; +$TestStatusFile = "tstatus.html"; +$BuildStatusFile = "bstatus.html"; + +# number of fatal build problems +$Nfbp = 0; + +# number of other build problems +$Nobp = 0; + +# number of fatal test problems +$Nftp = 0; + +# number of other test problems +$Notp = 0; + +# flag to signal bad test journal format +$BadTest = 0; +$BadTestReason = ""; + +# +# initialize the host array +# + +open(DEBUG, "> $DebugFile") if ($Debug); + +opendir(HDIR, $HostPath); +@entries = readdir(HDIR); +closedir(HDIR); + +foreach $entry (@entries) { + next if $entry =~ /^\.\.*$/; + next unless -d "$HostPath/$entry"; + push(hosts, $entry); +} + +# +# put the page top +# + +$when = `date`; +chop $when; + +printf("\n"); +printf("\n"); +printf("\n"); + +printf("
\n"); +printf("\n"); +printf("\t\n"); +printf("\t\n", $when); +printf("\t\n"); +printf("\t\n"); +printf("\t\t\n"); +printf("\t\t\n"); +printf("\t\t\n"); +printf("\t\t\n"); +printf("\t\n"); +printf("\n"); + +# +# produce status info for each host +# + +foreach $host (sort @hosts) { + &doHost($host); +} + +# +# output end of page +# + +printf("\n"); +printf("
 
bind9 status %s
 
hostbuild statusfatal/othertest status

\n"); +printf("\n"); +printf("\n"); + +close(DEBUG) if ($Debug); + +# +# produce status for host @ $hostpath +# + +sub doHost { + local($hostid) = @_; + local($entry, $prob, $line, $bstatus, $tstatus); + local(@junk, $junk, $hostname, $bcolor, $tcolor); + local(%buildprobs, %testprobs); + local($severity, $filename, $linenumber, $message, $lastfilename); + + mkdir("$HostPath/$hostid", 0755) if (! -d "$HostPath/$hostid"); + + # + # get the host name + # + + $hostname = "n/a"; + if ((-r "$HomePath/$hostid/$UnameFile") && (-s _)) { + open(XXX, "< $HomePath/$hostid/$UnameFile"); + $junk = ; + close(XXX); + @junk = split(/\s/, $junk); + $hostname = $junk[1]; + $hostname =~ s/\..*//; + } + + print DEBUG "Host: $hostid, Hostname: $hostname\n" if ($Debug); + + # + # scan the build and test results files for problems + # + + $Nfbp = 0; + $Nobp = 0; + $Ntprobs = 0; + $BadTest = 0; + + if ((-r "$HostPath/$hostid/$BuildFile") && (-s _)) { + %buildprobs = &buildCheck($hostid); + if ($Nfbp == 0) { + $bstatus = "ok"; + $bcolor = "green"; + + if ((-r "$HostPath/$hostid/$TestFile") && (-s _)) { + %testprobs = &testCheck($hostid); + if ($BadTest) { + $tstatus = "inspect ($BadTestReason)"; + $tcolor = "blue"; + } + else { + if ($Nftp) { + $tstatus = "fail"; + $tcolor = "red"; + } + else { + $tstatus = "pass"; + $tcolor = "green"; + } + } + } + else { + $tstatus = "none (no journal)"; + $tcolor = "red"; + } + } + else { + $bstatus = "broken"; + $tstatus = "none (build status)"; + $bcolor = "red"; + $tcolor = "black"; + } + } + else { + $bstatus = "none"; + $tstatus = "none (build status)"; + $bcolor = "red"; + $tcolor = "black"; + } + + printf(DEBUG "Host %s(%s) STATUS: bstatus %s, tstatus %s, badtest %d, reason %s\n", $hostid, $hostname, $bstatus, $tstatus, $BadTest, $BadTestReason) if ($Debug); + + printf("\t\n"); + printf("\t\t%s %s\n", $hostid, $hostname); + if ($bstatus =~ /none/) { + printf("\t\t%s\n", $bstatus); + printf("\t\t \n"); + } + else { + printf("\t\t"); + printf("%s", $bcolor, $bstatus); + printf("\n"); + printf("\t\t"); + printf("%d/%d", $bcolor, $Nfbp, $Nobp); + printf("\n"); + } + if ($tstatus =~ /none/) { + printf("\t\t%s\n", $tcolor, $tstatus); + } + else { + printf("\t\t%s\n", $tcolor, $tstatus); + } + printf("\t\n"); + + # + # write the build problems file + # + + &wbpf($hostid, %buildprobs) if ($Nfbp + $Nobp); +} + +# +# scan the build results file for host at $hostpath for build problems +# return %probs +# format key == filename:linenumber:severity, content == text of problem line +# set $Nfbp and $Nobp as a side effect +# + +sub buildCheck { + local($hostid) = @_; + local($filename, $linenumber, $severity); + local(%probs, %wkbp, @rxset); + local($matched, $exp, $entry, $ccrx); + + # initialize the well known build problems array, if available + if (-r "$HomePath/$hostid/$WkbpFile") { + open(XXX, "< $HomePath/$hostid/$WkbpFile"); + while() { + next if /^\#/; # skip comments + next if /^\s*$/; # and blank lines + chop; + ($filename, $linenumber) = split; + $wkbp{"$filename:$linenumber"} = 1; + } + close(XXX); + } + + # initialize the host specific regex array, if available + if (-r "$HomePath/$hostid/$RxFile") { + open(XXX, "< $HomePath/$hostid/$RxFile"); + while() { + next if /^\#/; # skip comments + next if /^\s*$/; # and blank lines + chop; + printf(DEBUG "RX: <%s>\n", $_) if ($Debug); + push(@rxset, $_); + } + close(XXX); + } + + # scan stdout/stderr of make all for problems + open(XXX, "< $HostPath/$hostid/$BuildFile"); + while () { + + undef $filename; + undef $linenumber; + undef $severity; + undef $1; + undef $2; + + $matched = 0; + + chop; + + foreach $entry (@rxset) { + ($severity, $exp) = split(/\s/, $entry, 2); + if (/$exp/) { + $filename = $1 if defined($1); + $linenumber = $2 if defined($2); + $matched = 1; + + last; + } + } + + + next unless $matched; + + if ($Debug) { + printf(DEBUG "LINE %d: %s\n", $., $_); + printf(DEBUG "MATCHES: exp<%s>\tfn<%s>\tln<%s>\tsev<%s>\n", $exp, $filename, $linenumber, $severity); + } + + if (length($filename) && length($linenumber)) { + + $filename = $1 if ($filename =~ /.*(bind9.*)/); + + # ignore it if its in the well known build problems list + if (defined($wkbp{"$filename:$linenumber"})) { + print DEBUG "IGNORED\n" if ($Debug); + # by convention, ignore all severity 0 problems + $severity = 0; + } + } + else { + $filename = "MISC"; + $linenumber = "0"; + } + + # avoid duplicates + next if (index($probs{"$filename:$linenumber:$severity"}, $_) >= 0); + + $probs{"$filename:$linenumber:$severity"} .= "$_\n"; + if ($severity >= $HaltLevel) { + ++$Nfbp; + } + else { + ++$Nobp; + } + printf(DEBUG "PROBLEM: fn<%s>\tln<%s>\tsev<%s>\n\n", $filename, $linenumber, $severity) if ($Debug); + } + close(XXX); + return(%probs); +} + +# +# run thru the test results file for $hostid +# write the test results file +# return %probs +# format key == funcname:assertion_number, value == test_result +# set $Nftp and $Notp as a side effect +# + +sub testCheck { + local($hostid) = @_; + local($funcname, $anum, $atext); + local(%probs, @junk, $junk); + local($intest, $intestcase, $inassert, $ininfo, $inresult, $ntestsets); + + # initialize the well known test problems array + if (-f "$HomePath/$hostid/$WktpFile") { + open(XXX, "< $HomePath/$hostid/$WktpFile"); + while() { + next if /^\#/; # skip comments + chop; + ($funcname, $anum) = split; + $wktp{"$funcname:$anum"} = 1; + } + close(XXX); + } + + if (! -r "$HostPath/$hostid/$TestFile") { + $BadTest = 1; + $BadTestReason = "no journal file"; + printf(DEBUG "No test journal at %s\n", "$hostpath/$TestFile") if ($Debug); + return; + } + + $intest = 0; + + open(XXX, "< $HostPath/$hostid/$TestFile"); + open(YYY, "> $HostPath/$hostid/$TestStatusFile"); + + printf(YYY "\n"); + printf(YYY "\n"); + printf(YYY "\n"); + + while () { + next unless ($_ =~ /^(S|I|T|A|R|E):/); + chop; + + if (/^S:([^:]*):(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/) { + $intest = 1; + $testname = $1; + ++$ntestsets; + printf(YYY "%s\n
\n", $_); + next; + } + + if (/^E:(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/) { + $intest = 0; + printf(YYY "%s\n
\n", $_); + next; + } + + if (/^T:([^:]*):([^:]*):/) { + if ($intest == 0) { + $BadTest = 1; + $BadTestReason = "T$."; + } + $funcname = $1; + $anum = $2; + $intestcase = 1; + $inassert = 0; + $ininfo = 0; + $inresult = 0; + ($junk = $funcname) =~ s/\//\\\//g; + s/$junk/$1<\/B>/; + printf(YYY "%s\n
\n", $_); + next; + } + if (/^A:(.*)$/) { + if (($intest == 0) || ($intestcase == 0) || ($inresult == 1)) { + $BadTest = 1; + $BadTestReason = "A$."; + } + $atext = $1; + $inassert = 1; + s/A:(.*)/A:$1<\/FONT>/; + printf(YYY "%s\n
\n", $_); + next; + } + if (/^I:(.*)$/) { + if (($intest == 0) || ($intestcase == 0) || ($inassert == 0)) { + $BadTest = 1; + $BadTestReason = "I$."; + } + $ininfo = 1; + s//\>/g; + printf(YYY "%s\n
\n", $_); + next; + } + if (/^R:(.*)$/) { + if (($intest == 0) || ($intestcase == 0) || ($inassert == 0)) { + $BadTest = 1; + $BadTestReason = "R:$intest:$intestcase:$inassert:$."; + } + $result = $1; + $inresult = 1; + if ($result =~ /FAIL|UNRESOLVED|UNINITIATED/) { + # + # skip if in the (ignorable) well known test problems list + # + if (defined($wktp{"$funcname:$anum"})) { + ++$Notp; + } + else { + $probs{"$funcname:$anum"} = $result; + ++$Nftp; + s/(FAIL|UNITIATED)/$1<\/FONT>/; + s/(UNRESOLVED)/$1<\/FONT>/; + + } + } + elsif ($result =~ /PASS|UNTESTED/) { + s/(PASS|UNTESTED)/$1<\/FONT>/; + } + printf(YYY "%s\n
\n", $_); + next; + } + } + close(XXX); + printf(YYY "\n"); + close(YYY); + + if ($ntestsets == 0) { + $BadTest = 1; + $BadTestReason = "no tests"; + } + return(%probs); +} + +# +# write the build problems file +# + +sub wbpf { + local($hostid, %buildprobs) = @_; + local($prob, $filename, $lastfilename, $linenumber, $severity); + local(@messageset, $message); + + open(XXX, "> $HostPath/$hostid/$BuildStatusFile"); + + printf(XXX "\n"); + printf(XXX "\n"); + printf(XXX "\n"); + + foreach $prob (sort keys %buildprobs) { + + ($filename, $linenumber, $severity) = split(/\:/, $prob); + + printf(XXX "

%s\n
\n", $filename) if ($filename ne $lastfilename); + + @messageset = split(/\n/, $buildprobs{$prob}); + foreach $message (@messageset) { + if ($severity >= $HaltLevel) { + printf(XXX "%s\n
\n", $message); + } + elsif ($severity == 0) { + printf(XXX "%s\n
\n", $message); + } + else { + printf(XXX "%s\n
\n", $message); + } + } + $lastfilename = $filename; + } + + printf(XXX "\n"); + close(XXX); +} +