#!/perl use CGI; #/* # * The contents of this file are subject to the Mozilla Public # * License Version 1.1 (the "License"); you may not use this file # * except in compliance with the License. You may obtain a copy of # * the License at http://www.mozilla.org/MPL/ # * # * Software distributed under the License is distributed on an "AS # * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or # * implied. See the License for the specific language governing # * rights and limitations under the License. # * # * The Original Code is mozilla.org code. # * # * The Initial Developer of the Original Code is Sun Microsystems, # * Inc. Portions created by Sun are # * Copyright (C) 1999 Sun Microsystems, Inc. All # * Rights Reserved. # * # * Contributor(s): # */ $LogPath = "/log"; $URLRoot = "/log"; $LST_FILE = ""; $RESULT_FILE = ""; $CURRENT_LOG = ""; $DESCR_FILE = "$LogPath//"; $DESCRIPTION_FILE_NAME = ""; $COMPARISIONS_FOLDER_NAME = ""; $LogNPath = ""; $file_name = ""; $query = new CGI; ######################### Main ######################################## $stage = $query->param('stage'); if($stage == 1){ CreateLogsList(); }elsif($stage == 2){ $gold_res = $query->param('gold'); $comp_res = $query->param('compared'); #@logsToDiff = $query->param('LogsToDiff'); DiffIt(); } exit 0; ####################################################################### sub CreateLogsList{ opendir THATDIR, $LogPath; @allfiles = grep -d, map "$LogPath/$_", grep !/^\.\.?$/, readdir THATDIR; closedir THATDIR; $size = @allfiles; %IDs = (); for($i=0; $i<$size; $i++){ $_ = $allfiles[$i]; s#$LogPath/##; if($_=~/CurrentLog/){ }else{ if((-e "$LogPath/$_/$RESULT_FILE") && (-e "$LogPath/$_/$DESCRIPTION_FILE_NAME")){ open(DESCR_FILE, "$LogPath/$_/$DESCRIPTION_FILE_NAME"); @LINES = ; close(DESCR_FILE); ($tmp, $descr) = split(/=/, $LINES[1]); ($tmp, $time) = split(/=/, $LINES[2]); chomp($descr); chomp($time); $descr = cutString($descr); $tmp = "Unique ID: $_ \\nExecution date and time: \\n$time \\nDescription: \\n$descr"; $IDs{$_} = $tmp; #print "$_$time$descr\n"; }else{ #print "no file in : $_\n"; } } } $javascript0 =" function checkit() {\n if(document.form1.gold.selectedIndex==document.form1.compared.selectedIndex) {\n"; $javascript0 .=" alert(\"You cannot diff equals logs\\n\"+\n \"Please select a different logs to diff.\")\n"; $javascript0 .=" }else{\n document.form1.submit();\n }\n"; $javascript0 .=" }\n"; $javascript1 .=" function Change_comment1() {\n"; $javascript2 .=" function Change_comment2() {\n"; $i=0; foreach $key(keys(%IDs)){ $javascript1 .=" if (document.form1.gold.selectedIndex==$i) document.form1.first.value=\"$IDs{$key}\";\n"; $javascript2 .=" if (document.form1.compared.selectedIndex==$i) document.form1.second.value=\"$IDs{$key}\";\n"; $i++; $options_string1 .= "\n "; $options_string2 .= "\n "; } $javascript1 .= " }\n"; $javascript2 .= " }\n"; $javascript = "\n"; print "Content-type:text/html\n\n"; print "\n\nSelect Log of responsiveness test for making diff\n\n"; print "\n$javascript\n

Select Log of responsiveness test for making diff

