1: 2eval 'exec perl -wS $0 ${1+"$@"}' 3 if 0; 4#************************************************************************* 5# 6# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 7# 8# Copyright 2000, 2010 Oracle and/or its affiliates. 9# 10# OpenOffice.org - a multi-platform office productivity suite 11# 12# This file is part of OpenOffice.org. 13# 14# OpenOffice.org is free software: you can redistribute it and/or modify 15# it under the terms of the GNU Lesser General Public License version 3 16# only, as published by the Free Software Foundation. 17# 18# OpenOffice.org is distributed in the hope that it will be useful, 19# but WITHOUT ANY WARRANTY; without even the implied warranty of 20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21# GNU Lesser General Public License version 3 for more details 22# (a copy is included in the LICENSE file that accompanied this code). 23# 24# You should have received a copy of the GNU Lesser General Public License 25# version 3 along with OpenOffice.org. If not, see 26# <http://www.openoffice.org/license.html> 27# for a copy of the LGPLv3 License. 28# 29#************************************************************************* 30 31# 32# deliver.pl - copy from module output tree to solver 33# 34 35my $progname = "testdefaultbootstrapping"; 36my $defExeExt; 37 38if ($ENV{GUI} eq "WNT") { 39 %services = ( 40 'com.sun.star.uno.NamingService' => 'namingservice.uno.dll', 41 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.dll', 42 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.dll', 43 ); 44 45 $defExeExt = ".exe"; 46 47} 48else { 49 %services = ( 50 'com.sun.star.uno.NamingService' => 'namingservice.uno.so', 51 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.so', 52 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.so' 53 ); 54 55 $defExeExt = ""; 56} 57 58sub extendProgName($) { 59 my $_extension = shift; 60 my $_result; 61 62 if ($ENV{GUI} eq "WNT") { 63 $_result = $progname . $_extension; 64 } 65 else { 66 $_result = $ENV{PWD} . "/" . $progname . $_extension; 67 } 68 69 return $_result; 70} 71 72 73sub rmDefRDB() { 74 unlink $progname . "_services.rdb"; 75} 76 77 78sub unregisterService($){ 79 my $service_name = shift; 80 81 my $rdb_name = $service_name . '.rdb'; 82 83 unlink $rdb_name; 84 85 return 1; 86} 87 88sub testForServices($$$) { 89 my $_services = shift; 90 my $_pars = shift; 91 my $_testexe = shift; 92 93 94# my $_rc = system 'echo', $_testexe, @{$_services}, $_pars; 95 my $_rc = system $_testexe, @{$_services}, $_pars; 96 97 return $_rc >> 8; 98} 99 100 101sub registerService($$){ 102 my $service_lib = shift; 103 my $rdb_name = shift; 104 105# system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib"; 106 my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib"; 107 108 109 return ! ( $rc >> 8 ); 110} 111 112 113 114my $state = 1; 115my @allservices; 116my $allservices_rdbs=""; 117my $rc; 118my $comment; 119my $testexe; 120 121 122sub registerServices() { 123 use Cwd; 124 125 # ensure that services can not be instantiated 126 foreach $service ( keys %services ) { 127 # ensure that the current service is not reachable 128 unregisterService($service); 129 $rc = !testForServices([$service], "", $testexe); 130 if(!$rc) { 131 $comment = $comment . "\tcouldn't unregister service " . $service . "\n"; 132 $state = 0; 133 } 134 135 136 # register the service and ensure that it is reachable 137 $rc = registerService($services{$service}, $service . '.rdb'); 138 if(!$rc) { 139 $comment = $comment . "\tcouldn't register service " . $service . "\n"; 140 $state = 0; 141 } 142 143 $rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe); 144 if(!$rc) { 145 $comment = $comment . "\tcouldn't reach service " . $service . "\n"; 146 $state = 0; 147 } 148 149 # memorize all services 150 if (length($allservices_rdbs)) { 151 $allservices_rdbs = $allservices_rdbs . " "; 152 } 153 $allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb"; 154 push @allservices, $service; 155 } 156} 157 158sub testIndirection() { 159 #test indirection 160 $rc = testForServices(['com.sun.star.uno.NamingService'], '-env:UNO_SERVICES=${testrc:Tests:TestKey1}', $testexe); 161 if (!$rc) { 162 $comment = $comment . "\tindirection test not passed\n"; 163 $state = 0; 164 } 165} 166 167 168sub testBeneathExe() { 169 my $service = 'com.sun.star.reflection.CoreReflection'; 170 my $_testexe; 171 172 my @_exes = (extendProgName(".exe"), 173 extendProgName(".Exe"), 174 extendProgName(".bin"), 175 extendProgName(".Bin")); 176 177 foreach $_testexe ( @_exes ) { 178 #test rdb found beneath executable 179 registerService($services{$service}, $progname . "_services.rdb"); 180 my $_rc = testForServices([$service], "", $_testexe); 181 if (!$_rc) { 182 $comment = $comment . "\tbeneath executable test not passed: " . $_testexe . "\n"; 183 $state = 0; 184 } 185 } 186} 187 188sub testBeneathLib_rdb() { 189 my $_service = 'com.sun.star.uno.NamingService'; 190 191 use UNO; 192 193 my $_rdb_name; 194 195 if ($ENV{GUI} eq "WNT") { 196 $_rdb_name = "UNO" . "_services.rdb"; 197 } 198 else { 199 $_rdb_name = "../lib/UNO" . "_services.rdb"; 200 } 201 202 registerService($services{$_service}, $_rdb_name); 203 my $_rc = UNO::tryService($_service); 204 if (!$_rc) { 205 $comment = $comment . "\tbeneath lib test not passed\n"; 206 $state = 0; 207 } 208 unlink $_rdb_name; 209} 210 211sub testBeneathLib_rc() { 212 my $_service = 'com.sun.star.uno.NamingService'; 213 214 use UNO; 215 216 my $_rc_name; 217 218 if ($ENV{GUI} eq "WNT") { 219 $_rc_name = "UNO.ini"; 220 } 221 else { 222 $_rc_name = "../lib/UNOrc"; 223 } 224 225 my $_rdb_name = "../lib/test.rdb"; 226 227 my $_handle; 228 open $_handle, ">" . $_rc_name; 229 print $_handle "UNO_SERVICES=" . $_rdb_name . "\n"; 230 close $_handle; 231 232 registerService($services{$_service}, $_rdb_name); 233 my $_rc = UNO::tryService($_service); 234 if (!$_rc) { 235 $comment = $comment . "\tbeneath lib rc test not passed\n"; 236 $state = 0; 237 } 238 unlink $_rdb_name; 239 unlink $_rc_name; 240} 241 242sub testAllAvailable() { 243 # test that all services are reachable through different rdbs 244 # change the directory to ensure, that all paths become expanded 245 chdir ".."; 246 247 $rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe); 248 if (!$rc) { 249 $comment = $comment . "\tmulti rdb test not passed\n"; 250 $state = 0; 251 } 252} 253 254$testexe = extendProgName($defExeExt); 255 256rmDefRDB(); 257registerServices(); 258#print "alls:", @allservices, $allservices_rdbs, "\n"; 259 260testIndirection(); 261testBeneathExe(); 262testBeneathLib_rc(); 263testBeneathLib_rdb(); 264testAllAvailable(); 265 266print "**************************\n"; 267if($state) { 268 print "****** tests passed ******\n"; 269} 270else { 271 print "**** tests NOT passed ****\n"; 272 print "Commnent:\n", $comment, "\n"; 273} 274print "**************************\n"; 275 276 277 278