diff --git a/mozilla/tools/tinderbox/qatest.pl b/mozilla/tools/tinderbox/qatest.pl new file mode 100755 index 00000000000..c14299d3b06 --- /dev/null +++ b/mozilla/tools/tinderbox/qatest.pl @@ -0,0 +1,417 @@ +#!/usr/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- +# +################################################################### +# Report Summary Generator for ARMS v2.0 by Vladimir Ermakov +################################################################### +# This file parses through a results file and generates a +# test summary giving the following info: +# # of tcs passed +# # of tcs failed +# # of tcs died +# % of pass and fail +# List of testcases that failed. +# Separates the results into suites with a convinient quick link +# at the top of the page +################################################################### +# Questions Coments go to vladimire@netscape.com +################################################################### + +sub PrintUsage { + die < +END_USAGE +} + + +if ($#ARGV != 0) { + PrintUsage(); +} + +$DATAFILE = $ARGV[0]; + +#my $resultsdir = "results"; +my $ngdir = "http://geckoqa.mcom.com/ngdriver/"; #$input->url(-base=>1) . "/ngdriver/"; +my $ngsuites = $ngdir . "suites/"; +my $conffile = "ngdriver.conf"; +my $HTMLreport = ""; + +print "Content-type: text/html\n\n"; + + +&generateResults; + +$File{'SuiteList'} = \@suiteArray; + +&generateHTML; + +$File{'Project'} = "Buffy"; + +#$File{'Name'} =~ /(.*)\./i; +#if(!open(OUTFILE,">$resultsdir/sum-$1.html")) +# { +# print "Cant create file!\n"; +# return -1; +# } + +#print OUTFILE $HTMLreport; + + +print $HTMLreport; + +#close OUTFILE; +# +# ShowHTML(); +#} +#else{ +# print "

Wrong Results Version...

\n\n"; +#} + + + + +sub generateResults + { + + + if (!open(INFILE,$DATAFILE)) { + print "DATAFILE = $DATAFILE\n"; + print "

Cannot open $?, $!

\n"; + return -1; + } + + $File{'tcsPass'} = 0; + $File{'tcsFail'} = 0; + $File{'tcsDied'} = 0; + $File{'tcsTotal'} = 0; + + $line = ; + while ($line) { + my %Suite = (); + + my @diedArray = (); + $Suite{'DiedList'} = \@diedArray; + my @testArray = (); + $Suite{'FailedList'} = \@testArray; + + # Skip to first anchor. + while (!($line =~ //i) && $line) { + $line = ; # Go to next line. + } + + # First anchor. + $line =~ /

(.*?)<\/H1>/i; + + + my $name = $1; + my $title =$2; + #if(!$name){ + # $Suite{'Name'} = $input->param('suite'); + # $Suite{'Title'}= $input->param('suite'); + #} + #else{ + $Suite{'Name'} = $name; + $Suite{'Title'} = $title; + #} + + $Suite{'tcsPass'} = 0; + $Suite{'tcsFail'} = 0; + $Suite{'tcsDied'} = 0; + $Suite{'tcsTotal'} = 0; + + my $i = 0; + + do + { + $i++; print "i = $i "; + + while ($line && !($line =~ //i) && !($line =~ //i)) { + $line = ; + } + + if (!$line) { + print "no line\n"; + } + + if ($line && ($line =~ //i) && ($1 eq $Suite{'Name'})) { + print "XXX \$line = $line\n"; + print "XXX \$1 = $1\n"; + $line = ; + } + + # TC = test case. + if ($line && ($line =~ //i)) { + while ($line && !($line =~ //i)) { + $line1 = ; + if ($line1 =~ //i) { + print "

SOMETHING WRONG!


