jl165 merging heads
[LibreOffice.git] / testgraphical / source / cwstestresulthelper.pm
blob37a5315445afbe8ff159978075d306b9081d691d
1 package cwstestresulthelper;
3 #*************************************************************************
5 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 # Copyright 2000, 2010 Oracle and/or its affiliates.
9 # OpenOffice.org - a multi-platform office productivity suite
11 # This file is part of OpenOffice.org.
13 # OpenOffice.org is free software: you can redistribute it and/or modify
14 # it under the terms of the GNU Lesser General Public License version 3
15 # only, as published by the Free Software Foundation.
17 # OpenOffice.org is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU Lesser General Public License version 3 for more details
21 # (a copy is included in the LICENSE file that accompanied this code).
23 # You should have received a copy of the GNU Lesser General Public License
24 # version 3 along with OpenOffice.org. If not, see
25 # <http://www.openoffice.org/license.html>
26 # for a copy of the LGPLv3 License.
28 #*************************************************************************
30 use English;
31 use warnings;
32 use strict;
33 use Cwd;
34 use Cwd 'chdir';
36 use stringhelper;
37 use loghelper;
38 use oshelper;
39 use filehelper;
40 use CallExternals;
42 BEGIN {
43 use Exporter ();
44 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
46 $VERSION = 1.00;
47 # if using RCS/CVS, this may be preferred
48 $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; # must be all one line, for MakeMaker
49 @ISA = qw(Exporter);
50 @EXPORT = qw(&cwstestresult);
51 %EXPORT_TAGS = ( ); # eg: TAG => [ qw!name1 name2! ],
52 # your exported package globals go here,
53 # as well as any optionally exported functions
54 @EXPORT_OK = ( ); # qw($Var1 %Hashit &func3);
57 sub cwstestresult($$$$$$)
59 my $sStatus = shift;
60 my $sDBdistinct = shift;
61 my $sourceversion = shift;
62 my $destinationversion = shift;
64 my $sSOLARENV; # = getSolenvPath();
65 my $nSOLARENV_fake = 0;
66 my $sCOMMON_ENV_TOOLS;
67 my $nCOMMON_ENV_TOOLS_fake = 0;
69 my $MAJOR;
70 my $MINOR;
71 # we need an extra state in DB
72 # if this state is given here, we need to add information in cws back.
73 if ( ! $sSOLARENV)
75 my @MAJORMINOR=split('_', $sourceversion);
76 if ($#MAJORMINOR < 1)
78 print "Failure with sourceversion '$sourceversion' not splitable.\n";
79 return;
81 $MAJOR=$MAJORMINOR[0]; # DEV300, OOH310, ...
82 $MINOR=$MAJORMINOR[1]; # m45, ...
83 if (getEnvironment() eq "wntmsci")
85 $sSOLARENV="o:/$MAJOR/ooo.$MINOR/solenv";
86 if (! -e $sSOLARENV)
88 # fallback to old before ause103 (treeconfig)
89 $sSOLARENV="o:/$MAJOR/src.$MINOR/solenv";
92 elsif (getEnvironment() eq "unxlngi" ||
93 getEnvironment() eq "unxsoli")
95 $sSOLARENV="/so/ws/$MAJOR/ooo.$MINOR/solenv";
96 # automount
97 system("ls -al $sSOLARENV >/dev/null");
98 sleep(1);
99 if (! -e $sSOLARENV)
101 # fallback to old before ause103 (treeconfig)
102 $sSOLARENV="/so/ws/$MAJOR/src.$MINOR/solenv";
105 else
107 log_print("cwstestresult(): This environment is not supported.");
108 return;
111 if ( !defined($ENV{SOLARENV}) || length($ENV{SOLARENV}) == 0 )
113 $ENV{SOLARENV} = $sSOLARENV;
114 log_print(" SOLARENV is: $ENV{SOLARENV} faked\n");
115 $nSOLARENV_fake = 1;
117 if ( ! $sCOMMON_ENV_TOOLS)
119 if (isWindowsEnvironment())
121 $sCOMMON_ENV_TOOLS="r:/etools";
123 elsif (isUnixEnvironment() )
125 $sCOMMON_ENV_TOOLS="/so/env/etools";
126 # automount
127 system("ls -al $sCOMMON_ENV_TOOLS >/dev/null");
128 sleep(1);
130 else
132 log_print("cwstestresult(): This environment is not supported. (variable COMMON_ENV_TOOLS not set.)");
133 return;
136 if ( !defined($ENV{COMMON_ENV_TOOLS}) || length($ENV{COMMON_ENV_TOOLS}) == 0 )
138 $ENV{COMMON_ENV_TOOLS} = $sCOMMON_ENV_TOOLS;
139 log_print( "COMMON_ENV_TOOLS is: $ENV{COMMON_ENV_TOOLS} faked\n");
140 $nCOMMON_ENV_TOOLS_fake = 1;
143 # if ( !defined($ENV{WORK_STAMP}) )
145 # $ENV{WORK_STAMP} = $MAJOR;
146 # log_print( " WORK_STAMP is: $ENV{WORK_STAMP} faked\n");
148 # if ( !defined($ENV{UPDMINOR}) )
150 # $ENV{UPDMINOR} = $MINOR;
151 # log_print( " UPDMINOR is: $ENV{UPDMINOR} faked\n");
154 my $nWORK_STAMP_fake = 0;
155 my $nUPDMINOR_fake = 0;
157 if ( !defined($ENV{WORK_STAMP}) || length($ENV{WORK_STAMP}) == 0 )
159 $ENV{WORK_STAMP} = $MAJOR;
160 log_print(" WORK_STAMP is: $ENV{WORK_STAMP} faked\n");
161 $nWORK_STAMP_fake = 1;
163 if ( !defined($ENV{UPDMINOR}) || length($ENV{WORK_STAMP}) == 0 )
165 $ENV{UPDMINOR} = $MINOR;
166 log_print(" UPDMINOR is: $ENV{UPDMINOR} faked\n");
167 $nUPDMINOR_fake = 1;
170 # my $sStatus = "ok";
171 # if ($nFailure == 0)
173 # $sStatus = $sInfo;
175 # elsif ($nFailure == 1)
177 # $sStatus = "failed";
179 # elsif ($nFailure == 2)
181 # $sStatus = "incomplete";
184 # system("cwstestresult -c mycws -n Performance -p Windows ok");
185 my $sPerlProgram = appendPath($sSOLARENV, "bin/cwstestresult.pl");
186 # if ( -e "cwstestresult.pl" )
188 # # use a local version instead
189 # $sPerlProgram = "cwstestresult.pl";
191 # else
193 # my $currentdir =cwd();
194 # log_print( "We are in $currentdir\n");
197 my $sPerlParam;
198 # $sPerlParam = " -m $MAJOR"; # master CWS
199 $sPerlParam .= " -c $destinationversion"; # name of CWS
200 $sPerlParam .= " -n ConvWatch"; # ConvWatch need to be capitalised for cwstestresult
201 my $sCWSEnv;
202 if (isWindowsEnvironment())
204 $sCWSEnv = "Windows";
206 elsif (getEnvironment() eq "unxlngi")
208 $sCWSEnv = "Linux";
210 elsif (getEnvironment() eq "unxsoli")
212 $sCWSEnv = "SolarisX86";
214 else
216 log_print("cwstestresult(): This environment is not supported. (getEnvironment() returns wrong value?)");
217 return;
219 $sPerlParam .= " -p " . $sCWSEnv;
220 $sPerlParam .= " -r http://so-gfxcmp-lin.germany.sun.com/gfxcmp_ui/status_new.php?distinct=$sDBdistinct";
222 $sPerlParam .= " ";
223 $sPerlParam .= $sStatus;
226 # my $sSetcwsAndPerl = "setcws $destinationversion; " . getPerlExecutable();
228 my $err = callperl(getPerlExecutable(), $sPerlProgram, $sPerlParam);
229 if ($err != 0)
231 log_print( "Can't call cwstestresult.pl\n");
233 if ($nSOLARENV_fake == 1)
235 $ENV{SOLARENV} = "";
236 undef( $ENV{SOLARENV} );
237 $nSOLARENV_fake = 0;
238 # if ( defined($ENV{SOLARENV}) )
240 # print "SOLARENV always defined.\n";
243 if ($nCOMMON_ENV_TOOLS_fake == 1)
245 $ENV{COMMON_ENV_TOOLS} = "";
246 undef( $ENV{COMMON_ENV_TOOLS} );
247 $nCOMMON_ENV_TOOLS_fake = 0;
250 if ( $nWORK_STAMP_fake == 1 )
252 # undef($ENV{WORK_STAMP});
253 $ENV{WORK_STAMP} = "";
254 undef($ENV{WORK_STAMP});
255 $nWORK_STAMP_fake = 0;
257 if ( $nUPDMINOR_fake == 1 )
259 $ENV{UPDMINOR} = "";
260 undef($ENV{UPDMINOR});
261 $nUPDMINOR_fake = 0;