:
eval 'exec perl -wS $0 ${1+"$@"}'
if 0;
#*************************************************************************
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: testlog.pl,v $
#
# $Revision: 1.4 $
#
# last change: $Author: hr $ $Date: 2005-10-27 15:12:24 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
#
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2005 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#*************************************************************************
### globals ###
$is_debug = 0;
$global_log = "log.dat";
%logfiles_list = ("writer", "swlog.dat",
"math", "smalog.dat",
"HTML", "shptlog.dat",
"draw", "sdrwlog.dat",
"impress", "sdlog.dat",
"calc", "sclog.dat",
"chart", "schlog.dat",
"Java", "javalog.dat",
"Database", "dblog.dat"
);
%log = ();
@ApplicationLog = ();
$dont_kill ="dont_deinstall";
$error_str = "error";
$tests_complete = "---";
$gui = $ENV{GUI};
$inpath = $ENV{INPATH};
$cygwin = "cygwin";
if ($^O =~ /cygwin/) {
$gui = $cygwin;
}
if (($gui eq "UNX") or ($gui eq $cygwin)) {
$pathslash = "/";
}
else
{
$pathslash = "\\";
}
$misc = $inpath . $pathslash . "misc" . $pathslash;
$okfile = $misc . "ok.bat";
umask (02);
### sub routines ###
sub test_logfile {
my ($file, $testname) = @_;
my ($line, $failed, $complete, $linecount, $LastLineError);
$failed = 0;
$complete = 0;
$linecount = -1;
$LastLineError = 0;
if (! -e $file) {
print "error: $testname failed! Logfile is missing.\n" if $is_debug;
return (0,0);
}
open TABLE, "<$file" or die "Error: canīt open log file $file]";
while(
) {
$line = $_;
chomp $line;
$linecount++;
if ( $line =~ /$error_str/ ) {
print "error: $testname: $line\n";
$failed = 1;
$LastLineError = 1;
}
elsif ( $line =~ /$tests_complete/ ) {
$complete = 1;
print "$file: $line\n" if $is_debug;
}
else
{
print "$testname: $line\n" if $is_debug;
$LastLineError = 0;
}
}
close TABLE;
print "$failed $complete $LastLineError $linecount\n" if $is_debug;
if (!$complete) {
my $message = "error: $testname: the test was not complete!";
if ((!$failed) || (($failed) && (!$LastLineError))) {
my $errormessage = getLog ($testname, $linecount+1);
if ($errormessage ne "") {
$message .= " $errormessage possibly failed!";
}
}
if (!$failed && !$is_testerror) {
print "$message\n";
}
}
if (!$failed && $complete) {
print "true\n" if $is_debug;
return (1,1);
}
else
{
print "false\n" if $is_debug;
return (0,1);
}
}
sub readGlobalLog {
my ($line);
my $logfilename = $logfiledir . $pathslash . $global_log;
if (! -e $logfilename) {
print "$logfilename: file is missing\n" if $is_debug;
return 0;
}
open TABLE, "<$logfilename" or die "Error: canīt open log file $logfilename]";
my $failed = 0;
my $complete = 0;
my $FirstLine = 1;
while(defined($line = ) and !$complete) {
chomp $line;
if ($FirstLine) {
if ( $line =~ /Sequence of testing/ ) {
$FirstLine = 0;
next;
}
else {
print "$logfilename: $line\n" if $is_debug;
$failed = 1;
return 0;
}
}
else {
if ( $line eq "" ) {
$complete = 1;
next;
}
my @splitedLine = split(/:/,$line);
my $testApplication = $splitedLine [0];
$testApplication =~ s/^ *(.*?) *$/$1/g; #truncate
my $testAction = $splitedLine [1];
@splitedLine = split(/,/,$testAction);
my @log_array = ();
foreach my $action (@splitedLine) {
$action =~ s/^ *(.*?) *$/$1/g; #truncate
if ($action =~ /\//) {
my @splitAction = split(/\//,$action);
my @specialAction;
foreach my $doubleaction (@splitAction) {
$doubleaction =~ s/^ *(.*?) *$/$1/g; #truncate
push (@specialAction, $doubleaction);
}
$action = join (' or ', @specialAction);
foreach my $doubleaction (@splitAction) {
push (@log_array, $action);
}
}
else {
push (@log_array, $action);
}
}
push (@ApplicationLog, $testApplication);
$log{$testApplication} = \@log_array;
}
}
close TABLE;
return 1;
}
sub getLog {
my ($testname, $linecount) = @_;
if ($linecount <= $#{@{$log{$testname}}}) {
return $log{$testname}[$linecount];
}
else {
return "";
}
}
### main ###
$idStr = ' $Revision: 1.4 $ ';
$idStr =~ /Revision:\s+(\S+)\s+\$/
? ($cpflat2minor_rev = $1) : ($cpflat2minor_rev = "-");
print "TestLog -- Version: $cpflat2minor_rev\n";
if (-e $okfile) {
unlink ($okfile);
}
if ( ($#ARGV >-1) && ($#ARGV < 1) ) {
$ARGV[0] =~ s/\"//g;
}
if ( ! ( ($#ARGV < 1) && $ARGV[0] && (-d $ARGV[0]) ) ) {
print "Error! Usage: testlog \n" ;
exit(1);
}
$logfiledir = $ARGV[0];
$is_testerror = 0;
$is_OneTestAvailable = 0;
print "%logfiles_list\n" if $is_debug;
readGlobalLog();
foreach my $applog (@ApplicationLog) {
if (!exists($logfiles_list{$applog})) {
next;
}
my $logname = $logfiles_list{$applog};
$current_file = $logfiledir . $pathslash . $logname;
my ($error, $logfile) = test_logfile ($current_file, $applog);
if ($logfile) {
$is_OneTestAvailable = 1;
}
elsif (!$is_testerror) {
print "error: $applog failed! Logfile is missing.\n";
}
if (!$error) {
$is_testerror = 1;
}
}
# write file to prevent deinstallation of office
if ($is_testerror) {
$dont_del_file = $logfiledir . $pathslash . $dont_kill;
open (ERRFILE, ">$dont_del_file");
print ERRFILE "dont delete flag";
close (ERRFILE);
}
else {
print "$okfile\n" if $is_debug;
open( OKFILE, ">$okfile");
print OKFILE "echo ok!\n";
close( OKFILE );
chmod (0775, "$okfile");
}
if (!$is_OneTestAvailable) {
print "error: no test succeeded! Maybe Office crashed during starting!\n";
}
exit($is_testerror);