"; next; next; + } + $line .= $line1; + } + + my ($tfName, $tcStat); + my @lines = split /<->/, $line; + $tfName = $lines[1]; + $tcStat = $lines[3]; + + if ($tcStat eq 'D') { + $Suite{'tcsDied'} += 1; + push(@diedArray,$line); + } + if ($tcStat eq 'P') { + $Suite{'tcsPass'} += 1; + $Suite{'tcsTotal'} += 1; + } + if ($tcStat eq 'F') { + push(@testArray,$line); + $Suite{'tcsFail'} += 1; + $Suite{'tcsTotal'} += 1; + } + $line = ; + } + } while ($line && !($line =~ /
/i) && $line); + + $File{'tcsPass'} += $Suite{'tcsPass'}; + $File{'tcsFail'} += $Suite{'tcsFail'}; + $File{'tcsTotal'} += $Suite{'tcsTotal'}; + $File{'tcsDied'} += $Suite{'tcsDied'}; + push(@suiteArray,\%Suite); + } + close INFILE; + 1; + } + +sub generateHTML + { + my $prjExtension; + my %extList; + + my $os = `uname -s`; # Cheap OS id for now + + $HTMLreport .= < + + + Test Result Summary on $File{'Platform'} + + + + +

AUTOMATED TEST RESULTS


+
+ + + + + + +
OS: $os
+
+
+

The Following Test Suites Were Run:

+
    +END_PRINT + + if (!open(CONFFILE,$conffile)) { + + $HTMLreport .= "

    ERROR - Could not read in the configuration!

    "; + $var = 0; + while ($File{'SuiteList'}->[$var]->{'Name'}) { + if ($File{'SuiteList'}->[$var]->{'Name'} eq "forms") { + + $HTMLreport .= "
  • [$var]->{'Name'}\">$File{'SuiteList'}->[$var]->{'Title'}
  • \n"; + $var++; + } + } + } else { + my %Matrices; + +# while () { +# if ($_ =~ /addTCMatrix\("(.*?)","(.*?)"\);/i) { +# $Matrices{$1} = $2; +# } +# if ($_ =~ /addProject\("(.*?)","(.*?)"\);/i) { +# print "XXX \$_ = $_"; +# if ($File{'Project'} eq $1) { +# $prjExtension = $2; +# $prjExtension =~ s/,/\|/ig; +# } +# } +# if ($_ =~ /addExtension\("(.*?)","(.*?)"\);/i) { +# $extList{$1} = $2; +# } +# } + + +$extList{"mb"} = "http://cemicrobrowser.web.aol.com/bugReportDetail.php?RID=%"; +$extList{"bs"} = "http://bugscape.nscp.aoltw.net/show_bug.cgi?id=%"; +$extList{"bz"} = "http://bugzilla.mozilla.org/show_bug.cgi?id=%"; +$extList{"bzx"} = "http://bugzilla.mozilla.org/show_bug.cgi?id=%"; + + +$prjExtension = "bz"; # Buffy hard-coded here. + +$Matricies{"dom-core"} = "http://geckoqa.mcom.com/browser/standards/dom1/tcmatrix/index.html"; +$Matricies{"dom-html"} = "http://geckoqa.mcom.com/browser/standards/dom1/tcmatrix/index.html"; +$Matricies{"domevents"} = "http://geckoqa.mcom.com/browser/standards/dom1/tcmatrix/index.html"; +$Matricies{"javascript"} = "http://geckoqa.mcom.com/browser/standards/javascript/tcmatrix/index.html"; +$Matricies{"forms"} = "http://geckoqa.mcom.com/browser/standards/form_submission/tcmatrix/index.html"; +$Matricies{"formsec"} = "http://geckoqa.mcom.com/browser/standards/form_submission/tcmatrix/index.html"; + + + + + close(CONFFILE); + for (my $var = 0;$File{'SuiteList'}->[$var]->{'Name'};$var++) { + if (my $href = $Matrices{$File{'SuiteList'}->[$var]->{'Name'}}) { + $HTMLreport .= "
  • $File{'SuiteList'}->[$var]->{'Title'}
  • \n"; + } else { + $HTMLreport .= "
  • [$var]->{'Name'}\">$File{'SuiteList'}->[$var]->{'Title'}
  • \n"; + } + } + } + $HTMLreport .= < + +

    Test Result Summary:

    + + + + + + + + + +END_PRINT + + for (my $var = 0;$File{'SuiteList'}->[$var]->{'Name'};$var++) { + $curSuite = $File{'SuiteList'}->[$var]; + + $HTMLreport .= " \n"; + $HTMLreport .= " \n"; + $HTMLreport .= " \n"; + $HTMLreport .= " \n"; + $HTMLreport .= " \n"; + $HTMLreport .= " \n"; + + my $pctPass = $File{'SuiteList'}->[$var]->{'tcsPass'} / $File{'SuiteList'}->[$var]->{'tcsTotal'}; + $pctPass = int($pctPass*10000)/100; + + $HTMLreport .= " \n"; + + my $pctFail = $File{'SuiteList'}->[$var]->{'tcsFail'} / $File{'SuiteList'}->[$var]->{'tcsTotal'}; + $pctFail = int($pctFail*10000)/100; + + $HTMLreport .= " \n"; + $HTMLreport .= " \n"; + } + + $HTMLreport .= < + + + + + +END_PRINT + my $pctPass = $File{'tcsPass'} / $File{'tcsTotal'}; + $pctPass = int($pctPass*10000)/100; + my $pctFail = $File{'tcsFail'} / $File{'tcsTotal'}; + $pctFail = int($pctFail*10000)/100; + + $HTMLreport .= <$pctPass + + +
     PassedFailedTotal RunDied% Passed% Failed
    {'Name'}\">$curSuite->{'Title'}$File{'SuiteList'}->[$var]->{'tcsPass'}$File{'SuiteList'}->[$var]->{'tcsFail'}$File{'SuiteList'}->[$var]->{'tcsTotal'}${@{$File{'SuiteList'}}[$var]}{'tcsDied'}$pctPass$pctFail
    Total:$File{'tcsPass'}$File{'tcsFail'}$File{'tcsTotal'}$File{'tcsDied'}$pctFail
    + +

    Failed Testcases:

    +END_PRINT + + my $curSuite; + for (my $var=0;$File{'SuiteList'}->[$var]->{'Name'};$var++) { + $curSuite = $File{'SuiteList'}->[$var]; + + $HTMLreport .= < +

    + $curSuite->{'Title'}

    + Died: + +END_PRINT + + for (my $dcnt = 0;$curFile = $File{'SuiteList'}->[$var]->{'DiedList'}->[$dcnt];$dcnt++) { + ($none,$fName) = split(/<->/,$curFile); + $HTMLreport .= "\n"; + } + + $HTMLreport .= "
    $fName

    \n"; + $HTMLreport .= "Failures:
    "; + $HTMLreport .= "\n"; + + for ($fcnt = 0;$curFile = $File{'SuiteList'}->[$var]->{'FailedList'}->[$fcnt];$fcnt++) { + ($none,$fName,$fDesc,$fStat,$fBug,$fExpected,$fActual) = split(/<->/,$curFile); + $HTMLreport.= "\n"; + + # $fBug =~ s/(\d+)($prjExtension)/makelink($1,$extList{$2})/ige; + # $HTMLreport.= "$fBug\n"; + + } + $HTMLreport .= "
    {'Name'}/$fName\" target=\"_new\">$fName"; + + + # Quiet perl warnings about unused variables. + my $tmp; $tmp = $fStat; $tmp = $fActual; $tmp = $fExpected; + + # + # TEMPRORAY DISABLED. + # + my @bugList = split(/[\s+]|,/,$fBug); + my $bug = ""; + my $index = 0; + + while ($bugList[$index]) { + if ($bugList[$index] =~ /(\d+)$prjExtension/i) { + $bugList[$index] =~ s/(\d+)($prjExtension)/makelink($1,$extList{$2})/ige; + $bug .= $bugList[$index]; + } + + $index++; + } + $HTMLreport.= "$bug$fDesc
    $fDesc
    \n"; + } + + $HTMLreport .= < + +END_PRINT + + 1; + } + +sub makelink + { + $bugNum = $_[0]; + $bugLnk = $_[1]; + + + $bugLnk =~ s/%/$bugNum/ig; + $bugLnk = "$bugNum"; + + return $bugLnk; + } +########################################################### +# Parameters: none +# Return: 0 if failed, 1 if passed +# Purpose: Show the report summary to the user. +########################################################### +#sub ShowHTML +#{ +# $File{'Name'} =~ /(.*)?\./i; +# open(INFILE,"$resultsdir/sum-$1.html") || return 0; +# print ""; +# close(INFILE); +# 1; +#} +1;