diff options
Diffstat (limited to 'testgraphical/source')
-rw-r--r-- | testgraphical/source/CallExternals.pm | 539 | ||||
-rw-r--r-- | testgraphical/source/ConvwatchHelper.pm | 574 | ||||
-rw-r--r-- | testgraphical/source/compare.pl | 408 | ||||
-rw-r--r-- | testgraphical/source/cwstestresult.pl | 208 | ||||
-rw-r--r-- | testgraphical/source/cwstestresulthelper.pm | 268 | ||||
-rw-r--r-- | testgraphical/source/dbhelper.pm | 209 | ||||
-rw-r--r-- | testgraphical/source/filehelper.pm | 358 | ||||
-rw-r--r-- | testgraphical/source/fill_documents_loop.pl | 423 | ||||
-rw-r--r-- | testgraphical/source/graphical_compare.pm | 586 | ||||
-rw-r--r-- | testgraphical/source/loghelper.pm | 94 | ||||
-rw-r--r-- | testgraphical/source/makefile.mk | 112 | ||||
-rw-r--r-- | testgraphical/source/oshelper.pm | 110 | ||||
-rw-r--r-- | testgraphical/source/solarenvhelper.pm | 63 | ||||
-rw-r--r-- | testgraphical/source/stringhelper.pm | 69 | ||||
-rw-r--r-- | testgraphical/source/timehelper.pm | 99 |
15 files changed, 4120 insertions, 0 deletions
diff --git a/testgraphical/source/CallExternals.pm b/testgraphical/source/CallExternals.pm new file mode 100644 index 000000000000..a0a3b1ae716a --- /dev/null +++ b/testgraphical/source/CallExternals.pm @@ -0,0 +1,539 @@ +package CallExternals; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use English; +use warnings; +use strict; +use loghelper; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.29 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&callphp &getPHPExecutable &ExecSQL &callperl &getPerlExecutable &calljava &setJavaExecutable &getJavaExecutable &setToolsPath "e "eIfNeed &set_logfile &close_logfile ); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + +# ------------------------------------------------------------------------------ +# small helper, which replaces the return code +sub errorAdaption($) +{ + my $error = shift; + if ($error != 0) + { + $error = $error / 256; + } + if ($error > 127) + { + $error = $error - 256; + } + return $error; +} +# ------------------------------------------------------------------------------ +# helper to call external php with popen +sub callphp($$$) +{ + local *IN_FILE; + my $phpexe = shift; + my $phpprogram = shift; + my $sParams = shift; + my $line; + my $error; + my @result; + + # print "Will send: $phpexe $sParams\n"; + # log_print("CALLPHP: $phpexe $phpprogram $sParams\n"); +# if (open(IN_FILE, "$phpexe $sParams 2>&1 |")) + if (open(IN_FILE, "$phpexe $phpprogram $sParams |")) + { + while ($line = <IN_FILE>) + { + chomp($line); + # $line .= " "; + push(@result, $line); + # print "callphp output: $line\n"; + } + close(IN_FILE); + $error = errorAdaption($?); + } + else + { + print "callphp(): Can't popen '$phpexe' with parameter: '$sParams'\n"; + $error = 1; + } + return $error, @result; +} + +# ------------------------------------------------------------------------------ +sub getPHPExecutable() +{ + my $phpexe; + if ($OSNAME eq "solaris") + { + $phpexe = "php5"; + } + elsif ($OSNAME eq "linux") + { + if ( -e "/usr/bin/php5") # Suse :-( + { + $phpexe = "php5"; + } + elsif ( -e "/usr/bin/php") # Gentoo + { + $phpexe = "php"; + } + else + { + print "getPHPExecutable(): no php exec found.\n"; + } + } + elsif ( $OSNAME eq "MSWin32" ) + { + $phpexe = "C:/programme/php/php.exe"; + # add second try (xampp) + if (! -e $phpexe) + { + $phpexe = "C:/xampp/php/php.exe"; + } + } + elsif ( $OSNAME eq "cygwin" ) + { + $phpexe = "/cygdrive/c/programme/php/php"; + } + else + { + print "getPHPExecutable(): unknown environment. ($OSNAME)\n"; + } + if (! $phpexe) + { + print "getPHPExecutable(): ERROR: php executable not found.\n"; + exit(1); + } + return $phpexe; +} +# ------------------------------------------------------------------------------ +# helper to call external java with popen +sub calljava($$$) +{ + local *IN_FILE; + my $javaexe = shift; + my $sParams = shift; + my $sDebug = shift; + my $line; + my $error = 1; + + if (! $javaexe) + { + log_print("ERROR: javaexe not set.\n"); + return; + } + if (! $sDebug) + { + $sDebug = ""; + } + $javaexe = quoteIfNeed($javaexe); + log_print ("CALLJAVA: $javaexe $sDebug $sParams\n"); + if (open(IN_FILE, "$javaexe $sDebug $sParams 2>&1 |")) + { + while ($line = <IN_FILE>) + { + chomp($line); + log_print ("- $line\n"); + } + close(IN_FILE); + $error = errorAdaption($?); + } + else + { + log_print ("calljava(): Can't popen '$javaexe' with parameter '$sParams'\n"); + $error = 1; + } + return $error; +} + +# ------------------------------------------------------------------------------ +sub getPerlExecutable() +{ + my $perlexe; + if ( $ENV{PERL} ) + { + $perlexe = $ENV{PERL}; + } + elsif ( $ENV{PERLEXE} ) + { + $perlexe = $ENV{PERLEXE}; + } + else + { + if ($OSNAME eq "MSWin32") + { + $perlexe="C:/xampp/perl/bin/perl.exe"; + if (! -e $perlexe) + { + $perlexe="r:/btw/perl/bin/perl"; + } + if (! -e $perlexe) + { + $perlexe="C:/Programme/Perl/bin/perl.exe"; + } + } + elsif ($OSNAME eq "cygwin") + { + $perlexe = "perl"; + } + elsif ($OSNAME eq "solaris") + { + $perlexe="/so/env/bt_solaris_intel/bin/perl"; + } + elsif ($OSNAME eq "linux") + { + $perlexe="/so/env/bt_linux_libc2.32/DEV300/bin/perl"; + } + else + { + log_print "WARNING: Use only the fallback of perl executable.\n"; + $perlexe = "perl"; # FALLBACK + } + } + if ( ! -e $perlexe) + { + log_print "getPerlExecutable(): There exist no perl executable.\n"; + exit(1); + } + return $perlexe; +} +# ------------------------------------------------------------------------------ +# helper to call external perl with popen +sub callperl($$$) +{ + local *IN_FILE; + my $perlexe = shift; + my $perlprogram = shift; + my $sParams = shift; + my $line; + my $error; + + log_print("CALLPERL: $perlexe $perlprogram $sParams\n"); +# if (open(IN_FILE, "$perlexe $sParams 2>&1 |")) + if (open(IN_FILE, "$perlexe $perlprogram $sParams |")) + { + while ($line = <IN_FILE>) + { + chomp($line); + log_print ("- $line\n"); + } + close(IN_FILE); + $error = errorAdaption($?); + } + else + { + log_print ("Can't popen '$perlexe' with parameter: '$sParams'\n"); + $error = 1; + } + return $error; +} +# ------------------------------------------------------------------------------ +our $sJavaExecutable; +sub setJavaExecutable($) +{ + $sJavaExecutable = shift; +} + +# sub getJava14() +# { +# my $sJava14; +# if ($OSNAME eq "MSWin32") +# { +# if ($sJavaExecutable) +# { +# $sJava14 = $sJavaExecutable; +# } +# else +# { +# # HARDCODE! +# $sJava14 = "C:\\Programme\\Java\\j2re1.4.2_10\\bin\\java.exe"; +# } +# } +# else +# { +# if ($sJavaExecutable) +# { +# $sJava14 = $sJavaExecutable; +# } +# else +# { +# # HARDCODE! +# $sJava14 = "/opt/java14/bin/java"; +# } +# } +# if ( ! -e $sJava14 ) +# { +# log_print ("Java14 not found. Is searched in '$sJava14'\n"); +# # exit(1); +# return ""; +# } +# return $sJava14; +# } +# ------------------------------------------------------------------------------ +sub getJava15() +{ + my $sJava15; + if ($sJavaExecutable) + { + $sJava15 = $sJavaExecutable; + } + else + { + if ($OSNAME eq "MSWin32") + { + # HARDCODE! + $sJava15 = "C:\\Programme\\Java\\jre1.5.0_22\\bin\\java.exe"; + if ( ! -e $sJava15) + { + $sJava15 = "C:\\Program Files\\Java\\jre6\\bin\\java.exe"; + } + if ( ! -e $sJava15) + { + $sJava15 = "C:\\Java\\jdk1.6\\bin\\java.exe"; + } + } + elsif ($OSNAME eq "cygwin") + { + $sJava15 = "java"; + } + else + { + # HARDCODE! + if ($OSNAME eq "solaris") + { + $sJava15 = "/usr/bin/java"; + } + else + { + $sJava15 = "/usr/bin/java"; + if ( ! -e $sJava15 ) + { + $sJava15 = "/opt/java15/bin/java"; + } + } + } + if ( ! -e $sJava15 ) + { + log_print ("Java15 not found. Is searched in '$sJava15'\n"); + # exit(1); + return ""; + } + } + return $sJava15; +} +# ------------------------------------------------------------------------------ +sub getJava16() +{ + my $sJava16; + if ($sJavaExecutable) + { + $sJava16 = $sJavaExecutable; + } + else + { + if ($OSNAME eq "MSWin32") + { + # HARDCODE! + $sJava16 = "C:\\Programme\\Java\\jre1.6.0_16\\bin\\java.exe"; + if ( ! -e $sJava16) + { + $sJava16 = "C:\\Program Files\\Java\\jre6\\bin\\java.exe"; + } + if ( ! -e $sJava16) + { + $sJava16 = "C:\\Java\\jdk1.6\\bin\\java.exe"; + } + # } + } + elsif ($OSNAME eq "cygwin") + { + # $sJava16 = "java"; + $sJava16 = "C:/Program Files/Java/jdk1.6.0_16/bin/java.exe"; + } + else + { + # HARDCODE! + if ($OSNAME eq "solaris") + { + $sJava16 = "/usr/bin/java"; + } + else + { + $sJava16 = "/usr/bin/java"; + if ( ! -e $sJava16 ) + { + $sJava16 = "/opt/java16/bin/java"; + } + } + } + if ( ! -e $sJava16 ) + { + log_print ("Java16 not found. Is searched in '$sJava16'\n"); + # exit(1); + return ""; + } + } + return $sJava16; +} + +# ------------------------------------------------------------------------------ +sub getJavaExecutable() +{ + return getJava16(); +} + +# ------------------------------------------------------------------------------ +# this function is a helper for parameters +# if quotes the whole string with 'STR' or "STR" and replace quotes in it's content for the right. +sub singleQuote($) +{ + my $sStr = shift; + if ( $OSNAME eq "MSWin32") + { + # we are MSWin32 (quote \" stronger) + # $sStr =~ s/\'/\"/g; + $sStr =~ s/\'/\\\"/g; + return "\"" . $sStr . "\""; + } + else + { + if (index($sStr, "'") >= 0) + { + # replace all single quotes ("'") by "\"" + $sStr =~ s/\'/\"/g; + } + } + return "'" . $sStr . "'"; +} + +sub quote($) +{ + my $sName = shift; + return "\"" . $sName . "\""; +} + +sub quoteIfNeed($) +{ + my $sName = shift; + if (-1 != index($sName, " ")) + { + return quote($sName); + } + return $sName; +} + + +# ------------------------------------------------------------------------------ +our $sToolsPath; +sub setToolsPath($) +{ + my $sNewPath = shift; + $sToolsPath = $sNewPath; +} + +sub ExecSQL($) +{ + my $sSQL = shift; + + my $error; + my @aResult; + my $sSQLDirect; + if ($sToolsPath) + { + $sSQLDirect = $sToolsPath; + $sSQLDirect .= "/"; + } + $sSQLDirect .= "sql_direct.php"; + + # select(undef, undef, undef, 0.060); + # log_print("ExecSQL: $sSQL\n"); + # sleep (1); + ($error, @aResult) = callphp(getPHPExecutable(), $sSQLDirect, singleQuote($sSQL)); + if ($error) + { + log_print ("ExecSQL: An Error occured.\n"); + log_print ("PHP: " . getPHPExecutable() . "\n"); + log_print ("SQL Statement: " . singleQuote($sSQL) . "\n"); + # exit(1); + } + # select(undef, undef, undef, 0.125); + # sleep (1); + return @aResult; +} + +# ------------------------------------------------------------------------------ +# helper to call external php with popen +# sub callexe($$$) +# { +# local *IN_FILE; +# my $exe = shift; +# my $program = shift; +# my $sParams = shift; +# my $line; +# my $error; +# my @result; +# +# $exe = quoteIfNeed($exe); +# $program = quoteIfNeed($program); +# +# # print "Will send: $exe $sParams\n"; +# # log_print("CALLEXE: $exe $program $sParams\n"); +# if (open(IN_FILE, "$exe $program $sParams |")) +# { +# while ($line = <IN_FILE>) +# { +# chomp($line); +# # $line .= " "; +# push(@result, $line); +# # print "callphp output: $line\n"; +# } +# close(IN_FILE); +# $error = errorAdaption($?); +# } +# else +# { +# print "Can't popen '$exe' with parameter: '$sParams'\n"; +# $error = 1; +# } +# return $error, @result; +# } + +1; diff --git a/testgraphical/source/ConvwatchHelper.pm b/testgraphical/source/ConvwatchHelper.pm new file mode 100644 index 000000000000..8f157641b1f4 --- /dev/null +++ b/testgraphical/source/ConvwatchHelper.pm @@ -0,0 +1,574 @@ +package ConvwatchHelper; + +use English; +use warnings; +use strict; +use Cwd; +use Cwd 'chdir'; + +use CallExternals; +use stringhelper; +use filehelper; +use oshelper; +use loghelper; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.39 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&getQADEVToolsPath &setProjectRoot &getProjectRoot &checkForStop &getSofficeExe &setINPATH); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + +# ------------------------------------------------------------------------------ +our $tempprefix; + +# sub getTempDir() +# { +# my $sTempDir; +# if (! $tempprefix) +# { +# if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") +# { +# # $tempdir = "C:/gfxcmp/temp"; +# $tempprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci/temp"; +# } +# elsif ($OSNAME eq "linux") +# { +# $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi/temp"; +# } +# elsif ($OSNAME eq "solaris") +# { +# # $tempdir = "/space/gfxcmp/temp"; +# $tempprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli/temp"; +# } +# else +# { +# print "Error: This environment isn't supported yet.\n"; +# exit(1); +# } +# } +# $sTempDir = $tempprefix; +# return $sTempDir; +# } +# ------------------------------------------------------------------------------ +# in filehelper +# our $programprefix; +# +# sub getProgramPrefix($) +# { +# my $sDBDistinct = shift; +# +# my $sProgramPrefix; +# if (! $programprefix) +# { +# if ($OSNAME eq "MSWin32") +# { +# # $programprefix = "C:/gfxcmp/programs"; +# $programprefix = "C:/gp"; +# } +# elsif ($OSNAME eq "linux") +# { +# $programprefix = "/space/gfxcmp/programs"; +# } +# elsif ($OSNAME eq "solaris") +# { +# $programprefix = "/space/gfxcmp/programs"; +# } +# else +# { +# print "Error: This environment isn't supported yet.\n"; +# exit(1); +# } +# } +# $sProgramPrefix = appendPath($programprefix, substr($sDBDistinct, 0, 19)); +# return $sProgramPrefix; +# } +# ------------------------------------------------------------------------------ +sub getQADEVToolsPath() +{ + my $sNewPath = appendPath(getToolsPrefix(), "qadev"); + $sNewPath = appendPath($sNewPath, "scripts"); + $sNewPath = appendPath($sNewPath, "gfxcmp_ui"); + return $sNewPath; +} + +# in filehelper +# our $toolsprefix; +# +# sub getToolsPrefix() +# { +# my $sToolsPrefix; +# if (! $toolsprefix) +# { +# if ($OSNAME eq "MSWin32") +# { +# $toolsprefix = "C:/gfxcmp/tools"; +# } +# elsif ($OSNAME eq "linux") +# { +# $toolsprefix = "/space/gfxcmp/tools"; +# } +# elsif ($OSNAME eq "solaris") +# { +# $toolsprefix = "/space/gfxcmp/tools"; +# } +# else +# { +# print "Error: This environment isn't supported yet.\n"; +# exit(1); +# } +# } +# $sToolsPrefix = $toolsprefix; +# return $sToolsPrefix; +# } +# ------------------------------------------------------------------------------ +our $sProjectRoot; +sub setProjectRoot($) +{ + $sProjectRoot = shift; + log_print "\$sProjectRoot := $sProjectRoot\n"; +} +sub getProjectRoot() +{ + if ($sProjectRoot) + { + return $sProjectRoot; + } + die "setProjectRoot(PATH) not set.\n"; +} + +our $sINPATH; +sub setINPATH($) +{ + $sINPATH = shift; +} +sub getINPATH() +{ + if ($sINPATH) + { + return $sINPATH; + } + die "setINPATH(PATH) not set.\n"; +} +our $dataprefix; + +# sub getDataPrefix() +# { +# my $sDataPrefix; +# if (! $dataprefix) +# { +# if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") +# { +# # $dataprefix = "C:/gfxcmp/data"; +# # $dataprefix = "//so-gfxcmp-lin/gfxcmp-data/wntmsci"; +# $dataprefix = getProjectRoot(); +# } +# elsif ($OSNAME eq "linux") +# { +# # $dataprefix = "/space/gfxcmp/data"; +# # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxlngi"; +# $dataprefix = getProjectRoot(); +# } +# elsif ($OSNAME eq "solaris") +# { +# # $dataprefix = "/space/gfxcmp/data"; +# # $dataprefix = "/net/so-gfxcmp-lin/export/gfxcmp/data/unxsoli"; +# $dataprefix = getProjectRoot(); +# } +# else +# { +# print "Error: This environment isn't supported yet.\n"; +# exit(1); +# } +# $dataprefix = appendPath(getProjectRoot(), getINPATH()); +# $dataprefix = appendPath($dataprefix, "data"); +# } +# $sDataPrefix = $dataprefix; +# return $sDataPrefix; +# } + +# ------------------------------------------------------------------------------ + +# sub _shortsleep($) +# { +# # sleep 1; +# select(undef, undef, undef, 0.333); +# } +# +# sub _waitInSeconds($) +# { +# my $nLength = shift; +# my $i; +# my $j; +# +# for ($j=0;$j<$nLength;$j++) +# { +# for ($i=0;$i<$j;$i++) +# { +# print "."; +# } +# for ($i=$j;$i<$nLength;$i++) +# { +# print " "; +# } +# _shortsleep( 1 ); +# print "\r"; +# } +# +# for ($j=0;$j<=$nLength;$j++) +# { +# for ($i=0;$i<$j;$i++) +# { +# print " "; +# } +# for ($i=$j;$i<$nLength;$i++) +# { +# print "."; +# } +# _shortsleep( 1 ); +# print "\r"; +# } +# } +# +# sub wait30seconds() +# { +# _waitInSeconds(20); +# _waitInSeconds(20); +# } + +sub checkForStop($) +{ + my $sStopFilename = shift; + my $sStopFilePath; + if ($OSNAME eq "MSWin32") + { + $sStopFilePath = "C:/temp/"; + } + else + { + $sStopFilePath = "/tmp/"; + } + my $sStopFile = $sStopFilePath . $sStopFilename; + if ( -e "$sStopFile" ) + { + print "Stop of Convwatch tool forced!\n"; + unlink($sStopFile); + exit(2); + } +} + +# ---------------------------------------------------------------------------------------- +sub readdirectory($$$); + +sub readdirectory($$$) +{ + my $startdir = shift; + my $sUserParameter = shift; + my $hook = shift; + + my $myfile; + + local *DIR; + chdir $startdir; + cwd(); + + my $nCountFiles = 0; + if (opendir (DIR, $startdir)) # Directory oeffnen + { + while ($myfile = readdir(DIR)) + { # ein filename holen + #if (! -l $myfile) # not a link + #{ + if (-d $myfile ) # is a directory + { + if ( -l $myfile) + { + next; + } + # if ( $myfile eq "help" || + # $myfile eq "presets" || + # $myfile eq "registry" || + # $myfile eq "uno_packages" || + # $myfile eq "lib" || + # $myfile eq "user_tree" ) + # { + # next; + # } + + if ($myfile ne "." && $myfile ne "..") + { + my $sNewStartDir = appendPath($startdir, $myfile); # neuen Directorystring erstellen + # if ($sNewStartDir =~ "^\/proc" || + # $sNewStartDir =~ "^\/dev" || + # $sNewStartDir =~ "^\/udev" || + # $sNewStartDir =~ "lost+found" ) + # { + # next; + # } + # my $sNewSUserParameter = $sUserParameter . $myfile ."/"; + # do a recursive call + # $nCountFiles++; + my $nFileCount = readdirectory($sNewStartDir, $sUserParameter, $hook); + # workOnDir($sNewDir, $nFileCount); + $nCountFiles += $nFileCount; + + chdir ($startdir); # zurueckwechseln. + cwd(); + } + } + else + { + # File must exist, be a regular file and must not be the $onlyOnFile + if (-f $myfile) + { + # print STDERR " $startdir" . "$myfile\n"; + $nCountFiles++; + # workOnFile($startdir, $myfile, $destdir); + $hook->($startdir, $myfile, $sUserParameter); + } + } + #} + #else + #{ + # print STDERR "linked file: $dir/$myfile\n"; + #} + } + closedir(DIR); + } + else + { + print STDERR "could not open $startdir\n"; + } + return $nCountFiles; +} + +our $lcl_sSofficeBinPath; +our $lcl_sSofficeBinName; + +sub searchSofficeBin($$$) +{ + my $currentDir = shift; + my $currentFile = shift; + my $sUserParameter = shift; + + if ($currentFile eq $sUserParameter) + { + my $sSourceFilename; + $sSourceFilename = appendPath($currentDir, $currentFile); + + if ( -e "$sSourceFilename" ) + { + $lcl_sSofficeBinPath = $currentDir; + $lcl_sSofficeBinName = $currentFile; + } + } +} + +# our $lcl_sUnoPkgPath; +# +# sub searchUnoPkgBin($$$) +# { +# my $currentDir = shift; +# my $currentFile = shift; +# my $sUserParameter = shift; +# +# if ($currentFile eq $sUserParameter) +# { +# my $sSourceFilename; +# $sSourceFilename = appendPath($currentDir, $currentFile); +# if ( -e "$sSourceFilename" ) +# { +# $lcl_sUnoPkgPath = $currentDir; +# } +# } +# } + +# our $lcl_sJARPath; + +# sub searchJARFile($$$) +# { +# my $currentDir = shift; +# my $currentFile = shift; +# my $sUserParameter = shift; +# +# if ($currentFile eq $sUserParameter) +# { +# my $sSourceFilename; +# $sSourceFilename = appendPath($currentDir, $currentFile); +# if ( -e "$sSourceFilename" ) +# { +# $lcl_sJARPath = $currentDir; +# } +# } +# } + +# return the PATH, where the file was found +# sub searchForJAR($$) +# { +# my $sPathToInstallOffice = shift; +# my $sJARFileName = shift; +# +# my $sCurrentPath = cwd(); +# +# $lcl_sJARPath = ""; +# readdirectory(${sPathToInstallOffice}, ${sJARFileName}, \&searchJARFile); +# +# chdir $sCurrentPath; +# cwd(); +# +# return $lcl_sJARPath; +# } + +# sub getUnoPkg($) +# { +# my $sPathToInstallOffice = shift; +# +# my $sUnoPkgName = "unopkg.bin"; +# if (isWindowsEnvironment()) +# { +# $sUnoPkgName = "unopkg.exe"; +# } +# +# my $sCurrentPath = cwd(); +# +# $lcl_sUnoPkgPath = ""; +# readdirectory(${sPathToInstallOffice}, ${sUnoPkgName}, \&searchUnoPkgBin); +# +# chdir $sCurrentPath; +# cwd(); +# +# return ($lcl_sUnoPkgPath, $sUnoPkgName); +# } + +sub getSofficeExe($) +{ + my $sPathToOffice = shift; + + my $sSofficeExeName = "soffice"; + if (isWindowsEnvironment()) + { + $sSofficeExeName = "soffice.exe"; + } + + my $sCurrentPath = cwd(); + + $lcl_sSofficeBinPath = ""; + $lcl_sSofficeBinName = ""; + readdirectory(${sPathToOffice}, ${sSofficeExeName}, \&searchSofficeBin); + + chdir $sCurrentPath; + cwd(); + + return ($lcl_sSofficeBinPath, $lcl_sSofficeBinName); +} + +# sub checkOfficeAlreadyInstalled($) +# { +# my $sOfficePath = shift; +# +# my $sCurrentPath = cwd(); +# +# $lcl_sSofficeBinPath = ""; +# my $sOldOfficePath = appendPath($sOfficePath, "program"); +# if ( -d "$sOldOfficePath" ) +# { +# $sOldOfficePath = appendPath($sOldOfficePath, "soffice.bin"); +# if ( -e $sOldOfficePath ) +# { +# return 1; +# } +# } +# else +# { +# if (isWindowsEnvironment()) +# { +# my $sThreeLayerOffice = appendPath($sOfficePath, "Sun"); +# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "StarOffice 9"); +# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program"); +# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin"); +# +# if ( -e "$sThreeLayerOffice" ) +# { +# return 1; +# } +# } +# else +# { +# my $sThreeLayerOffice = appendPath($sOfficePath, "staroffice9"); +# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "program"); +# $sThreeLayerOffice = appendPath($sThreeLayerOffice, "soffice.bin"); +# if ( -e "$sThreeLayerOffice" ) +# { +# return 1; +# } +# } +# } +# +# # soffice.bin not found in fast path +# readdirectory($sOfficePath, "soffice.bin", \&searchSofficeBin); +# chdir $sCurrentPath; +# cwd(); +# +# if ( $lcl_sSofficeBinPath ne "" ) +# { +# return 1; +# } +# return 0; +# # this is the old check +# # my $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "program"); +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); +# # if ( -e $sOfficePathCheck ) +# # { +# # return 1; +# # } +# # +# # # check path system of tree layer office +# # if ( isWindowsEnvironment() ) +# # { +# # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "Sun"); +# # if ( ! -e $sOfficePathCheck) +# # { +# # # could be an OpenOffice.org +# # return 0; +# # } +# # else +# # { +# # +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "StarOffice 9"); +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "program"); +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); +# # if ( -e $sOfficePathCheck ) +# # { +# # return 1; +# # } +# # print "Error: There exist no Office, maybe an unsupported version?\n"; +# # } +# # } +# # elsif ( isUnixEnvironment() ) +# # { +# # $sOfficePathCheck = appendPath(${sPathToInstallOffice}, "staroffice9"); +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "staroffice9"); +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "program"); +# # $sOfficePathCheck = appendPath($sOfficePathCheck, "soffice.bin"); +# # if ( -e $sOfficePathCheck ) +# # { +# # return 1; +# # } +# # print "Error: There exist no Office, maybe an unsupported version?\n"; +# # } +# # else +# # { +# # print "Error: There exist no Office, maybe an unsupported version?\n"; +# # } +# # return 0; +# } + +1; diff --git a/testgraphical/source/compare.pl b/testgraphical/source/compare.pl new file mode 100644 index 000000000000..4aef877dc2b7 --- /dev/null +++ b/testgraphical/source/compare.pl @@ -0,0 +1,408 @@ +eval 'exec perl -wS $0 ${1+\"$@\"}' + if 0; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +BEGIN +{ + # Adding the path of this script file to the include path in the hope + # that all used modules can be found in it. + $0 =~ /^(.*)[\/\\]/; + push @INC, $1; + # print "PATH: " . $1 . "\n"; +} + +# my $e; +# foreach $e (keys %ENV) +# { +# print "$e := $ENV{$e}" . "\n"; +# } + +use strict; +use graphical_compare; +use ConvwatchHelper; +use filehelper; +use timehelper; +use loghelper; + +use Cwd; +use File::Basename; +use Getopt::Long; +use English; # $OSNAME, ... +use File::Path; +use Cwd 'chdir'; + +our $help; # Help option flag +our $version; # Version option flag +# our $test; + +# our $MAJOR; +# our $MINOR; +# our $cwsname; +our $pool; +our $document; +our $creatortype; +our $prepareonly = 0; +our $force; +our $verbose = 0; +our $show = 0; +our $connectionstring; + +# Prototypes +sub print_usage(*); +sub prepare(); +sub CompareFiles($$); + +# flush STDOUT +# my $old_handle = select (STDOUT); # "select" STDOUT and save # previously selected handle +# $| = 1; # perform flush after each write to STDOUT +# select ($old_handle); # restore previously selected handle + +$OUTPUT_AUTOFLUSH=1; # works only if use English is used. + +our $version_info = 'compare.pl'; + +GetOptions( +# "MAJOR=s" => \$MAJOR, +# "MINOR=s" => \$MINOR, +# "cwsname=s" => \$cwsname, + "pool=s" => \$pool, + "document=s" => \$document, + "creatortype=s" => \$creatortype, + "prepareonly=s" => \$prepareonly, + "connectionstring=s" => \$connectionstring, + + "force" => \$force, + "verbose" => \$verbose, + "show" => \$show, + +# "test" => \$test, + "help" => \$help, + "version" => \$version + ); + +if ($help) +{ + print_usage(*STDOUT); + exit(0); +} +# Check for version option +if ($version) +{ + print STDERR "$version_info\n"; + exit(0); +} + +if ($prepareonly) +{ + $force=1; +} + +prepare(); +if ($connectionstring) +{ + setConnectionString($connectionstring); +} + +my $sDocumentPool = appendPath(getProjectRoot(), "document-pool"); +# print "ProjectRoot: " . getProjectRoot() . "\n"; +if ($ENV{DOCUMENTPOOL}) +{ + if ( -d $ENV{DOCUMENTPOOL}) + { + print "overwrite default Documentpool: '$sDocumentPool'\n"; + print " with \$ENV{DOCUMENTPOOL}: $ENV{DOCUMENTPOOL}\n"; + $sDocumentPool = $ENV{DOCUMENTPOOL}; + } + else + { + print "Given \$DOCUMENTPOOL doesn't exist.\n"; + } +} + +my $err = 0; +my $nCompareTime = getTime(); + +# if we want to check one file, give -pool and -document +# if we want to check the whole pool, give -pool +# if we want to check all, call without parameters +if ($pool) +{ + if ($document) + { + $err = SingleDocumentCompare( $sDocumentPool, + $pool, + $document, + $creatortype, + $prepareonly, + $show + ); + } + else + { + $err = CompareFiles($sDocumentPool, $pool); + } +} +else +{ + local *DIR; + if (opendir (DIR, $sDocumentPool)) # Directory oeffnen + { + my $myfile; + while ($myfile = readdir(DIR)) + { # ein filename holen + if ($myfile eq "." || + $myfile eq "..") + { + next; + } + my $sDocumentPath = appendPath($sDocumentPool, $myfile); + if ( -d $sDocumentPath ) + { + $err += CompareFiles($sDocumentPool, $myfile); + } + elsif ( -f $sDocumentPath ) + { + print "Warning: the file '$myfile' will not compared.\n"; + } + } + closedir(DIR); + } + # my $sPool = "eis-chart"; + # $err += CompareFiles($sDocumentPool, "eis-chart"); + # $err += CompareFiles($sDocumentPool, "eis-impress"); + # $err += CompareFiles($sDocumentPool, "eis-writer"); + # $err += CompareFiles($sDocumentPool, "eis-calc"); + +} + +printTime(endTime($nCompareTime)); +exit ($err); + +# ------------------------------------------------------------------------------ + +sub CompareFiles($$) +{ + my $sDocumentPath = shift; + my $sPool = shift; + my %aFailedHash; + my $startdir = appendPath($sDocumentPath, $sPool); + + local *DIR; + if (opendir (DIR, $startdir)) # Directory oeffnen + { + my $myfile; + while ($myfile = readdir(DIR)) + { # ein filename holen + if ($myfile eq "knownissues.xcl") + { + next; + } + my $sAbsoluteFile = appendPath($startdir, $myfile); + if (-f $sAbsoluteFile) + { + my $nIssue; + my $sIssueText; + ($nIssue, $sIssueText) = checkForKnownIssue($startdir, $myfile); + if ($nIssue == 0) + { + $err = SingleDocumentCompare( + # "/net/so-gfxcmp-documents.germany.sun.com/export/gfxcmp/document-pool", # $documentpoolpath, + $sDocumentPool, + $sPool, # $documentpool, + $myfile, # $documentname); + $creatortype, # $destinationcreatortype, + $prepareonly, + $show + ); + $aFailedHash{$myfile} = $err; + } + else + { + print "$myfile [KNOWN ISSUE: #$sIssueText#]\n"; + } + } + } + closedir(DIR); + } + + print "***** State for graphical compare of pool: '$sPool' ******\n"; + my $nErrorCount = 0; + my $file; + foreach $file (keys %aFailedHash) + { + if ($aFailedHash{$file} != 0) + { + print "Failed: $file\n"; + $nErrorCount++; + } + } + print "Whole unit: "; + if ($nErrorCount > 0) + { + print "PASSED.FAILED\n"; + } + else + { + print "PASSED.OK\n"; + } + print "************************************************************\n"; + return $nErrorCount; +} +# ------------------------------------------------------------------------------ +# return issue number if file exists in knownissues.xcl file +sub checkForKnownIssue($$) +{ + my $startdir = shift; + my $myfile = shift; + + if ($force) + { + return 0,""; + } + + my $sKnownIssueFile = appendPath($startdir, "knownissues.xcl"); + my $sIssueText = "unknown"; + local *ISSUES; + my $nIssue = 0; + my $sCurrentSection; + + if (open(ISSUES, $sKnownIssueFile)) + { + my $line; + while ($line = <ISSUES>) + { + chomp($line); + if ($line =~ /\[(.*)\]/ ) + { + $sCurrentSection = $1; + next; + } + if ($sCurrentSection eq $creatortype) + { + if ($line =~ /\#\#\# (.*) \#\#\#/ ) + { + $sIssueText = $1; + } + if ($line =~ /^${myfile}$/ ) + { + $nIssue = 1; + last; + } + } + } + close(ISSUES); + } + return $nIssue, $sIssueText; +} +# ------------------------------------------------------------------------------ +sub prepare() +{ + # directory structure: + # documents will be found in + # ../document-pool/eis-tests + + # references will be found in + # ../references/unxlngi/eis-tests + # ../references/wntmsci/eis-tests + + # output goes to + # ../unxlngi6.pro/misc + + if ($verbose) + { + setVerbose(); + } + + # TEST + if (!$ENV{INPATH}) + { + if ($OSNAME eq "linux") + { + # just for debug + setINPATH("unxlngi6.pro"); + } + } + else + { + setINPATH($ENV{INPATH}); + } + + if (! $creatortype) + { + $creatortype= "ps"; + } + + my $cwd = getcwd(); + print "Current Directory: $cwd\n" if ($verbose); + my $sProjectBase; + if ($ENV{PRJ}) + { + # print "cwd:=$cwd\n"; + # print "PRJ:=$ENV{PRJ}\n"; + $sProjectBase = appendPath($cwd, $ENV{PRJ}); + } + else + { + $sProjectBase = dirname($cwd); + } + if ($OSNAME eq "cygwin") + { + $sProjectBase = `cygpath -w $sProjectBase`; + chomp($sProjectBase); + $sProjectBase = unixpath($sProjectBase); + # print "cygwin patch \$sProjectBase := $sProjectBase\n"; + } + # print "Project base path: $sProjectBase\n"; + setProjectRoot($sProjectBase); + + + # TEST TEST TEST + # exit (0); +} +# ------------------------------------------------------------------------------ +sub print_usage(*) +{ + local *HANDLE = $_[0]; + my $tool_name = basename($0); + + print(HANDLE <<END_OF_USAGE); + +Usage: $tool_name [OPTIONS] + + -pool Give pool name out of document-pool directory. + But all documents list in knownissues.xcl will not check. + -document Give a single document to test, the known issue list will ignored. + -creatortype=s s:ps create postscript files via print to file. + s:pdf create PDF file via export to pdf. + -h, --help Print this help, then exit + -v, --version Print version number, then exit + +END_OF_USAGE +; +} diff --git a/testgraphical/source/cwstestresult.pl b/testgraphical/source/cwstestresult.pl new file mode 100644 index 000000000000..63c68c827dbd --- /dev/null +++ b/testgraphical/source/cwstestresult.pl @@ -0,0 +1,208 @@ +: +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +# +# cwstestresult.pl - publish results of CWS tests to EIS +# + +use strict; +use Getopt::Long; +use Cwd; + +#### module lookup +my @lib_dirs; +BEGIN { + if ( !defined($ENV{SOLARENV}) ) { + die "No environment found (environment variable SOLARENV is undefined)"; + } + push(@lib_dirs, "$ENV{SOLARENV}/bin/modules"); + push(@lib_dirs, "$ENV{COMMON_ENV_TOOLS}/modules") if defined($ENV{COMMON_ENV_TOOLS}); +} +use lib (@lib_dirs); + +use Cws; + +#### global ##### +( my $script_name = $0 ) =~ s/^.*\b(\w+)\.pl$/$1/; + +my $is_debug = 1; # enable debug +my $opt_master; # option: master workspace +my $opt_child; # option: child workspace +my $opt_milestone; # option: milestone +my $opt_testrunName; # option: testrunName +my $opt_testrunPlatform; # option: testrunPlatfrom +my $opt_resultPage; # option: resultPage + + +#### main ##### + +my $arg_status= parse_options(); +testresult($arg_status); +exit(0); + +#### subroutines #### + +sub testresult +{ + my $status = shift; + # get master and child workspace + my $masterws = $opt_master ? uc($opt_master) : $ENV{WORK_STAMP}; + my $milestone = $opt_milestone ? $opt_milestone : $ENV{UPDMINOR}; + my $childws = $opt_milestone ? undef : ( $opt_child ? $opt_child : $ENV{CWS_WORK_STAMP} ); + + if ( !defined($masterws) ) { + print_error("Can't determine master workspace environment.\n" + . "Please initialize environment with setsolar ...", 1); + } + + if ( !defined($childws) && !defined($milestone) ) { + print_error("Can't determine child workspace environment or milestone.\n" + . "Please initialize environment with setsolar ...", 1); + } + if ( !defined($opt_resultPage) ) { + $opt_resultPage=""; + } + my $cws = Cws->new(); + if ( defined($childws) ) { + $cws->child($childws); + } + $cws->master($masterws); + my $eis = $cws->eis(); + + no strict; + my $result=''; + + if ( defined($childws) ) { + $opt_resultPage=SOAP::Data->type(string => $opt_resultPage); + my $id = $cws->eis_id(); + if ( is_valid_cws($cws) ) { + $result=$eis->submitTestResult($id,$opt_testrunName,$opt_testrunPlatform, $opt_resultPage, $status); + } else { + print STDERR "cws is not valid"; + } + } else { + $opt_resultPage=SOAP::Data->type(string => $opt_resultPage); + $result=$eis->submitTestResultMWS($masterws,$milestone,$opt_testrunName,$opt_testrunPlatform, $opt_resultPage, $status); + } + + exit(0) +} + + +sub is_valid_cws +{ + my $cws = shift; + + my $masterws = $cws->master(); + my $childws = $cws->child(); + # check if we got a valid child workspace + my $id = $cws->eis_id(); + if ( !$id ) { + print_error("Child workspace '$childws' for master workspace '$masterws' not found in EIS database.", 2); + } + return 1; +} + +sub parse_options +{ + # parse options and do some sanity checks + Getopt::Long::Configure("no_ignore_case"); + my $help = 0; + my $success = GetOptions('h' => \$help, + 'M=s' => \$opt_master, + 'm=s' => \$opt_milestone, + 'c=s' => \$opt_child, + 'n=s' => \$opt_testrunName, + 'p=s' => \$opt_testrunPlatform , + 'r=s' => \$opt_resultPage ); + if ( $help || !$success || $#ARGV < 0 || (!defined($opt_testrunName)) || ( !defined($opt_testrunPlatform)) ) { + usage(); + exit(1); + } + + print "$opt_master\n"; + print "$opt_milestone\n"; + print "$opt_child\n"; + print "$opt_testrunName\n"; + print "$opt_testrunPlatform\n"; + print "$opt_resultPage\n"; + + if ( defined($opt_milestone) && defined($opt_child) ) { + print_error("-m and -c are mutually exclusive options",1); + } + + return $ARGV[0]; +} + +# sub print_message +# { +# my $message = shift; +# +# print STDERR "$script_name: "; +# print STDERR "$message\n"; +# return; +# } + +sub print_error +{ + my $message = shift; + my $error_code = shift; + + print STDERR "$script_name: "; + print STDERR "ERROR: $message\n"; + + if ( $error_code ) { + print STDERR "\nFAILURE: $script_name aborted.\n"; + exit($error_code); + } + return; +} + +sub usage +{ + print STDERR "Usage: cwstestresult[-h] [-M masterws] [-m milestone|-c childws] <-n testrunName> <-p testrunPlatform> <-r resultPage> statusName\n"; + print STDERR "\n"; + print STDERR "Publish result of CWS- or milestone-test to EIS\n"; + print STDERR "\n"; + print STDERR "Options:\n"; + print STDERR "\t-h\t\t\thelp\n"; + print STDERR "\t-M master\t\toverride MWS specified in environment\n"; + print STDERR "\t-m milestone\t\toverride milestone specified in environment\n"; + print STDERR "\t-c child\t\toverride CWS specified in environment\n"; + print STDERR "\t-n testrunName\t\tspecifiy name of the test\n"; + print STDERR "\t-p testrunPlatform\tspecify platform where the test ran on\n"; + print STDERR "\t-r resultPage\t\tspecify name of attachment or hyperlink\n"; + print STDERR "\t\t\t\tfor resultPage\n"; + + + print STDERR "\nExample:\n"; + print STDERR "\tcwstestresult -c mycws -n Performance -p Windows -r PerfomanceTestWindows.html ok\n"; +} diff --git a/testgraphical/source/cwstestresulthelper.pm b/testgraphical/source/cwstestresulthelper.pm new file mode 100644 index 000000000000..37a5315445af --- /dev/null +++ b/testgraphical/source/cwstestresulthelper.pm @@ -0,0 +1,268 @@ +package cwstestresulthelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use English; +use warnings; +use strict; +use Cwd; +use Cwd 'chdir'; + +use stringhelper; +use loghelper; +use oshelper; +use filehelper; +use CallExternals; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&cwstestresult); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + +sub cwstestresult($$$$$$) +{ + my $sStatus = shift; + my $sDBdistinct = shift; + my $sourceversion = shift; + my $destinationversion = shift; + + my $sSOLARENV; # = getSolenvPath(); + my $nSOLARENV_fake = 0; + my $sCOMMON_ENV_TOOLS; + my $nCOMMON_ENV_TOOLS_fake = 0; + + my $MAJOR; + my $MINOR; + # we need an extra state in DB + # if this state is given here, we need to add information in cws back. + if ( ! $sSOLARENV) + { + my @MAJORMINOR=split('_', $sourceversion); + if ($#MAJORMINOR < 1) + { + print "Failure with sourceversion '$sourceversion' not splitable.\n"; + return; + } + $MAJOR=$MAJORMINOR[0]; # DEV300, OOH310, ... + $MINOR=$MAJORMINOR[1]; # m45, ... + if (getEnvironment() eq "wntmsci") + { + $sSOLARENV="o:/$MAJOR/ooo.$MINOR/solenv"; + if (! -e $sSOLARENV) + { + # fallback to old before ause103 (treeconfig) + $sSOLARENV="o:/$MAJOR/src.$MINOR/solenv"; + } + } + elsif (getEnvironment() eq "unxlngi" || + getEnvironment() eq "unxsoli") + { + $sSOLARENV="/so/ws/$MAJOR/ooo.$MINOR/solenv"; + # automount + system("ls -al $sSOLARENV >/dev/null"); + sleep(1); + if (! -e $sSOLARENV) + { + # fallback to old before ause103 (treeconfig) + $sSOLARENV="/so/ws/$MAJOR/src.$MINOR/solenv"; + } + } + else + { + log_print("cwstestresult(): This environment is not supported."); + return; + } + } + if ( !defined($ENV{SOLARENV}) || length($ENV{SOLARENV}) == 0 ) + { + $ENV{SOLARENV} = $sSOLARENV; + log_print(" SOLARENV is: $ENV{SOLARENV} faked\n"); + $nSOLARENV_fake = 1; + } + if ( ! $sCOMMON_ENV_TOOLS) + { + if (isWindowsEnvironment()) + { + $sCOMMON_ENV_TOOLS="r:/etools"; + } + elsif (isUnixEnvironment() ) + { + $sCOMMON_ENV_TOOLS="/so/env/etools"; + # automount + system("ls -al $sCOMMON_ENV_TOOLS >/dev/null"); + sleep(1); + } + else + { + log_print("cwstestresult(): This environment is not supported. (variable COMMON_ENV_TOOLS not set.)"); + return; + } + } + if ( !defined($ENV{COMMON_ENV_TOOLS}) || length($ENV{COMMON_ENV_TOOLS}) == 0 ) + { + $ENV{COMMON_ENV_TOOLS} = $sCOMMON_ENV_TOOLS; + log_print( "COMMON_ENV_TOOLS is: $ENV{COMMON_ENV_TOOLS} faked\n"); + $nCOMMON_ENV_TOOLS_fake = 1; + } + + # if ( !defined($ENV{WORK_STAMP}) ) + # { + # $ENV{WORK_STAMP} = $MAJOR; + # log_print( " WORK_STAMP is: $ENV{WORK_STAMP} faked\n"); + # } + # if ( !defined($ENV{UPDMINOR}) ) + # { + # $ENV{UPDMINOR} = $MINOR; + # log_print( " UPDMINOR is: $ENV{UPDMINOR} faked\n"); + # } + + my $nWORK_STAMP_fake = 0; + my $nUPDMINOR_fake = 0; + + if ( !defined($ENV{WORK_STAMP}) || length($ENV{WORK_STAMP}) == 0 ) + { + $ENV{WORK_STAMP} = $MAJOR; + log_print(" WORK_STAMP is: $ENV{WORK_STAMP} faked\n"); + $nWORK_STAMP_fake = 1; + } + if ( !defined($ENV{UPDMINOR}) || length($ENV{WORK_STAMP}) == 0 ) + { + $ENV{UPDMINOR} = $MINOR; + log_print(" UPDMINOR is: $ENV{UPDMINOR} faked\n"); + $nUPDMINOR_fake = 1; + } + + # my $sStatus = "ok"; + # if ($nFailure == 0) + # { + # $sStatus = $sInfo; + # } + # elsif ($nFailure == 1) + # { + # $sStatus = "failed"; + # } + # elsif ($nFailure == 2) + # { + # $sStatus = "incomplete"; + # } + + # system("cwstestresult -c mycws -n Performance -p Windows ok"); + my $sPerlProgram = appendPath($sSOLARENV, "bin/cwstestresult.pl"); + # if ( -e "cwstestresult.pl" ) + # { + # # use a local version instead + # $sPerlProgram = "cwstestresult.pl"; + # } + # else + # { + # my $currentdir =cwd(); + # log_print( "We are in $currentdir\n"); + # } + + my $sPerlParam; + # $sPerlParam = " -m $MAJOR"; # master CWS + $sPerlParam .= " -c $destinationversion"; # name of CWS + $sPerlParam .= " -n ConvWatch"; # ConvWatch need to be capitalised for cwstestresult + my $sCWSEnv; + if (isWindowsEnvironment()) + { + $sCWSEnv = "Windows"; + } + elsif (getEnvironment() eq "unxlngi") + { + $sCWSEnv = "Linux"; + } + elsif (getEnvironment() eq "unxsoli") + { + $sCWSEnv = "SolarisX86"; + } + else + { + log_print("cwstestresult(): This environment is not supported. (getEnvironment() returns wrong value?)"); + return; + } + $sPerlParam .= " -p " . $sCWSEnv; + $sPerlParam .= " -r http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/status_new.php?distinct=$sDBdistinct"; + + $sPerlParam .= " "; + $sPerlParam .= $sStatus; + + + # my $sSetcwsAndPerl = "setcws $destinationversion; " . getPerlExecutable(); + + my $err = callperl(getPerlExecutable(), $sPerlProgram, $sPerlParam); + if ($err != 0) + { + log_print( "Can't call cwstestresult.pl\n"); + } + if ($nSOLARENV_fake == 1) + { + $ENV{SOLARENV} = ""; + undef( $ENV{SOLARENV} ); + $nSOLARENV_fake = 0; + # if ( defined($ENV{SOLARENV}) ) + # { + # print "SOLARENV always defined.\n"; + # } + } + if ($nCOMMON_ENV_TOOLS_fake == 1) + { + $ENV{COMMON_ENV_TOOLS} = ""; + undef( $ENV{COMMON_ENV_TOOLS} ); + $nCOMMON_ENV_TOOLS_fake = 0; + } + + if ( $nWORK_STAMP_fake == 1 ) + { + # undef($ENV{WORK_STAMP}); + $ENV{WORK_STAMP} = ""; + undef($ENV{WORK_STAMP}); + $nWORK_STAMP_fake = 0; + } + if ( $nUPDMINOR_fake == 1 ) + { + $ENV{UPDMINOR} = ""; + undef($ENV{UPDMINOR}); + $nUPDMINOR_fake = 0; + } + + +} + + +1; diff --git a/testgraphical/source/dbhelper.pm b/testgraphical/source/dbhelper.pm new file mode 100644 index 000000000000..0f5c0d5bb5ea --- /dev/null +++ b/testgraphical/source/dbhelper.pm @@ -0,0 +1,209 @@ +# +# # ------------------------------------------------------------------------------ +# +# sub DB_INSERT_INTO_TABLE_STATUS() +# { +# # my $sDocID = shift; +# # my $sDBDistinct = shift; +# +# my $sHostname = hostname; +# +# my $sSQL = "INSERT INTO status (docid, dbdistinct2, hostname)"; +# $sSQL .= " VALUES ($docid, '$dbdistinct', '$sHostname')"; +# ExecSQL($sSQL); +# } +# sub DB_UPDATE_TABLE_STATUS_SET_INFO($) +# { +# # my $sDocID = shift; +# # my $sDBDistinct = shift; +# my $sInfo = shift; +# +# # my $sHostname = hostname; +# +# my $sInsertSQL = "UPDATE status SET info='$sInfo' WHERE docid=$docid AND dbdistinct2='$dbdistinct'"; +# ExecSQL($sInsertSQL); +# } +# +# sub DB_UPDATE_TABLE_DOCUMENTS_SET_STATE_INFO($$) +# { +# # my $sDocID = shift; +# my $sStatus = shift; +# my $sError = shift; +# +# my $sSQL = "UPDATE documents"; +# $sSQL .= " SET state='" . $sStatus . "'"; +# $sSQL .= ",info='" . $sError . "'"; +# $sSQL .= " WHERE docid=$docid"; +# ExecSQL($sSQL); +# } +# sub DB_UPDATE_TABLE_STATUS_SET_STATE($) +# { +# # my $sDocID = shift; +# my $sStatus = shift; +# +# my $sSQL = "UPDATE status"; +# $sSQL .= " SET state='" . $sStatus . "'"; +# $sSQL .= " WHERE docid=$docid"; +# ExecSQL($sSQL); +# } +# +# # sub DB_UPDATE_TABLE_STATUS_SET_STATE_FAILED() +# # { +# # DB_UPDATE_TABLE_STATUS_SET_STATE("FAILED-FAILED"); +# # } +# # ------------------------------------------------------------------------------ +# # sub getDBConnectionString() +# # { +# # # return "server:jakobus,db:jobs_convwatch,user:admin,passwd:admin"; +# # return "server:unoapi,db:jobs_convwatch,user:convwatch,passwd:convwatch"; +# # } +# # ------------------------------------------------------------------------------ +# sub getSourceInfo($) +# { +# my $sDBStr = shift; +# +# my $sSourceVersion; +# if ( $sDBStr =~ / sourceversion='(.*?)',/ ) +# { +# $sSourceVersion = $1; +# log_print( "sSourceVersion: $sSourceVersion\n"); +# } +# if (! $sSourceVersion) +# { +# log_print( "Error: no value for sourceversion found.\n"); +# return; +# } +# my $sSourceName; +# if ( $sDBStr =~ / sourcename='(.*?)',/ ) +# { +# $sSourceName = $1; +# log_print( "sSourceName: $sSourceName\n"); +# } +# my $sSourceCreatorType; +# if ( $sDBStr =~ / sourcecreatortype='(.*?)',/ ) +# { +# $sSourceCreatorType = $1; +# log_print( "sSourceCreatorType: $sSourceCreatorType\n"); +# } +# return $sSourceVersion, $sSourceName, $sSourceCreatorType; +# } +# # ------------------------------------------------------------------------------ +# sub getDestinationInfo($) +# { +# my $sDBStr = shift; +# +# my $sDestinationVersion; +# if ( $sDBStr =~ / destinationversion='(.*?)',/ ) +# { +# $sDestinationVersion = $1; +# log_print( "sDestinationVersion: $sDestinationVersion\n"); +# } +# if (! $sDestinationVersion) +# { +# log_print( "Error: no value for destinationversion found.\n"); +# return; +# } +# my $sDestinationName; +# if ( $sDBStr =~ / destinationname='(.*?)',/ ) +# { +# $sDestinationName = $1; +# log_print( "sDestinationName: $sDestinationName\n"); +# } +# my $sDestinationCreatorType; +# if ( $sDBStr =~ / destinationcreatortype='(.*?)',/ ) +# { +# $sDestinationCreatorType = $1; +# log_print( "sDestinationCreatorType: $sDestinationCreatorType\n"); +# } +# return $sDestinationVersion, $sDestinationName, $sDestinationCreatorType; +# } +# # ------------------------------------------------------------------------------ +# # sub getMailAddress($) +# # { +# # my $sDBStr = shift; +# # my $sMailAddress = ""; +# # if ( $sDBStr =~ / mailfeedback='(.*?)',/ ) +# # { +# # $sMailAddress = $1; +# # log_print( "sMailAddress: $sMailAddress\n"); +# # } +# # return $sMailAddress; +# # } +# +# # sub getDocumentInfo($) +# # { +# # my $sDBStr = shift; +# # +# # my $sDocumentPoolPath; +# # if ( $sDBStr =~ / documentpoolpath='(.*?)',/ ) +# # { +# # $sDocumentPoolPath = $1; +# # log_print( "sDocumentPoolPath: $sDocumentPoolPath\n"); +# # } +# # if (! $sDocumentPoolPath) +# # { +# # log_print( "Error: no value for documentpoolpath found.\n"); +# # return; +# # } +# # my $sDocumentPool; +# # if ( $sDBStr =~ / documentpool='(.*?)',/ ) +# # { +# # $sDocumentPool = $1; +# # log_print( "sDocumentPool: $sDocumentPool\n"); +# # } +# # if (! $sDocumentPool) +# # { +# # log_print( "Error: no value for documentpool found.\n"); +# # return; +# # } +# # my $sDocumentName; +# # if ( $sDBStr =~ / name='(.*?)',/ ) +# # { +# # $sDocumentName = $1; +# # log_print( "sDocumentName: $sDocumentName\n"); +# # } +# # return $sDocumentPoolPath, $sDocumentPool, $sDocumentName; +# # } +# +# sub getDistinct($) +# { +# my $sDBStr = shift; +# my $sDBDistinct; +# if ( $sDBStr =~ / dbdistinct2='(\S*?)',/ ) +# { +# $sDBDistinct = $1; +# log_print( "dbdistinct2: $sDBDistinct\n"); +# } +# return $sDBDistinct; +# } +# +# sub getIDInfo($) +# { +# my $sDBStr = shift; +# # my $dbdistinct; +# +# my $sDBDistinct = getDistinct($sDBStr); +# # if ( $sDBStr =~ / dbdistinct2='(\S*?)',/ ) +# # { +# # $sDBDistinct = $1; +# # log_print( "dbdistinct2: $sDBDistinct\n"); +# # } +# if (! $sDBDistinct) +# { +# log_print( "Error: no dbdistinct given.\n"); +# return; +# } +# my $sDocID; +# if ( $sDBStr =~ / docid=(\S*?),/ ) +# { +# $sDocID = $1; +# log_print( "docid: $sDocID\n"); +# } +# if (! $sDocID) +# { +# log_print( "Error: no docid given.\n"); +# return; +# } +# return $sDBDistinct, $sDocID; +# } +# diff --git a/testgraphical/source/filehelper.pm b/testgraphical/source/filehelper.pm new file mode 100644 index 000000000000..ed1be35cf124 --- /dev/null +++ b/testgraphical/source/filehelper.pm @@ -0,0 +1,358 @@ +package filehelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use strict; +use warnings; +use strict; +use English; # $OSNAME, ... +use stringhelper; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&dospath &unixpath &appendPath &appendClass &setPrefix &getToolsPrefix &rmkdir &getJavaPathSeparator &getJavaFileDirSeparator &getFromPathes &convertCygwinPath); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + + +# ------------------------------------------------------------------------------ +# helper, to change all file separators +sub dospath($) +{ + my $sPath = shift; + if ($OSNAME eq "MSWin32") + { + # make out of '/' a '\' + $sPath =~ s/\//\\/g; + } + else + { + } + return $sPath; +} + +sub unixpath($) +{ + my $sPath = shift; + if ($OSNAME ne "MSWin32") + { + # make out of '\' a '/' + $sPath =~ s/\\/\//g; + } + else + { + } + return $sPath; +} + +# ------------------------------------------------------------------------------ +# sub getGlobalInstSet() +# { +# my $sJumbo; +# if ($OSNAME eq "MSWin32") +# { +# # $sJumbo = "\\\\so-gfxcmp-lin\\jumbo_ship\\install"; +# $sJumbo = "\\\\jumbo.germany.sun.com\\ship\\install"; +# } +# elsif ($OSNAME eq "cygwin") +# { +# $sJumbo = "//jumbo.germany.sun.com/ship/install"; +# } +# else +# { +# $sJumbo = "/net/jumbo.germany.sun.com/ship/install"; +# } +# return $sJumbo; +# } + +# ------------------------------------------------------------------------------ +# sub getSolarisLockFile() +# { +# my $sSolarisLockFile = "/tmp/.ai.pkg.zone.lock-afdb66cf-1dd1-11b2-a049-000d560ddc3e"; +# return $sSolarisLockFile; +# } +# +# sub checkForSolarisLock() +# { +# if ($OSNAME eq "solaris") +# { +# # wait until the internal installer lock is gone +# while ( -e getSolarisLockFile() ) +# { +# while ( -e getSolarisLockFile() ) +# { +# log_print( "Warning: Wait active until installer lock is gone. \n"); +# sleep 1; +# } +# sleep 5; +# } +# log_print( "[ok], lock is gone.\n"); +# } +# } +# +# sub deleteSolarisLock() +# { +# if ($OSNAME eq "solaris") +# { +# sleep 1; +# unlink getSolarisLockFile(); +# +# sleep 1; +# if ( -e getSolarisLockFile() ) +# { +# # try delete the file as super user? +# `sudo rm -f getSolarisLockFile()`; +# sleep 1; +# } +# } +# } + +# ------------------------------------------------------------------------------ +sub appendPath($$) +{ + my $sPath = shift; + my $sAddPath = shift; + if ($sPath && $sAddPath) + { + if (! endswith($sPath, "/") && + ! endswith($sPath, "\\")) + { + # getJavaFileDirSeparator(); + $sPath .= "/"; + } + $sPath .= $sAddPath; + } + return $sPath; +} + +sub appendClass($$) +{ + my $sPath = shift; + my $sAddPath = shift; + + my $sSeparator = getJavaPathSeparator(); + if ($sPath && $sAddPath) + { + if (! endswith($sPath, $sSeparator)) + { + # getJavaFileDirSeparator(); + $sPath .= $sSeparator; + } + $sPath .= $sAddPath; + } + return $sPath; +} + +# ------------------------------------------------------------------------------ + +our $sPrefix; +sub setPrefix($) +{ + $sPrefix = shift; +} + +sub getPrefix() +{ + return $sPrefix; +} + +# ------------------------------------------------------------------------------ +our $programprefix; + +# sub getProgramPrefix($) +# { +# my $sDBDistinct = shift; +# +# my $sProgramPrefix; +# if (! $programprefix) +# { +# if ($OSNAME eq "MSWin32") +# { +# # $programprefix = "C:/gfxcmp/programs"; +# $programprefix = "C:"; +# if (getPrefix() eq "performance") +# { +# $programprefix = "D:"; +# } +# $programprefix = appendPath($programprefix, "gp"); +# } +# elsif ($OSNAME eq "linux") +# { +# $programprefix = "/space/" . getPrefix() . "/programs"; +# } +# elsif ($OSNAME eq "solaris") +# { +# $programprefix = "/space/" . getPrefix() . "/programs"; +# } +# else +# { +# print "Error: This environment isn't supported yet.\n"; +# exit(1); +# } +# } +# $sProgramPrefix = appendPath($programprefix, substr($sDBDistinct, 0, 19)); +# return $sProgramPrefix; +# } +# ------------------------------------------------------------------------------ +our $toolsprefix; + +sub getToolsPrefix() +{ + my $sToolsPrefix; + if (! $toolsprefix) + { + if ($OSNAME eq "MSWin32") + { + $toolsprefix = "C:"; + if (getPrefix() eq "performance") + { + $toolsprefix = "D:"; + } + } + elsif ($OSNAME eq "linux") + { + $toolsprefix = "/space"; + } + elsif ($OSNAME eq "solaris") + { + $toolsprefix = "/space"; + } + else + { + print "Error: This environment isn't supported yet.\n"; + exit(1); + } + $toolsprefix = appendPath($toolsprefix, getPrefix()); + $toolsprefix = appendPath($toolsprefix, "tools"); + } + $sToolsPrefix = $toolsprefix; + return $sToolsPrefix; +} + +# also Windows safe +sub rmkdir($) +{ + my($tpath) = shift; + my $dir; + my $accum = ""; + + my @dirs = split(/\//, $tpath); + if ( $#dirs eq 0 ) + { + @dirs = split("\\\\", $tpath); + } + + foreach $dir (@dirs) + { + $accum = "$accum$dir/"; + if($dir ne "") + { + if(! -d "$accum") + { + mkdir ($accum); + chmod (0777,$accum); + } + } + } +} + +# ------------------------------------------------------------------------------ +sub getJavaPathSeparator() +{ + my $ps = ":"; + if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") + { + $ps = ";"; + } + return $ps; +} +# ------------------------------------------------------------------------------ +sub getJavaFileDirSeparator() +{ + my $sfs = "/"; + if ($OSNAME eq "MSWin32") + { + $sfs = "\\"; + } + return $sfs; +} +# ------------------------------------------------------------------------------ +sub getFromPathes($$) +{ + my $sPathesIni = shift; + my $searchvalue = shift; + my $sResult; + if ( -e $sPathesIni) + { + local *PATHES; + if (open(PATHES, "$sPathesIni")) + { + my $line; + while ($line = <PATHES>) + { + chomp($line); + if ($line =~ /^$searchvalue=(.*)$/) + { + $sResult = $1; + } + } + close(PATHES); + } + } + return $sResult; +} + +sub convertCygwinPath($) +{ + my $sPath = shift; + + if ($OSNAME eq "cygwin") + { + # print "Cygwin Path Patch.\n" if ($verbose); + if ($sPath =~ /\/cygdrive\/(.)/) + { + my $Letter = $1; + $sPath =~ s/\/cygdrive\/${Letter}/${Letter}\:/; + # print "Cygwin Path Patch: '$sPath'\n" if ($verbose); + } + } + return $sPath; +} + + + +1; diff --git a/testgraphical/source/fill_documents_loop.pl b/testgraphical/source/fill_documents_loop.pl new file mode 100644 index 000000000000..c1b8174fefe5 --- /dev/null +++ b/testgraphical/source/fill_documents_loop.pl @@ -0,0 +1,423 @@ +eval 'exec perl -wS $0 ${1+\"$@\"}' + if 0; + +# This program has to start for the new convwatch, +# once on Windows environment and once on Linux environment +# Solaris is handled by the linux also. +# +# This program polls the database (documentcompare) every 60s for new jobs +# it runs over the given directory from documentpoolpath and pool, and create for every file +# a new database entry in documents. +# + +BEGIN +{ + # Adding the path of this script file to the include path in the hope + # that all used modules can be found in it. + $0 =~ /^(.*)[\/\\]/; + push @INC, $1; +} + +use ConvwatchHelper; +use CallExternals; +use stringhelper; +use filehelper; +use oshelper; +use timehelper; +use cwstestresulthelper; + +use strict; +use Cwd; +use File::Basename; +use English; # $OSNAME, ... +use Getopt::Long; +use File::Path; +use Cwd 'chdir'; + +my $cwd = getcwd(); + +our $help; # Help option flag +our $version; # Version option flag +our $test; + +our $version_info = 'convwatch.pl $Revision: 1.24 $ '; + +our $SOLARENV; +our $COMMON_ENV_TOOLS; + + +our $documentpoolname; +our $documentpoolpath; +our $dbdistinct; +our $sParentDistinct; +our $sCurrentDocumentPool; + +our $fs; +our @aEntries; + +# Prototypes +# sub getJavaFileDirSeparator(); +sub readdirectory($$$); +sub putDocumentInDB($$$); + +# flush STDOUT +my $old_handle = select (STDOUT); # "select" STDOUT and save # previously selected handle +$| = 1; # perform flush after each write to STDOUT +select ($old_handle); # restore previously selected handle + +setPrefix("gfxcmp"); + +if (!GetOptions( + "test" => \$test, + "help" => \$help, + "version" => \$version + )) +{ + print_usage(*STDERR); + exit(1); +} +if ($help) +{ + print_usage(*STDOUT); + exit(0); +} +# Check for version option +if ($version) +{ + print STDERR "$version_info\n"; + exit(0); +} + +# ------------------------------------------------------------------------------ +# within mysql it is better to use only '/' +$fs = "/"; # getJavaFileDirSeparator(); +# ------------------------------------------------------------------------------ +sub readdirectory($$$) +{ + my $startdir = shift; + my $sValues = shift; + my $hook = shift; + + my $myfile; + + local *DIR; + chdir $startdir; + cwd(); + if (! endswith($startdir, $fs)) + { + $startdir .= $fs; + } + + my $nCountFiles = 0; + if (opendir (DIR, $startdir)) # Directory oeffnen + { + while ($myfile = readdir(DIR)) + { # ein filename holen + #if (! -l $myfile) # not a link + #{ + if (-d $myfile ) # is a directory + { + if ( -l $myfile) + { + next; + } + if ($myfile ne "." && $myfile ne "..") + { + my $sNewStartDir = $startdir . $myfile ."/"; # neuen Directorystring erstellen + if ($sNewStartDir =~ "^\/proc" || + $sNewStartDir =~ "^\/dev" || + $sNewStartDir =~ "^\/udev" || + $sNewStartDir =~ "lost+found" ) + { + next; + } + # my $sNewDestDir = $destdir . $myfile ."/"; + # do a recursive call + # $nCountFiles++; + my $nFileCount = readdirectory($sNewStartDir, $sValues, $hook); + # workOnDir($sNewDir, $nFileCount); + $nCountFiles += $nFileCount; + + chdir ($startdir); # zurueckwechseln. + cwd(); + } + } + else + { + # File must exist, be a regular file and must not be the $onlyOnFile + if (-f $myfile) + { + # print " $startdir" . "$myfile\n"; + $nCountFiles++; + # workOnFile($startdir, $myfile, $destdir); + $hook->($startdir, $myfile, $sValues); + } + } + #} + #else + #{ + # print "linked file: $dir/$myfile\n"; + #} + } + closedir(DIR); + } + else + { + print "could not open $startdir\n"; + } + return $nCountFiles; +} +# ------------------------------------------------------------------------------ +sub putDocumentInDB($$$) +{ + my $currentDir = shift; + my $currentFile = shift; + my $sValues = shift; + + my $sSourceFilename = $currentDir . $currentFile; + # we cut down all the previous names like documentpoolpath and the documentpoolname + $sSourceFilename = substr($sSourceFilename, length($sCurrentDocumentPool . $fs)); + + my $sSQL = "INSERT INTO documents (dbdistinct2, name, pagecount, priority, parentdistinct) VALUES"; + $sSQL .= "('" . $dbdistinct . "', '" . $sSourceFilename . "', 0, 1, '". $sParentDistinct . "')"; + # print $sSQL . "\n"; + + push(@aEntries, $sSQL); + # ExecSQL($sSQL); +} + +# ------------------------------------------------------------------------------ +sub createDBEntriesForEveryDocument($) +{ + my $sStr = shift; + if ($sStr =~ /^MySQL-Error/ ) + { + # we don't do anything if an error occured + return; + } + + # interpret the follows string + # documentpoolpath='//so-gfxcmp-documents/doc-pool', documentpool='demo_lla', dbdistinct=62, + + # my $sDocumentPoolDir; + if ( $sStr =~ /documentpoolpath='(.*?)',/ ) + { + $documentpoolpath = $1; + } + if (! $documentpoolpath) + { + print "Error: no value for documentpoolpath found.\n"; + return; + } + + # my $sDocumentPool; + if ( $sStr =~ /documentpool='(.*?)',/ ) + { + $documentpoolname = $1; + } + if (! $documentpoolname) + { + print "Error: no value for documentpool found.\n"; + return; + } + # my $dbdistinct; + if ( $sStr =~ /dbdistinct2='(\S*?)',/ ) + { + $dbdistinct = $1; + } + if (! $dbdistinct) + { + print "Error: no dbdistinct given.\n"; + return; + } + + if (! -d $documentpoolpath ) + { + my $sEnv = getEnvironment(); + if ( isUnixEnvironment() ) + { + $documentpoolpath = "/net/so-gfxcmp-documents" . $documentpoolpath; + } + if ( -d $documentpoolpath ) + { + print "Warning: given documentpoolpath seems to be local, fix to '$documentpoolpath'\n"; + my $sSQL = "UPDATE documentcompare SET documentpoolpath='$documentpoolpath' WHERE dbdistinct2='$dbdistinct'"; + print "$sSQL\n"; + ExecSQL($sSQL); + } + else + { + print "Error: documentpoolpath '$documentpoolpath' not found. Don't insert anything.\n"; + my $sSQL = "UPDATE documentcompare SET state='failed',info='documentpoolpath not found.' WHERE dbdistinct2='$dbdistinct'"; + print "$sSQL\n"; + ExecSQL($sSQL); + return; + } + } + # create the documentpool directory, to run through + $sCurrentDocumentPool = $documentpoolpath; + if (! endswith($sCurrentDocumentPool, $fs)) + { + $sCurrentDocumentPool .= $fs; + } + $sCurrentDocumentPool .= $documentpoolname; + + if ( -d $sCurrentDocumentPool ) + { + if ( $sStr =~ /parentdistinct='(.*?)',/ ) + { + $sParentDistinct = $1; + } + else + { + $sParentDistinct = ""; + } + + # remove any doubles, if any + my $sSQL = "DELETE FROM documents WHERE dbdistinct2='$dbdistinct'"; + print "$sSQL\n"; + ExecSQL($sSQL); + + # run over the whole given document pool and store every found document name in the database + readdirectory($sCurrentDocumentPool, "", \&putDocumentInDB); + + chdir $cwd; + cwd(); + + foreach $sSQL (@aEntries) + { + # print "# $sSQL\n"; + print "$sSQL\n"; + ExecSQL($sSQL); + } + + my $sSQL = "UPDATE documentcompare SET state='inprogress' WHERE dbdistinct2='$dbdistinct'"; + print "$sSQL\n"; + ExecSQL($sSQL); + print "----------------------------------------------------------------------\n"; + $sParentDistinct = ""; + @aEntries = (); + } + else + { + print "Error: Given document pool '$sCurrentDocumentPool' doesn't exists.\n"; + my $sSQL = "UPDATE documentcompare SET state='cancelled' WHERE dbdistinct2='$dbdistinct'"; + ExecSQL($sSQL); + return; + } + # Send Mail, due to startconvwatch now + sendMail($sStr, $documentpoolname, $dbdistinct); +} + +# ------------------------------------------------------------------------------ +sub sendMail($$$) +{ + my $sStr = shift; + my $documentpool = shift; + my $dbdistinct = shift; + my $sourceversion; + if ( $sStr =~ /sourceversion='(.*?)',/ ) + { + $sourceversion = $1; + } + if (! $sourceversion) + { + print "Warning: no value for sourceversion found.\n"; + return; + } + my $destinationversion; + if ( $sStr =~ /destinationversion='(.*?)',/ ) + { + $destinationversion = $1; + } + if (! $destinationversion) + { + print "Warning: no value for destinationversion found.\n"; + return; + } + my $mailaddress; + if ( $sStr =~ /mailfeedback='(.*?)',/ ) + { + $mailaddress = $1; + } + if (! $mailaddress) + { + print "Warning: no value for mailfeedback found.\n"; + return; + } + + # state is 'inprogress', so send a mail + # my $sMailAddress = getMailAddress($sDoneStr); + my $sParams = "$sourceversion"; + $sParams .= " $destinationversion"; + $sParams .= " $documentpool"; + $sParams .= " $dbdistinct"; + $sParams .= " $mailaddress"; + $sParams .= " starts"; # run through state of convwatch + + my $sMailProgram = appendPath(getQADEVToolsPath(), "mailsend.php"); + + my $err; + my @lines; + my $sLine; + ($err, @lines) = callphp(getPHPExecutable(), $sMailProgram, $sParams); + foreach $sLine (@lines) + { + log_print( "Mail: $sLine\n"); + } + + if ($documentpool eq "EIS-tests") + { + cwstestresult("running", $dbdistinct, $sourceversion, $destinationversion, $SOLARENV, $COMMON_ENV_TOOLS); + } +} +# ------------------------------------------------------------------------------ +# ------------------------------------------------------------------------------ + +my $sEnvironmentCondition; +if (isWindowsEnvironment()) +{ + $sEnvironmentCondition = "environment='" . getEnvironment() . "'"; +} +elsif (isUnixEnvironment()) +{ + # $sEnvironmentCondition = " ( environment='unxlngi' OR environment='unxsoli' ) "; + $sEnvironmentCondition = " environment='" . getEnvironment() . "'"; +} +else +{ + print "Error: wrong environment.\n"; + exit(1); +} +my $sWhereClause = "WHERE "; +if ($sEnvironmentCondition) +{ + $sWhereClause .= $sEnvironmentCondition . " AND "; +} +$sWhereClause .= " state='new'"; + +setToolsPath(getQADEVToolsPath()); + +# ---------------------------------- main loop ---------------------------------- +while (1) +{ + my @aResult; + my $sSQL = "SELECT documentpoolpath,documentpool,dbdistinct2,sourceversion,destinationversion,mailfeedback,parentdistinct FROM documentcompare $sWhereClause"; + @aResult = ExecSQL($sSQL); + + my $aValue; + foreach $aValue (@aResult) + { + # print "# $nValue\n"; + createDBEntriesForEveryDocument($aValue); + } + if ($test) + { + last; + } + + # wait 30sec. + # wait30seconds(); + waitAMinute(); + checkForStop("stop_fill_documents_loop"); +} diff --git a/testgraphical/source/graphical_compare.pm b/testgraphical/source/graphical_compare.pm new file mode 100644 index 000000000000..5cde8d64ea01 --- /dev/null +++ b/testgraphical/source/graphical_compare.pm @@ -0,0 +1,586 @@ +package graphical_compare; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use CallExternals; +use stringhelper; +use timehelper; +use filehelper; +use loghelper; +use oshelper; +use cwstestresulthelper; +use solarenvhelper; +use ConvwatchHelper; + +use strict; +use Cwd; +# use File::Basename; +use Getopt::Long; +use English; # $OSNAME, ... +use File::Path; +use Cwd 'chdir'; +use Sys::Hostname; +use Time::localtime; + +# my $cwd = getcwd(); + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&SingleDocumentCompare &setPrefix &setConnectionString); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + + +our $nTimeOut = 300 * 1000; +our $viewable = 1; +our $port; +our $resolution; +our $overwritereference; +our $fixreference; +our $sConncectionString; + +sub setConnectionString($) +{ + $sConncectionString=shift; +} + +sub getOOoRunnerClasspath() +{ + my $sSourceRoot; + my $sUPDExtensions = ""; + if (defined ($ENV{SOL_TMP}) && defined ($ENV{SOLARVERSION})) + { + $sSourceRoot = $ENV{SOLARVERSION}; + } + elsif (defined $ENV{SOURCE_ROOT}) + { + $sSourceRoot = $ENV{SOURCE_ROOT}; + $sSourceRoot = appendPath($sSourceRoot, $ENV{WORK_STAMP}); + } + else + { + $sSourceRoot = $ENV{SOLARVERSION}; + $sUPDExtensions = ".$ENV{UPDMINOR}"; + } + $sSourceRoot = appendPath($sSourceRoot, $ENV{INPATH}); + my $sSourceRootBin = appendPath($sSourceRoot, "bin" . $sUPDExtensions); + my $sSourceRootLib = appendPath($sSourceRoot, "lib" . $sUPDExtensions); + + if (! -d $sSourceRoot ) + { + log_print( "SourceRoot not found, search it in '$sSourceRoot'\n"); + return ""; + } + + my $sOOoRunnerPath = $sSourceRootBin; + my $sUnoilPath = $sSourceRootBin; + my $sRidlPath = $sSourceRootBin; + my $sJurtPath = $sSourceRootBin; + my $sJuhPath = $sSourceRootBin; + my $sJavaUnoPath = $sSourceRootBin; + + my $sOOoRunnerClasspath = + appendPath( $sRidlPath, "ridl.jar") . getJavaPathSeparator() . + appendPath( $sUnoilPath, "unoil.jar") . getJavaPathSeparator() . + appendPath( $sJurtPath, "jurt.jar") . getJavaPathSeparator() . + appendPath( $sJuhPath, "juh.jar") . getJavaPathSeparator() . + appendPath( $sJavaUnoPath, "java_uno.jar") . getJavaPathSeparator() . + appendPath( $sOOoRunnerPath, "OOoRunnerLight.jar"); + if (isWindowsEnvironment()) + { + $sOOoRunnerClasspath .= getJavaPathSeparator() . $sSourceRootBin; + } + else + { + $sOOoRunnerClasspath .= getJavaPathSeparator() . $sSourceRootLib; + } + return $sOOoRunnerClasspath; +} + +# ------------------------------------------------------------------------------ +sub getTempPath() +{ + my $sTempPath; + if (isWindowsEnvironment()) + { + $sTempPath = "C:/temp"; + } + elsif (isUnixEnvironment()) + { + $sTempPath = "/tmp"; + } + else + { + die "getTempPath() Failed, due to unsupported environment.\n"; + } + return $sTempPath; +} +# ------------------------------------------------------------------------------ + +sub getProjectOutput() +{ + my $sOutput = appendPath(getProjectRoot(), $ENV{INPATH}); + $sOutput = appendPath($sOutput, "misc"); + return $sOutput; +} + +# ------------------------------------------------------------------------------ +sub getProjectOutputReference() +{ + my $sOutput = appendPath(getProjectRoot(), $ENV{INPATH}); + $sOutput = appendPath($sOutput, "reference"); + return $sOutput; +} + + +sub searchForReference($) +{ + my $sFile = shift; + if ( -e $sFile ) + { + return 0; + } + if ( -e $sFile . ".ps") + { + return 0; + } + if ( -e $sFile . ".pdf") + { + return 0; + } + return 1; +} +# ------------------------------------------------------------------------------ + +# my $sOfficeName = $officeprefixname . $officename; +sub SingleDocumentCompare($$$$$$) +{ + # get all about the document to compare + my $sDocumentPoolPath = shift; + my $sDocumentPool = shift; + my $sDocumentName = shift; + my $sDebug = ""; + + # get all about the destination office + my $sCreatorType = shift; + if (! $sCreatorType) + { + # log_print( "parameter -creatortype not given. Use 'OOo'\n"); + $sCreatorType = "ps"; + } + my $prepareonly = shift; + my $show = shift; + + # my $nSimpleCompareTime = getTime(); + + my $nConvwatchFailed = 0; + set_logfile( appendPath(getProjectOutput(), $sDocumentName . ".txt" )); + + print("$sDocumentName"); + log_print("\n"); + log_print("Graphical compare on document: '$sDocumentName'\n"); + # ------------------------------------------------------------------------------ + # create postscript or pdf from first installed office + # ------------------------------------------------------------------------------ + + my $sOOoRunnerClasspath = quoteIfNeed(getOOoRunnerClasspath()); + if ($OSNAME eq "cygwin") + { + if (!startswith($sOOoRunnerClasspath, "\"")) + { + $sOOoRunnerClasspath = quote($sOOoRunnerClasspath); + } + } + if (length($sOOoRunnerClasspath) == 0) + { + $nConvwatchFailed == 1; + } + # ------------------------------------------------------------------------------ + # create postscript or pdf from second installed office + # ------------------------------------------------------------------------------ + + my $sPathesIni = appendPath(getProjectOutput(), "pathes.ini"); + my $gspath = getFromPathes($sPathesIni, "gs.path"); + my $gsexe = getFromPathes($sPathesIni, "gs.exe"); + my $impath = getFromPathes($sPathesIni, "imagemagick.path"); + my $javaexe = getFromPathes($sPathesIni, "java.exe"); + setJavaExecutable($javaexe); + + log_print("----- CREATE POSTSCRIPT OR PDF WITH RUNNING OFFICE -----\n"); + # my $nPrepareSecondPostscriptTime = getTime(); + if ($nConvwatchFailed == 0) + { + my $sInputPath = $sDocumentPoolPath; + $sInputPath = appendPath($sInputPath, $sDocumentPool); + $sInputPath = appendPath($sInputPath, $sDocumentName); + + if (! -f $sInputPath ) + { + $nConvwatchFailed = 1; + log_print("ERROR: File '$sInputPath' doesn't exists.\n"); + } + else + { + my $sOutputPath = getProjectOutput(); + my $sPropertyFile = appendPath(getProjectOutput() , $sDocumentName . ".build.props"); + + local *PROPERTYFILE; + if (open(PROPERTYFILE, ">$sPropertyFile")) + { + print PROPERTYFILE "# This file is automatically created by graphical_compare.pl\n"; + print PROPERTYFILE "DOC_COMPARATOR_PRINT_MAX_PAGE=9999\n"; + print PROPERTYFILE "DOC_COMPARATOR_GFX_OUTPUT_DPI_RESOLUTION=180\n"; + print PROPERTYFILE "DOC_COMPARATOR_REFERENCE_CREATOR_TYPE=$sCreatorType\n"; + print PROPERTYFILE "TEMPPATH=" . getTempPath() . "\n"; + if ($sConncectionString) + { + print PROPERTYFILE "ConnectionString=$sConncectionString\n"; + } + else + { + print PROPERTYFILE "ConnectionString=pipe,name=" . getUsername() . "\n"; + } + print PROPERTYFILE "OFFICE_VIEWABLE=true\n"; + print PROPERTYFILE "CREATE_DEFAULT_REFERENCE=true\n"; + print PROPERTYFILE "DOC_COMPARATOR_INPUT_PATH=$sInputPath\n"; + print PROPERTYFILE "DOC_COMPARATOR_OUTPUT_PATH=$sOutputPath\n"; + if (isWindowsEnvironment()) + { + print PROPERTYFILE "DOC_COMPARATOR_PRINTER_NAME=CrossOffice Generic Printer\n"; + } + print PROPERTYFILE "NoOffice=true\n"; + + close(PROPERTYFILE); + } + else + { + print "Can't open '$sPropertyFile' for write.\n"; + } + if ( -e "$sPropertyFile") + { + # start OOoRunner + # sleep 10; + # $sOOoRunnerClasspathFromDestinationName = quoteIfNeed(getOOoRunnerClasspath()); + my $sParams; + if ( $ENV{PERL} ) + { + $sParams = "-Dperl.exe=" . convertCygwinPath($ENV{PERL}); + } + + $sParams .= " -cp " . $sOOoRunnerClasspath . + " org.openoffice.Runner" . + " -TimeOut $nTimeOut" . + " -tb java_complex" . + " -ini $sPropertyFile" . + " -o graphical.PostscriptCreator"; + # $sParams .= " -cs pipe,name=$USER"; + + # $sDebug = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9001,suspend=y"; + my $err = calljava(getJavaExecutable(), $sParams, $sDebug); + $sDebug = ""; + log_print( "\n\n"); + if ($err != 0) + { + my $sFailure = "Failed after try to create Postscript/pdf document for " . $sDocumentName; + log_print("ERROR: $sFailure\n"); + $nConvwatchFailed = 1; + } + } + else + { + my $sFailure = "There is no propertyfile: $sPropertyFile"; + log_print( "ERROR: $sFailure\n"); + $nConvwatchFailed=1; + } + } + + # set prepareonly and it is possible to only create ps or pdf files + if ($prepareonly) + { + print(" [only create "); + if ($sCreatorType eq "ps" || $sCreatorType eq "pdf") + { + print(" $sCreatorType"); + } + else + { + print(" (${sCreatorType}?)"); + } + if ($nConvwatchFailed == 0) + { + print(" ok"); + } + else + { + print(" failed") + } + print("]\n"); + return $nConvwatchFailed; + } + + + # ------------------------------------------------------------------------------ + # create jpeg from postscript or pdf from second installed office + # ------------------------------------------------------------------------------ + + if ($nConvwatchFailed == 0) + { + log_print("----- CREATE JPEG FROM POSTSCRIPT OR PDF FROM RUNNING OFFICE -----\n"); + # start OOoRunner + my $sInputPath = getProjectOutput(); + $sInputPath = appendPath($sInputPath, $sDocumentName); + + my $sOutputPath = getProjectOutput(); + + my $sParams = "-cp " . $sOOoRunnerClasspath . + " org.openoffice.Runner" . + " -TimeOut $nTimeOut" . + " -tb java_complex" . + " -DOC_COMPARATOR_INPUT_PATH " . quoteIfNeed($sInputPath) . + " -DOC_COMPARATOR_OUTPUT_PATH " . quoteIfNeed($sOutputPath) . + " -DOC_COMPARATOR_REFERENCE_CREATOR_TYPE $sCreatorType" . + " -NoOffice" . + " -NoSmallPictures" . + " -o graphical.JPEGCreator"; + if ($gspath) + { + $sParams .= " -gs.path " . quoteIfNeed($gspath); + } + if ($gsexe) + { + $sParams .= " -gs.exe $gsexe"; + } + + # $sDebug = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9001,suspend=y"; + my $err = calljava(getJavaExecutable(), $sParams, $sDebug); + $sDebug = ""; + # log_print( "\n\n"); + if ($err != 0) + { + my $sFailure = "Failed after try to create JPEG from Postscript/pdf document for " . $sDocumentName; + log_print("ERROR: $sFailure\n"); + $nConvwatchFailed = 1; + } + } + } + + # ------------------------------------------------------------------------------ + # create jpeg from postscript or pdf from references + # ------------------------------------------------------------------------------ + + if ($nConvwatchFailed == 0) + { + log_print("----- CREATE JPEG FROM POSTSCRIPT OR PDF FROM REFERENCE -----\n"); + + # start OOoRunner + my $sInputPath = appendPath(getProjectRoot(), "references"); + $sInputPath = appendPath($sInputPath, getEnvironment()); + $sInputPath = appendPath($sInputPath, $sDocumentPool); + $sInputPath = appendPath($sInputPath, $sDocumentName); + + my $err = searchForReference($sInputPath); + if ($err != 0) + { + log_print("ERROR: Can't find Postscript or PDF reference for '$sInputPath'\n"); + $nConvwatchFailed = 1; + } + else + { + my $sOutputPath = getProjectOutputReference(); + rmkdir $sOutputPath; + + my $sIndexFile = appendPath($sOutputPath, "index.ini"); + # we need the index.ini for better run through + local *INDEXINI; + if ( ! -e $sIndexFile) + { + if (open(INDEXINI, ">$sIndexFile")) + { + # print INDEXINI "[$sDocumentName]\n"; + close(INDEXINI); + } + } + my $sParams = "-cp " . $sOOoRunnerClasspath . + " org.openoffice.Runner" . + " -TimeOut $nTimeOut" . + " -tb java_complex" . + " -DOC_COMPARATOR_INPUT_PATH " . quoteIfNeed($sInputPath) . + " -DOC_COMPARATOR_OUTPUT_PATH " . quoteIfNeed($sOutputPath) . + " -DOC_COMPARATOR_REFERENCE_CREATOR_TYPE $sCreatorType" . + " -NoOffice" . + " -NoSmallPictures" . + " -o graphical.JPEGCreator"; + if ($gspath) + { + $sParams .= " -gs.path " . quoteIfNeed($gspath); + } + if ($gsexe) + { + $sParams .= " -gs.exe $gsexe"; + } + + # $sDebug = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9001,suspend=y"; + my $err = calljava(getJavaExecutable(), $sParams, $sDebug); + $sDebug = ""; + # log_print( "\n\n"); + if ($err != 0) + { + my $sFailure = "Failed after try to create JPEG from Postscript/pdf document for references."; + log_print("ERROR: $sFailure\n"); + $nConvwatchFailed = 1; + } + } + } + # ------------------------------------------------------------------------------ + # compare JPEGs + # ------------------------------------------------------------------------------ + + if ($nConvwatchFailed == 0) + { + log_print("----- COMPARE JPEGS -----\n"); + my $sInputPath = appendPath(getProjectOutputReference(), $sDocumentName); + + my $sOutputPath = getProjectOutput(); + + my $sParams = "-Xmx512m" . + " -cp " . $sOOoRunnerClasspath . + " org.openoffice.Runner" . + " -TimeOut $nTimeOut" . + " -tb java_complex" . + " -DOC_COMPARATOR_INPUT_PATH " . quoteIfNeed($sInputPath) . + " -DOC_COMPARATOR_OUTPUT_PATH " . quoteIfNeed($sOutputPath) . + " -NoOffice" . + " -NoSmallPictures" . + " -o graphical.JPEGComparator"; + if ($impath) + { + $sParams .= " -imagemagick.path " . quoteIfNeed($impath); + } + + # start OOoRunner + # $sDebug = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9001,suspend=y"; + my $err = calljava(getJavaExecutable(), $sParams, $sDebug); + $sDebug = ""; + log_print( "\n\n"); + if ($err != 0) + { + my $sFailure = "Failed after compare JPEGs $sDocumentName\n"; + log_print("ERROR: $sFailure\n"); + $nConvwatchFailed = 1; + + if ($show) + { + # try to execute new java tool to show graphical compare + my $sJavaProgram = appendPath(getProjectRoot(), $ENV{INPATH}); + $sJavaProgram = appendPath($sJavaProgram, "class"); + $sJavaProgram = appendPath($sJavaProgram, "ConvwatchGUIProject.jar"); + if ( -e "$sJavaProgram") + { + my $sInputPath = appendPath(getProjectOutput(), $sDocumentName . ".ps.ini"); + if (! -e $sInputPath) + { + $sInputPath = appendPath(getProjectOutput(), $sDocumentName . ".pdf.ini"); + if (! -e $sInputPath) + { + $sInputPath = 0; + } + } + if ($sInputPath) + { + my $sParams = "-Xms128m -Xmx512m -jar $sJavaProgram $sInputPath"; + # $sParams .= " -cs pipe,name=$USER"; + # my $sJavaExe = "C:/Program Files/Java/jdk1.6.0_16/bin/java.exe"; # getJavaExecutable() + my $sJavaExe = getJavaExecutable(); + # $sDebug = "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,address=9001,suspend=y"; + my $err = calljava($sJavaExe, $sParams, $sDebug); + # $sDebug = ""; + # log_print( "\n\n"); + # if ($err != 0) + # { + # my $sFailure = "Failed after try to create Postscript/pdf document for " . $sDocumentName; + # log_print("ERROR: $sFailure\n"); + # $nConvwatchFailed = 1; + # } + } + } + else + { + print "WARNING: The show program '$sJavaProgram' doesn't exists.\n"; + } + } + } + } + + log_print( "\n\n"); + close_logfile(); + + if ($nConvwatchFailed == 0) + { + print(" [ok]\n"); + } + else + { + print(" [FAILED]\n"); + print("\nPrint output of test: $sDocumentName\n"); + my $sLogFile = appendPath(getProjectOutput(), $sDocumentName . ".txt"); + showFile($sLogFile); + } + # printTime(endTime($nSimpleCompareTime)); + + return $nConvwatchFailed; +} + +# ------------------------------------------------------------------------------ +# cat $file +sub showFile($) +{ + my $logfile = shift; + local *LOGFILE; + if (open(LOGFILE, "$logfile")) + { + my $line; + while ($line = <LOGFILE>) + { + chomp($line); + print $line ."\n"; + } + close(LOGFILE); + } +} + + +1; diff --git a/testgraphical/source/loghelper.pm b/testgraphical/source/loghelper.pm new file mode 100644 index 000000000000..6dad31c7761a --- /dev/null +++ b/testgraphical/source/loghelper.pm @@ -0,0 +1,94 @@ +package loghelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use strict; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&set_logfile &close_logfile &log_print &setVerbose); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + +# ------------------------------- Log into a file ------------------------------- +local *LOGFILE; +our $nGlobalLog = 0; +our $nGlobalVerbose = 0; + +sub setVerbose() +{ + $nGlobalVerbose = 1; +} + +sub set_logfile($) +{ + my $sLogFile = shift; + + if (open(LOGFILE, ">$sLogFile")) + { + $nGlobalLog = 1; + } +} +sub close_logfile() +{ + close(LOGFILE); + $nGlobalLog = 0; +} + +sub log_print($) +{ + my $sLine = shift; + if ($nGlobalLog) + { + print LOGFILE $sLine; + } + if ($nGlobalVerbose == 1) + { + print $sLine; + } + else + { + # In this special case for NetBeans, which show if a debugger can access. + # The Line should print anyway. + if ($sLine =~ /Listening for transport/) + { + print $sLine; + } + } +} + +1; diff --git a/testgraphical/source/makefile.mk b/testgraphical/source/makefile.mk new file mode 100644 index 000000000000..619fd7786f93 --- /dev/null +++ b/testgraphical/source/makefile.mk @@ -0,0 +1,112 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=.. + +PRJNAME=gfxcmp +TARGET=notargetyet + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + +# call with PDF=1 to use office pdf exporter instead of the XPrinter API +.IF "$(PDF)"!="" + CREATORTYPE="-creatortype" pdf +.ELSE + CREATORTYE="-creatortype" ps +.ENDIF + +.IF "$(SHOW)"!="" + P_SHOW=-show +.ENDIF + + +# call with PREPARE=1 to only create new reference files +# copy these files by hand into the corresponding directories +.IF "$(PREPARE)"!="" + PREPAREONLY="-prepareonly" 1 +.ELSE + PREPAREONLY= +.ENDIF + +.IF "$(DOCUMENTPOOL)"=="" + DOCUMENTPOOL=$PRJ$/document-pool +.ENDIF + +# PERLDEBUG=-d:ptkdb +ALLTAR: selftest +# pwd +# $(PERL) $(PERLDEBUG) compare.pl -MAJOR $(WORK_STAMP) -MINOR $(UPDMINOR) -cwsname "$(CWS_WORK_STAMP)" +# $(PERL) $(PERLDEBUG) compare.pl -pool singletest + +# $(PRJ)$/util$/makefile.pmk contains ALLTAR stuff + +# selftest is the default run through at the moment and use pdf export to create output. +# dmake +selftest: + $(PERL) $(PERLDEBUG) compare.pl -creatortype pdf $(PREPAREONLY) -pool singletest -document eis-test.odt $(P_SHOW) + +# selftest_ps is like the default run through but use always postscript print out +# dmake selftest_ps +selftest_ps: + $(PERL) $(PERLDEBUG) compare.pl -creatortype ps $(PREPAREONLY) -pool singletest -document eis-test.odt $(P_SHOW) + +# +# +# The follows are demonstration targets, DO NOT DELETE +# +# + +# dmake demo SHOW=1 +demo: + $(PERL) $(PERLDEBUG) compare.pl $(CREATORTYPE) $(PREPAREONLY) -pool $@ $(P_SHOW) + +# failtest is a demonstration of a failure, with SHOW=1 it should open a java windows which shows 3 pictures, +# the current document, the reference document and the difference between both. +# dmake failtest SHOW=1 +# dmake failtest PREPARE=1 +# This test will most the time fail, it is just a demonstration. +failtest: + $(PERL) $(PERLDEBUG) compare.pl $(CREATORTYPE) $(PREPAREONLY) -force -pool demo -document CurrentTime.ods $(P_SHOW) + +# manual runs through all documents found in document-pool +# dmake manual +# dmake manual PDF=1 SHOW=1 +# dmake manual PREPARE=1 PDF=1 +# should help to create a lot of references at one time. +manual: + $(PERL) $(PERLDEBUG) compare.pl $(CREATORTYPE) $(PREPAREONLY) -force $(P_SHOW) + +# msoffice: +# $(PERL) $(PERLDEBUG) compare.pl -creatortype msoffice $(PREPAREONLY) -pool msoffice -document calc_cellformat_import_biff8.xls $(P_SHOW) + +clean: diff --git a/testgraphical/source/oshelper.pm b/testgraphical/source/oshelper.pm new file mode 100644 index 000000000000..3f2ed1c44e38 --- /dev/null +++ b/testgraphical/source/oshelper.pm @@ -0,0 +1,110 @@ +package oshelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use English; +use warnings; +use strict; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&getEnvironment &isWindowsEnvironment &isUnixEnvironment &getUsername); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + + +# ------------------------------------------------------------------------------ +sub getEnvironment() +{ + my $sEnvironment; + if ($OSNAME eq "MSWin32" || $OSNAME eq "cygwin") + { + $sEnvironment = "wntmsci"; + } + elsif ( $OSNAME eq "linux") + { + $sEnvironment = "unxlngi"; + } + elsif ( $OSNAME eq "solaris") + { + $sEnvironment = "unxsoli"; + } + else + { + print "Unknown Environment please check OSNAME: '$OSNAME'\n"; + $sEnvironment = "unknown"; + } + return $sEnvironment; +} + +# ------------------------------------------------------------------------------ + +sub isWindowsEnvironment() +{ + if ($OSNAME eq "MSWin32" || + $OSNAME eq "cygwin") + { + return 1; + } + return 0; +} + +sub isUnixEnvironment() +{ + if ($OSNAME eq "linux" || + $OSNAME eq "solaris") + { + return 1; + } + return 0; +} + +sub getUsername() +{ + my $sUser = $ENV{USER}; + if (!$sUser) + { + $sUser = $ENV{USERNAME}; + } + if (!$sUser) + { + die "Username not set.\n"; + } + return $sUser; +} + +1; diff --git a/testgraphical/source/solarenvhelper.pm b/testgraphical/source/solarenvhelper.pm new file mode 100644 index 000000000000..f8ec17ece12b --- /dev/null +++ b/testgraphical/source/solarenvhelper.pm @@ -0,0 +1,63 @@ +package solarenvhelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use strict; +use warnings; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&setSolenvPath &getSolenvPath); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + +our $sSolenvPath; +sub setSolenvPath($) +{ + $sSolenvPath = shift; +} +sub getSolenvPath() +{ + if ($sSolenvPath) + { + return $sSolenvPath; + } + print "INTERNAL ERROR: You must set the solenv path to the performancetest, by call setSolenvPath()\n"; + exit 1; +} + +1; diff --git a/testgraphical/source/stringhelper.pm b/testgraphical/source/stringhelper.pm new file mode 100644 index 000000000000..e7d19256bf1b --- /dev/null +++ b/testgraphical/source/stringhelper.pm @@ -0,0 +1,69 @@ +package stringhelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use strict; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.2 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&endswith &startswith); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + +# string helper like java endsWith +sub endswith($$) +{ + my $string = shift; + my $search = shift; + if ( $string =~ /${search}$/ ) + { + return 1; + } + return 0; +} +sub startswith($$) +{ + my $string = shift; + my $search = shift; + if ( $string =~ /^${search}/ ) + { + return 1; + } + return 0; +} + +1; diff --git a/testgraphical/source/timehelper.pm b/testgraphical/source/timehelper.pm new file mode 100644 index 000000000000..38bd56fc4b20 --- /dev/null +++ b/testgraphical/source/timehelper.pm @@ -0,0 +1,99 @@ +package timehelper; + +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org 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 version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +use POSIX qw(strftime); +use POSIX qw(time difftime); +# use POSIX qw(localtime); +use strict; +# use Time::localtime; +use loghelper; + +BEGIN { + use Exporter (); + our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS); + + $VERSION = 1.00; + # if using RCS/CVS, this may be preferred + $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker + @ISA = qw(Exporter); + @EXPORT = qw(&getTime &endTime &printTime &waitAMinute ); + %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ], + # your exported package globals go here, + # as well as any optionally exported functions + @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3); +} + + +# ------------------------------------------------------------------------------ +# our $starttime; +sub getTime() +{ + my $nValue; + # $nValue = localtime->sec(); + # $nValue += 60 * localtime->min(); + # $nValue += 3600 * localtime->hour(); + $nValue = time(); + return $nValue; +} +# sub startTime() +# { +# $starttime = getTime(); +# } +sub endTime($) +{ + my $starttime = shift; + + my $endtime = getTime(); + my $nTime = difftime($endtime, $starttime); + # my $nTime = $endtime - $starttime; + # if ($nTime < 0) + # { + # $nTime += 24 * 3600; # add 24 hours + # } + return $nTime; +} +sub printTime($) +{ + my $nTime = shift; + print( "Time: " . $nTime . " seconds.\n\n"); +} + + +# sub waitAMinute() +# { +# # _waitInSeconds(20); +# # _waitInSeconds(20); +# my $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime; +# print $now_string . "\n"; +# # print getCurrentDateString() . "\n"; +# sleep(60); +# } +# + +1; |