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