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