1*b1cdbd2cSJim Jagielski#!/usr/bin/perl -w 2*b1cdbd2cSJim Jagielski# ************************************************************* 3*b1cdbd2cSJim Jagielski# 4*b1cdbd2cSJim Jagielski# Licensed to the Apache Software Foundation (ASF) under one 5*b1cdbd2cSJim Jagielski# or more contributor license agreements. See the NOTICE file 6*b1cdbd2cSJim Jagielski# distributed with this work for additional information 7*b1cdbd2cSJim Jagielski# regarding copyright ownership. The ASF licenses this file 8*b1cdbd2cSJim Jagielski# to you under the Apache License, Version 2.0 (the 9*b1cdbd2cSJim Jagielski# "License"); you may not use this file except in compliance 10*b1cdbd2cSJim Jagielski# with the License. You may obtain a copy of the License at 11*b1cdbd2cSJim Jagielski# 12*b1cdbd2cSJim Jagielski# http://www.apache.org/licenses/LICENSE-2.0 13*b1cdbd2cSJim Jagielski# 14*b1cdbd2cSJim Jagielski# Unless required by applicable law or agreed to in writing, 15*b1cdbd2cSJim Jagielski# software distributed under the License is distributed on an 16*b1cdbd2cSJim Jagielski# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17*b1cdbd2cSJim Jagielski# KIND, either express or implied. See the License for the 18*b1cdbd2cSJim Jagielski# specific language governing permissions and limitations 19*b1cdbd2cSJim Jagielski# under the License. 20*b1cdbd2cSJim Jagielski# 21*b1cdbd2cSJim Jagielski# ************************************************************* 22*b1cdbd2cSJim Jagielskiuse URI::Escape; 23*b1cdbd2cSJim Jagielskiuse File::Basename; 24*b1cdbd2cSJim Jagielskiuse Cwd; 25*b1cdbd2cSJim Jagielskiuse Cwd 'abs_path'; 26*b1cdbd2cSJim Jagielski 27*b1cdbd2cSJim Jagielski$numArgs = $#ARGV + 1; 28*b1cdbd2cSJim Jagielskiprint "thanks, you gave me $numArgs command-line arguments.\n"; 29*b1cdbd2cSJim Jagielski 30*b1cdbd2cSJim Jagielskiforeach $argnum (0 .. $#ARGV) { 31*b1cdbd2cSJim Jagielski print "$ARGV[$argnum]\n"; 32*b1cdbd2cSJim Jagielski} 33*b1cdbd2cSJim Jagielski 34*b1cdbd2cSJim Jagielski 35*b1cdbd2cSJim Jagielskimy $binDir = abs_path( dirname($0) ); 36*b1cdbd2cSJim Jagielski 37*b1cdbd2cSJim Jagielskimy $sysDir = "unix"; 38*b1cdbd2cSJim Jagielskimy $fileSep = "/"; 39*b1cdbd2cSJim Jagielskimy $theResult; 40*b1cdbd2cSJim Jagielskimy $officepath = shift || die "please specify path to office installation program dir"; 41*b1cdbd2cSJim Jagielskimy $DocName = shift || ""; 42*b1cdbd2cSJim Jagielskimy $programpath = "$officepath"."3/program:$officepath/program:"; 43*b1cdbd2cSJim Jagielskimy $basiclibrarypath = "$officepath/basis3.3/program"; 44*b1cdbd2cSJim Jagielskimy $urelibpath = "$officepath/ure/lib"; 45*b1cdbd2cSJim Jagielskimy $binext = ""; 46*b1cdbd2cSJim Jagielskimy $testDocDir = "$binDir/TestDocuments"; 47*b1cdbd2cSJim Jagielskimy $testLogDir = "$binDir/Logs"; 48*b1cdbd2cSJim Jagielskimy $testclientname = "testclient"; 49*b1cdbd2cSJim Jagielskimy $buildtestclient = "../../../../unxlngi6.pro/bin/$testclientname"; 50*b1cdbd2cSJim Jagielski 51*b1cdbd2cSJim Jagielski# test testclient 52*b1cdbd2cSJim Jagielskiif ( -e "$buildtestclient" ) 53*b1cdbd2cSJim Jagielski{ 54*b1cdbd2cSJim Jagielski print "use the latest build\n"; 55*b1cdbd2cSJim Jagielski system( "cp $buildtestclient ." ); 56*b1cdbd2cSJim Jagielski} 57*b1cdbd2cSJim Jagielskielsif ( !( -e "$testclientname" ) ) 58*b1cdbd2cSJim Jagielski{ 59*b1cdbd2cSJim Jagielski print "$testclientname do not exist\n"; 60*b1cdbd2cSJim Jagielski exit; 61*b1cdbd2cSJim Jagielski} 62*b1cdbd2cSJim Jagielski 63*b1cdbd2cSJim Jagielski# test for uname 64*b1cdbd2cSJim Jagielskisystem("uname"); 65*b1cdbd2cSJim Jagielski$exit_value = $? >> 8; 66*b1cdbd2cSJim Jagielski$signal_num = $? & 127; 67*b1cdbd2cSJim Jagielski$dumped_core = $? & 128; 68*b1cdbd2cSJim Jagielski 69*b1cdbd2cSJim Jagielski$failed = ( $exit_value || $signal_num || $dumped_core ); 70*b1cdbd2cSJim Jagielski 71*b1cdbd2cSJim Jagielskiprint "$failed = ( $exit_value || $signal_num || $dumped_core )\n"; 72*b1cdbd2cSJim Jagielski 73*b1cdbd2cSJim Jagielskiif ( !$failed && open(UNAME, "uname -a|") ) { 74*b1cdbd2cSJim Jagielski $theResult = <UNAME>; 75*b1cdbd2cSJim Jagielski close(UNAME); 76*b1cdbd2cSJim Jagielski if ( $theResult =~ /^CYGWIN/ ) { 77*b1cdbd2cSJim Jagielski # windows under cygwin 78*b1cdbd2cSJim Jagielski $sysDir = "win" ; 79*b1cdbd2cSJim Jagielski $tmpPath=$ENV{"PATH"}; 80*b1cdbd2cSJim Jagielski $ENV{"PATH"} = "$officepath:$tmpPath"; 81*b1cdbd2cSJim Jagielski $testDocDir=`cygpath -m $testDocDir`; 82*b1cdbd2cSJim Jagielski uri_escape($testDocDir); 83*b1cdbd2cSJim Jagielski # hacky windows url construction 84*b1cdbd2cSJim Jagielski $testDocDir="file:///$testDocDir"; 85*b1cdbd2cSJim Jagielski 86*b1cdbd2cSJim Jagielski chomp($testDocDir); 87*b1cdbd2cSJim Jagielski #print "*** doc dir is $testDocDir\n"; 88*b1cdbd2cSJim Jagielski $testLogDir = `cygpath -m "$testLogDir"`; 89*b1cdbd2cSJim Jagielski uri_escape($testLogDir); 90*b1cdbd2cSJim Jagielski $testLogDir="file:///$testLogDir"; 91*b1cdbd2cSJim Jagielski chomp($testLogDir); 92*b1cdbd2cSJim Jagielski #print "*** log dir is $testLogDir\n"; 93*b1cdbd2cSJim Jagielski $binext = ".exe"; 94*b1cdbd2cSJim Jagielski } 95*b1cdbd2cSJim Jagielski else{ 96*b1cdbd2cSJim Jagielski # unix we need to find sal etc. ( from the office path ) 97*b1cdbd2cSJim Jagielski my $tmpPath=$ENV{"PATH"}; 98*b1cdbd2cSJim Jagielski $ENV{"PATH"} = "$programpath:$basiclibrarypath:$urelibpath/../bin:$tmpPath"; 99*b1cdbd2cSJim Jagielski $tmpPATH = $ENV{"LD_LIBRARY_PATH"}; 100*b1cdbd2cSJim Jagielski $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$urelibpath../bin/javaldx:$urelibpath/../bin:$tmpPATH"; 101*b1cdbd2cSJim Jagielski $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$tmpPATH"; 102*b1cdbd2cSJim Jagielski my $testPath = $ENV{"LD_LIBRARY_PATH"}; 103*b1cdbd2cSJim Jagielski print "$testPath\n"; 104*b1cdbd2cSJim Jagielski $testPath = $ENV{"PATH"}; 105*b1cdbd2cSJim Jagielski print "$testPath\n"; 106*b1cdbd2cSJim Jagielski $ENV{"STAR_RESOURCEPATH"} = "$officepath/basis3.0/program/resource"; 107*b1cdbd2cSJim Jagielski $ENV{"SAL_ALLOW_LINKOO_SYMLINKS"} = "1"; 108*b1cdbd2cSJim Jagielski $testPath = $ENV{"LANG"}; 109*b1cdbd2cSJim Jagielski print "$testPath\n"; 110*b1cdbd2cSJim Jagielski } 111*b1cdbd2cSJim Jagielski} 112*b1cdbd2cSJim Jagielskielse 113*b1cdbd2cSJim Jagielski{ 114*b1cdbd2cSJim Jagielski # ordinary windows, not sure if this will actually work 115*b1cdbd2cSJim Jagielski $sysDir = "win" ; 116*b1cdbd2cSJim Jagielski $tmpPath=$ENV{"PATH"}; 117*b1cdbd2cSJim Jagielski $ENV{"PATH"} = "$tmpPath;$officepath"; 118*b1cdbd2cSJim Jagielski $binext = ".exe"; 119*b1cdbd2cSJim Jagielski} 120*b1cdbd2cSJim Jagielski 121*b1cdbd2cSJim Jagielski# the exe needs system paths or urls ( urls are by far the least troublesome ) 122*b1cdbd2cSJim Jagielski 123*b1cdbd2cSJim Jagielskimy $runCmd = ""; 124*b1cdbd2cSJim Jagielskimy $analyseCmd = ""; 125*b1cdbd2cSJim Jagielski 126*b1cdbd2cSJim Jagielskiif ( "$DocName" eq "" ) 127*b1cdbd2cSJim Jagielski{ 128*b1cdbd2cSJim Jagielski $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir"; 129*b1cdbd2cSJim Jagielski $analyseCmd = "perl $binDir/testResults.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir"; 130*b1cdbd2cSJim Jagielski} 131*b1cdbd2cSJim Jagielskielse 132*b1cdbd2cSJim Jagielski{ 133*b1cdbd2cSJim Jagielski $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir $testDocDir/$DocName"; 134*b1cdbd2cSJim Jagielski $analyseCmd = "perl $binDir/testResult.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir $DocName"; 135*b1cdbd2cSJim Jagielski} 136*b1cdbd2cSJim Jagielskiprint "runCmd = $runCmd\n"; 137*b1cdbd2cSJim Jagielski 138*b1cdbd2cSJim Jagielskisystem ("rm -rf $testLogDir/*"); 139*b1cdbd2cSJim Jagielskimy $status = system( $runCmd ); 140*b1cdbd2cSJim Jagielskiprint "analyseCmd = $analyseCmd\n"; 141*b1cdbd2cSJim Jagielski$status = system( $analyseCmd ); 142