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