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