From a2e179c936c8da3a68e5bb5bdc1f2133766689a5 Mon Sep 17 00:00:00 2001 From: Ben Greear Date: Wed, 13 May 2020 16:58:12 -0700 Subject: [PATCH] cicd: Process console logs, adding links to problem areas. --- gui/lf_gui_report_summary.pl | 114 ++++++++++++++++++++++++++++++++++- 1 file changed, 112 insertions(+), 2 deletions(-) diff --git a/gui/lf_gui_report_summary.pl b/gui/lf_gui_report_summary.pl index cb17e17f..713ed5ec 100755 --- a/gui/lf_gui_report_summary.pl +++ b/gui/lf_gui_report_summary.pl @@ -20,6 +20,7 @@ use lib "../"; use lib "./"; use Getopt::Long; +use HTML::Entities; our $dir = ""; our $notes = ""; @@ -32,10 +33,10 @@ our $title = "Automated test results."; ######################################################################## our $usage = <<"__EndOfUsage__"; -$0 [ --dir directory-to-process --notes testbed-notes-file.html --gitlog gitlog-output.txt ] +$0 [ --dir directory-to-process --notes testbed-notes-file.html --gitlog gitlog-output.txt ] < html_template.html Example: - $0 --dir ~/tmp/results --title "My Title" --notes testbeds/my_testbed/testbed_notes.html --gitlog /tmp/gitlog.txt + cat html-template | $0 --dir ~/tmp/results --title "My Title" --notes testbeds/my_testbed/testbed_notes.html --gitlog /tmp/gitlog.txt __EndOfUsage__ my $i = 0; @@ -100,8 +101,10 @@ my $tests_tr = ""; foreach my $line (@files) { if ( -d $line) { + #print "Checking report: $line\n"; if ( -d "$line/logs") { $tests_tr .= "$lineLogs\n"; + processLogs("$line/logs"); } else { $tests_tr .= "$line\n"; @@ -149,5 +152,112 @@ while (<>) { exit(0); +sub processLogs { + my $ldir = shift; + + my @files = `ls $ldir`; + chomp(@files); + + foreach $line (@files) { + if ($line =~ /console.*\.txt$/) { + my $tag = 0; + my $logf = $ldir . "/" . $line; + my $logh = $logf . ".html"; + my $loghb = $line . ".html"; + my $loghi = $logf . "-idx.html"; + + #print("Processing log file: $logf\n"); + + open(IFILE, "<", $logf ) or die( "could not read $logf"); + open(IDX, ">$loghi"); + open(LOGH, ">$logh"); + + print IDX getHtmlHdr("Log file index: $line"); + print LOGH getHtmlHdr("Log file: $line"); + + print LOGH "
\n";
+
+         print IDX "Full Logs in HTML format
\n"; + print IDX "Full Logs in Text format

\n"; + print IDX "Interesting log sections.
\n"; + print IDX "

    \n"; + + while () { + my $ln = $_; + chomp($ln); + + #print("ln: $ln\n"); + my $enc_ln = encode_entities($ln); + # Get rid of some funk + $enc_ln =~ s/\&\#0\;//g; + + if (($ln =~ /WARNING:/) || + ($ln =~ /BUG:/) || + ($ln =~ /restarting hardware/) || + ($ln =~ /crashed/)) { + print IDX "
  1. $enc_ln
  2. \n"; + print LOGH "\n"; + print LOGH "
    $enc_ln
    \n"; + $tag++; + } + else { + print LOGH "$enc_ln\n"; + } + } + + #print ("Done with file\n"); + + print LOGH "
\n"; + print IDX "\n"; + + print LOGH getHtmlFooter(); + print IDX getHtmlFooter(); + + close(IDX); + close(LOGH); + close(IFILE); + } + } + print("Done processing logs.\n"); +} + +sub getHtmlHdr { + my $title = shift; + + return "\n" . + "\n" . + " \n" . + " \n" . + " \n" . + " $title \n" . + " \n" . + " \n" . + " \n" . + " \n" . + " \n" . + "
\n" . + "

$title


\n" . + "\n" . + "
\n"; +} + +sub getHtmlFooter { + return "
\n" . + "
Generated by Candela Technologies LANforge network testing tool.
\n" . + " www.candelatech.com\n" . + "
\n" . + "

\n" . + " \n" . + "\n"; +} + # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----