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