xref: /AOO41X/main/sc/source/ui/vba/testvba/runTests.pl (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir#!/usr/bin/perl -w
2*cdf0e10cSrcweiruse URI::Escape;
3*cdf0e10cSrcweiruse File::Basename;
4*cdf0e10cSrcweiruse Cwd;
5*cdf0e10cSrcweiruse Cwd 'abs_path';
6*cdf0e10cSrcweir
7*cdf0e10cSrcweir$numArgs = $#ARGV + 1;
8*cdf0e10cSrcweirprint "thanks, you gave me $numArgs command-line arguments.\n";
9*cdf0e10cSrcweir
10*cdf0e10cSrcweirforeach $argnum (0 .. $#ARGV) {
11*cdf0e10cSrcweir   print "$ARGV[$argnum]\n";
12*cdf0e10cSrcweir}
13*cdf0e10cSrcweir
14*cdf0e10cSrcweir
15*cdf0e10cSrcweirmy $binDir = abs_path( dirname($0) );
16*cdf0e10cSrcweir
17*cdf0e10cSrcweirmy $sysDir = "unix";
18*cdf0e10cSrcweirmy $fileSep = "/";
19*cdf0e10cSrcweirmy $theResult;
20*cdf0e10cSrcweirmy $officepath = shift || die "please specify path to office installation program dir";
21*cdf0e10cSrcweirmy $DocName = shift || "";
22*cdf0e10cSrcweirmy $programpath = "$officepath"."3/program:$officepath/program:";
23*cdf0e10cSrcweirmy $basiclibrarypath = "$officepath/basis3.3/program";
24*cdf0e10cSrcweirmy $urelibpath = "$officepath/ure/lib";
25*cdf0e10cSrcweirmy $binext = "";
26*cdf0e10cSrcweirmy $testDocDir = "$binDir/TestDocuments";
27*cdf0e10cSrcweirmy $testLogDir = "$binDir/Logs";
28*cdf0e10cSrcweirmy $testclientname = "testclient";
29*cdf0e10cSrcweirmy $buildtestclient = "../../../../unxlngi6.pro/bin/$testclientname";
30*cdf0e10cSrcweir
31*cdf0e10cSrcweir# test testclient
32*cdf0e10cSrcweirif ( -e "$buildtestclient" )
33*cdf0e10cSrcweir{
34*cdf0e10cSrcweir    print "use the latest build\n";
35*cdf0e10cSrcweir    system( "cp $buildtestclient ." );
36*cdf0e10cSrcweir}
37*cdf0e10cSrcweirelsif ( !( -e "$testclientname" ) )
38*cdf0e10cSrcweir{
39*cdf0e10cSrcweir    print "$testclientname do not exist\n";
40*cdf0e10cSrcweir    exit;
41*cdf0e10cSrcweir}
42*cdf0e10cSrcweir
43*cdf0e10cSrcweir# test for uname
44*cdf0e10cSrcweirsystem("uname");
45*cdf0e10cSrcweir$exit_value  = $? >> 8;
46*cdf0e10cSrcweir$signal_num  = $? & 127;
47*cdf0e10cSrcweir$dumped_core = $? & 128;
48*cdf0e10cSrcweir
49*cdf0e10cSrcweir$failed = ( $exit_value || $signal_num || $dumped_core );
50*cdf0e10cSrcweir
51*cdf0e10cSrcweirprint "$failed = ( $exit_value || $signal_num || $dumped_core )\n";
52*cdf0e10cSrcweir
53*cdf0e10cSrcweirif ( !$failed && open(UNAME, "uname -a|") ) {
54*cdf0e10cSrcweir   $theResult = <UNAME>;
55*cdf0e10cSrcweir   close(UNAME);
56*cdf0e10cSrcweir   if (  $theResult =~ /^CYGWIN/  ) {
57*cdf0e10cSrcweir      # windows under cygwin
58*cdf0e10cSrcweir      $sysDir = "win" ;
59*cdf0e10cSrcweir      $tmpPath=$ENV{"PATH"};
60*cdf0e10cSrcweir      $ENV{"PATH"} = "$officepath:$tmpPath";
61*cdf0e10cSrcweir      $testDocDir=`cygpath -m  $testDocDir`;
62*cdf0e10cSrcweir      uri_escape($testDocDir);
63*cdf0e10cSrcweir      # hacky windows url construction
64*cdf0e10cSrcweir      $testDocDir="file:///$testDocDir";
65*cdf0e10cSrcweir
66*cdf0e10cSrcweir      chomp($testDocDir);
67*cdf0e10cSrcweir      #print "*** doc dir is $testDocDir\n";
68*cdf0e10cSrcweir      $testLogDir = `cygpath -m  "$testLogDir"`;
69*cdf0e10cSrcweir      uri_escape($testLogDir);
70*cdf0e10cSrcweir      $testLogDir="file:///$testLogDir";
71*cdf0e10cSrcweir      chomp($testLogDir);
72*cdf0e10cSrcweir      #print "*** log dir is $testLogDir\n";
73*cdf0e10cSrcweir      $binext = ".exe";
74*cdf0e10cSrcweir   }
75*cdf0e10cSrcweir   else{
76*cdf0e10cSrcweir      # unix we need to find sal etc. ( from the office path )
77*cdf0e10cSrcweir      my $tmpPath=$ENV{"PATH"};
78*cdf0e10cSrcweir      $ENV{"PATH"} = "$programpath:$basiclibrarypath:$urelibpath/../bin:$tmpPath";
79*cdf0e10cSrcweir      $tmpPATH = $ENV{"LD_LIBRARY_PATH"};
80*cdf0e10cSrcweir      $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$urelibpath../bin/javaldx:$urelibpath/../bin:$tmpPATH";
81*cdf0e10cSrcweir      $ENV{"LD_LIBRARY_PATH"} = "$officepath:$programpath:$basiclibrarypath:$urelibpath:$tmpPATH";
82*cdf0e10cSrcweir      my $testPath = $ENV{"LD_LIBRARY_PATH"};
83*cdf0e10cSrcweir      print "$testPath\n";
84*cdf0e10cSrcweir      $testPath = $ENV{"PATH"};
85*cdf0e10cSrcweir      print "$testPath\n";
86*cdf0e10cSrcweir      $ENV{"STAR_RESOURCEPATH"} = "$officepath/basis3.0/program/resource";
87*cdf0e10cSrcweir      $ENV{"SAL_ALLOW_LINKOO_SYMLINKS"} = "1";
88*cdf0e10cSrcweir      $testPath = $ENV{"LANG"};
89*cdf0e10cSrcweir      print "$testPath\n";
90*cdf0e10cSrcweir   }
91*cdf0e10cSrcweir}
92*cdf0e10cSrcweirelse
93*cdf0e10cSrcweir{
94*cdf0e10cSrcweir      # ordinary windows, not sure if this will actually work
95*cdf0e10cSrcweir      $sysDir = "win" ;
96*cdf0e10cSrcweir      $tmpPath=$ENV{"PATH"};
97*cdf0e10cSrcweir      $ENV{"PATH"} = "$tmpPath;$officepath";
98*cdf0e10cSrcweir      $binext = ".exe";
99*cdf0e10cSrcweir}
100*cdf0e10cSrcweir
101*cdf0e10cSrcweir# the exe needs system paths or urls ( urls are by far the least troublesome )
102*cdf0e10cSrcweir
103*cdf0e10cSrcweirmy $runCmd = "";
104*cdf0e10cSrcweirmy $analyseCmd = "";
105*cdf0e10cSrcweir
106*cdf0e10cSrcweirif ( "$DocName" eq "" )
107*cdf0e10cSrcweir{
108*cdf0e10cSrcweir    $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir";
109*cdf0e10cSrcweir    $analyseCmd = "perl $binDir/testResults.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir";
110*cdf0e10cSrcweir}
111*cdf0e10cSrcweirelse
112*cdf0e10cSrcweir{
113*cdf0e10cSrcweir    $runCmd = "$binDir/testclient$binext $testDocDir $testLogDir $testDocDir/$DocName";
114*cdf0e10cSrcweir    $analyseCmd = "perl $binDir/testResult.pl $binDir/Logs $binDir/TestDocuments/logs/$sysDir $DocName";
115*cdf0e10cSrcweir}
116*cdf0e10cSrcweirprint "runCmd = $runCmd\n";
117*cdf0e10cSrcweir
118*cdf0e10cSrcweirsystem ("rm -rf $testLogDir/*");
119*cdf0e10cSrcweirmy $status = system( $runCmd );
120*cdf0e10cSrcweirprint "analyseCmd = $analyseCmd\n";
121*cdf0e10cSrcweir$status = system( $analyseCmd );
122