\n"; print "
/manager.cgi\" name=form1 method=post>\n\n"; print "\n \n \n\n"; print "\n \n \n\n"; print "
Gold: \n
Compared: "; print "
\n"; print "\n\n"; print ""; print "
\n"; print "\n"; } ####################################################################### sub DiffIt{ open(RESULT_FILE_GOLD, "$LogPath/$gold_res/$RESULT_FILE"); @LINES_GOLD = ; close(RESULT_FILE_GOLD); open(RESULT_FILE_COMP, "$LogPath/$comp_res/$RESULT_FILE"); @LINES_COMP = ; close(RESULT_FILE_COMP); $SIZE_GOLD = @LINES_GOLD; $SIZE_COMP = @LINES_COMP; open(DESCRIPTION_FILE_GOLD, "$LogPath/$gold_res/$DESCRIPTION_FILE_NAME"); @LINES_DESCR_GOLD = ; close(DESCRIPTION_FILE_GOLD); open(DESCRIPTION_FILE_COMP, "$LogPath/$comp_res/$DESCRIPTION_FILE_NAME"); @LINES_DESCR_COMP = ; close(DESCRIPTION_FILE_COMP); ($tmp, $descr_gold) = split(/=/, $LINES_DESCR_GOLD[1]); ($tmp, $time_gold) = split(/=/, $LINES_DESCR_GOLD[2]); chomp($descr_gold); chomp($time_gold); ($tmp, $descr_comp) = split(/=/, $LINES_DESCR_COMP[1]); ($tmp, $time_comp) = split(/=/, $LINES_DESCR_COMP[2]); chomp($descr_comp); chomp($time_comp); for($i=0;$i<$SIZE_GOLD;$i++){ ($test_id, $result) = split(/=/, $LINES_GOLD[$i]); chomp($result); $TestRes{$test_id} = $result; } for($i=0;$i<$SIZE_COMP;$i++){ ($test_id, $result) = split(/=/, $LINES_COMP[$i]); chomp($result); if(defined $TestRes{$test_id}){ $tmp = $TestRes{$test_id}; $TestRes{$test_id} = "$tmp".";"."$result"; }else{ $TestRes{$test_id} = "0;"."$result"; } } foreach $key(keys(%TestRes)){ if($TestRes{$key}=~/;/){}else{ $TestRes{$key} = $TestRes{$key}.";0"; } } $file_name = "$gold_res"."_"."$comp_res".".html"; if(-d "$LogPath/$COMPARISIONS_FOLDER_NAME"){ open(FILE_COMPARISION, ">$LogPath/$COMPARISIONS_FOLDER_NAME/$file_name"); }else{ mkdir("$LogPath/$COMPARISIONS_FOLDER_NAME", 0777) || die "cannot mkdir "; open(FILE_COMPARISION, ">$LogPath/$COMPARISIONS_FOLDER_NAME/$file_name"); } print FILE_COMPARISION "\n\nDiff of two tests\n\n"; print FILE_COMPARISION "\n

Diff between two tests, UID\'s is: $gold_res & $comp_res

\n"; print FILE_COMPARISION "Gold tests is:
\n
Unique ID: $gold_res
\nTime: $time_gold
\nDescription: $descr_gold\n
"; print FILE_COMPARISION "Compared tests is:
\n
Unique ID: $comp_res
\nTime: $time_comp
\nDescription: $descr_comp\n
\n"; print FILE_COMPARISION "\n"; print FILE_COMPARISION "\n \n \n \n \n\n"; foreach $key(keys(%TestRes)){ ($gold, $comp) = split(/;/, $TestRes{$key}); if($gold!=0 && $comp!=0){ $proc = $gold - $comp / $gold; $proc = $proc * 100; }else{ if($gold==0){ $gold = "undef"; } if($comp==0){ $comp = "undef"; } $proc = "undef"; } print FILE_COMPARISION "\n \n \n \n \n\n"; } print FILE_COMPARISION "
Test nameGold ResultCompared Result %
$key$gold$comp"; if($proc=~/undef/){ print FILE_COMPARISION "$proc"; }else{ printf FILE_COMPARISION "%d", $proc; } print FILE_COMPARISION "
\n"; print FILE_COMPARISION "\n"; close FILE_COMPARISION; redirect("$URLRoot/$COMPARISIONS_FOLDER_NAME/$file_name"); } ####################################################################### sub cutString { $input = shift(@_); $in = 35; $output = ""; $old_index = 0; $tmp = $input; while($in