1cdf0e10cSrcweir: 2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}' 3cdf0e10cSrcweir if 0; 4*7e90fac2SAndrew Rist#************************************************************** 5*7e90fac2SAndrew Rist# 6*7e90fac2SAndrew Rist# Licensed to the Apache Software Foundation (ASF) under one 7*7e90fac2SAndrew Rist# or more contributor license agreements. See the NOTICE file 8*7e90fac2SAndrew Rist# distributed with this work for additional information 9*7e90fac2SAndrew Rist# regarding copyright ownership. The ASF licenses this file 10*7e90fac2SAndrew Rist# to you under the Apache License, Version 2.0 (the 11*7e90fac2SAndrew Rist# "License"); you may not use this file except in compliance 12*7e90fac2SAndrew Rist# with the License. You may obtain a copy of the License at 13*7e90fac2SAndrew Rist# 14*7e90fac2SAndrew Rist# http://www.apache.org/licenses/LICENSE-2.0 15*7e90fac2SAndrew Rist# 16*7e90fac2SAndrew Rist# Unless required by applicable law or agreed to in writing, 17*7e90fac2SAndrew Rist# software distributed under the License is distributed on an 18*7e90fac2SAndrew Rist# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19*7e90fac2SAndrew Rist# KIND, either express or implied. See the License for the 20*7e90fac2SAndrew Rist# specific language governing permissions and limitations 21*7e90fac2SAndrew Rist# under the License. 22*7e90fac2SAndrew Rist# 23*7e90fac2SAndrew Rist#************************************************************** 24*7e90fac2SAndrew Rist 25*7e90fac2SAndrew Rist 26cdf0e10cSrcweir 27cdf0e10cSrcweir# 28cdf0e10cSrcweir# deliver.pl - copy from module output tree to solver 29cdf0e10cSrcweir# 30cdf0e10cSrcweir 31cdf0e10cSrcweirmy $progname = "testdefaultbootstrapping"; 32cdf0e10cSrcweirmy $defExeExt; 33cdf0e10cSrcweir 34cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") { 35cdf0e10cSrcweir %services = ( 36cdf0e10cSrcweir 'com.sun.star.uno.NamingService' => 'namingservice.uno.dll', 37cdf0e10cSrcweir 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.dll', 38cdf0e10cSrcweir 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.dll', 39cdf0e10cSrcweir ); 40cdf0e10cSrcweir 41cdf0e10cSrcweir $defExeExt = ".exe"; 42cdf0e10cSrcweir 43cdf0e10cSrcweir} 44cdf0e10cSrcweirelse { 45cdf0e10cSrcweir %services = ( 46cdf0e10cSrcweir 'com.sun.star.uno.NamingService' => 'namingservice.uno.so', 47cdf0e10cSrcweir 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.so', 48cdf0e10cSrcweir 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.so' 49cdf0e10cSrcweir ); 50cdf0e10cSrcweir 51cdf0e10cSrcweir $defExeExt = ""; 52cdf0e10cSrcweir} 53cdf0e10cSrcweir 54cdf0e10cSrcweirsub extendProgName($) { 55cdf0e10cSrcweir my $_extension = shift; 56cdf0e10cSrcweir my $_result; 57cdf0e10cSrcweir 58cdf0e10cSrcweir if ($ENV{GUI} eq "WNT") { 59cdf0e10cSrcweir $_result = $progname . $_extension; 60cdf0e10cSrcweir } 61cdf0e10cSrcweir else { 62cdf0e10cSrcweir $_result = $ENV{PWD} . "/" . $progname . $_extension; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir return $_result; 66cdf0e10cSrcweir} 67cdf0e10cSrcweir 68cdf0e10cSrcweir 69cdf0e10cSrcweirsub rmDefRDB() { 70cdf0e10cSrcweir unlink $progname . "_services.rdb"; 71cdf0e10cSrcweir} 72cdf0e10cSrcweir 73cdf0e10cSrcweir 74cdf0e10cSrcweirsub unregisterService($){ 75cdf0e10cSrcweir my $service_name = shift; 76cdf0e10cSrcweir 77cdf0e10cSrcweir my $rdb_name = $service_name . '.rdb'; 78cdf0e10cSrcweir 79cdf0e10cSrcweir unlink $rdb_name; 80cdf0e10cSrcweir 81cdf0e10cSrcweir return 1; 82cdf0e10cSrcweir} 83cdf0e10cSrcweir 84cdf0e10cSrcweirsub testForServices($$$) { 85cdf0e10cSrcweir my $_services = shift; 86cdf0e10cSrcweir my $_pars = shift; 87cdf0e10cSrcweir my $_testexe = shift; 88cdf0e10cSrcweir 89cdf0e10cSrcweir 90cdf0e10cSrcweir# my $_rc = system 'echo', $_testexe, @{$_services}, $_pars; 91cdf0e10cSrcweir my $_rc = system $_testexe, @{$_services}, $_pars; 92cdf0e10cSrcweir 93cdf0e10cSrcweir return $_rc >> 8; 94cdf0e10cSrcweir} 95cdf0e10cSrcweir 96cdf0e10cSrcweir 97cdf0e10cSrcweirsub registerService($$){ 98cdf0e10cSrcweir my $service_lib = shift; 99cdf0e10cSrcweir my $rdb_name = shift; 100cdf0e10cSrcweir 101cdf0e10cSrcweir# system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib"; 102cdf0e10cSrcweir my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib"; 103cdf0e10cSrcweir 104cdf0e10cSrcweir 105cdf0e10cSrcweir return ! ( $rc >> 8 ); 106cdf0e10cSrcweir} 107cdf0e10cSrcweir 108cdf0e10cSrcweir 109cdf0e10cSrcweir 110cdf0e10cSrcweirmy $state = 1; 111cdf0e10cSrcweirmy @allservices; 112cdf0e10cSrcweirmy $allservices_rdbs=""; 113cdf0e10cSrcweirmy $rc; 114cdf0e10cSrcweirmy $comment; 115cdf0e10cSrcweirmy $testexe; 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweirsub registerServices() { 119cdf0e10cSrcweir use Cwd; 120cdf0e10cSrcweir 121cdf0e10cSrcweir # ensure that services can not be instantiated 122cdf0e10cSrcweir foreach $service ( keys %services ) { 123cdf0e10cSrcweir # ensure that the current service is not reachable 124cdf0e10cSrcweir unregisterService($service); 125cdf0e10cSrcweir $rc = !testForServices([$service], "", $testexe); 126cdf0e10cSrcweir if(!$rc) { 127cdf0e10cSrcweir $comment = $comment . "\tcouldn't unregister service " . $service . "\n"; 128cdf0e10cSrcweir $state = 0; 129cdf0e10cSrcweir } 130cdf0e10cSrcweir 131cdf0e10cSrcweir 132cdf0e10cSrcweir # register the service and ensure that it is reachable 133cdf0e10cSrcweir $rc = registerService($services{$service}, $service . '.rdb'); 134cdf0e10cSrcweir if(!$rc) { 135cdf0e10cSrcweir $comment = $comment . "\tcouldn't register service " . $service . "\n"; 136cdf0e10cSrcweir $state = 0; 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir $rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe); 140cdf0e10cSrcweir if(!$rc) { 141cdf0e10cSrcweir $comment = $comment . "\tcouldn't reach service " . $service . "\n"; 142cdf0e10cSrcweir $state = 0; 143cdf0e10cSrcweir } 144cdf0e10cSrcweir 145cdf0e10cSrcweir # memorize all services 146cdf0e10cSrcweir if (length($allservices_rdbs)) { 147cdf0e10cSrcweir $allservices_rdbs = $allservices_rdbs . " "; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir $allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb"; 150cdf0e10cSrcweir push @allservices, $service; 151cdf0e10cSrcweir } 152cdf0e10cSrcweir} 153cdf0e10cSrcweir 154cdf0e10cSrcweirsub testIndirection() { 155cdf0e10cSrcweir #test indirection 156cdf0e10cSrcweir $rc = testForServices(['com.sun.star.uno.NamingService'], '-env:UNO_SERVICES=${testrc:Tests:TestKey1}', $testexe); 157cdf0e10cSrcweir if (!$rc) { 158cdf0e10cSrcweir $comment = $comment . "\tindirection test not passed\n"; 159cdf0e10cSrcweir $state = 0; 160cdf0e10cSrcweir } 161cdf0e10cSrcweir} 162cdf0e10cSrcweir 163cdf0e10cSrcweir 164cdf0e10cSrcweirsub testBeneathExe() { 165cdf0e10cSrcweir my $service = 'com.sun.star.reflection.CoreReflection'; 166cdf0e10cSrcweir my $_testexe; 167cdf0e10cSrcweir 168cdf0e10cSrcweir my @_exes = (extendProgName(".exe"), 169cdf0e10cSrcweir extendProgName(".Exe"), 170cdf0e10cSrcweir extendProgName(".bin"), 171cdf0e10cSrcweir extendProgName(".Bin")); 172cdf0e10cSrcweir 173cdf0e10cSrcweir foreach $_testexe ( @_exes ) { 174cdf0e10cSrcweir #test rdb found beneath executable 175cdf0e10cSrcweir registerService($services{$service}, $progname . "_services.rdb"); 176cdf0e10cSrcweir my $_rc = testForServices([$service], "", $_testexe); 177cdf0e10cSrcweir if (!$_rc) { 178cdf0e10cSrcweir $comment = $comment . "\tbeneath executable test not passed: " . $_testexe . "\n"; 179cdf0e10cSrcweir $state = 0; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir } 182cdf0e10cSrcweir} 183cdf0e10cSrcweir 184cdf0e10cSrcweirsub testBeneathLib_rdb() { 185cdf0e10cSrcweir my $_service = 'com.sun.star.uno.NamingService'; 186cdf0e10cSrcweir 187cdf0e10cSrcweir use UNO; 188cdf0e10cSrcweir 189cdf0e10cSrcweir my $_rdb_name; 190cdf0e10cSrcweir 191cdf0e10cSrcweir if ($ENV{GUI} eq "WNT") { 192cdf0e10cSrcweir $_rdb_name = "UNO" . "_services.rdb"; 193cdf0e10cSrcweir } 194cdf0e10cSrcweir else { 195cdf0e10cSrcweir $_rdb_name = "../lib/UNO" . "_services.rdb"; 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir registerService($services{$_service}, $_rdb_name); 199cdf0e10cSrcweir my $_rc = UNO::tryService($_service); 200cdf0e10cSrcweir if (!$_rc) { 201cdf0e10cSrcweir $comment = $comment . "\tbeneath lib test not passed\n"; 202cdf0e10cSrcweir $state = 0; 203cdf0e10cSrcweir } 204cdf0e10cSrcweir unlink $_rdb_name; 205cdf0e10cSrcweir} 206cdf0e10cSrcweir 207cdf0e10cSrcweirsub testBeneathLib_rc() { 208cdf0e10cSrcweir my $_service = 'com.sun.star.uno.NamingService'; 209cdf0e10cSrcweir 210cdf0e10cSrcweir use UNO; 211cdf0e10cSrcweir 212cdf0e10cSrcweir my $_rc_name; 213cdf0e10cSrcweir 214cdf0e10cSrcweir if ($ENV{GUI} eq "WNT") { 215cdf0e10cSrcweir $_rc_name = "UNO.ini"; 216cdf0e10cSrcweir } 217cdf0e10cSrcweir else { 218cdf0e10cSrcweir $_rc_name = "../lib/UNOrc"; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir 221cdf0e10cSrcweir my $_rdb_name = "../lib/test.rdb"; 222cdf0e10cSrcweir 223cdf0e10cSrcweir my $_handle; 224cdf0e10cSrcweir open $_handle, ">" . $_rc_name; 225cdf0e10cSrcweir print $_handle "UNO_SERVICES=" . $_rdb_name . "\n"; 226cdf0e10cSrcweir close $_handle; 227cdf0e10cSrcweir 228cdf0e10cSrcweir registerService($services{$_service}, $_rdb_name); 229cdf0e10cSrcweir my $_rc = UNO::tryService($_service); 230cdf0e10cSrcweir if (!$_rc) { 231cdf0e10cSrcweir $comment = $comment . "\tbeneath lib rc test not passed\n"; 232cdf0e10cSrcweir $state = 0; 233cdf0e10cSrcweir } 234cdf0e10cSrcweir unlink $_rdb_name; 235cdf0e10cSrcweir unlink $_rc_name; 236cdf0e10cSrcweir} 237cdf0e10cSrcweir 238cdf0e10cSrcweirsub testAllAvailable() { 239cdf0e10cSrcweir # test that all services are reachable through different rdbs 240cdf0e10cSrcweir # change the directory to ensure, that all paths become expanded 241cdf0e10cSrcweir chdir ".."; 242cdf0e10cSrcweir 243cdf0e10cSrcweir $rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe); 244cdf0e10cSrcweir if (!$rc) { 245cdf0e10cSrcweir $comment = $comment . "\tmulti rdb test not passed\n"; 246cdf0e10cSrcweir $state = 0; 247cdf0e10cSrcweir } 248cdf0e10cSrcweir} 249cdf0e10cSrcweir 250cdf0e10cSrcweir$testexe = extendProgName($defExeExt); 251cdf0e10cSrcweir 252cdf0e10cSrcweirrmDefRDB(); 253cdf0e10cSrcweirregisterServices(); 254cdf0e10cSrcweir#print "alls:", @allservices, $allservices_rdbs, "\n"; 255cdf0e10cSrcweir 256cdf0e10cSrcweirtestIndirection(); 257cdf0e10cSrcweirtestBeneathExe(); 258cdf0e10cSrcweirtestBeneathLib_rc(); 259cdf0e10cSrcweirtestBeneathLib_rdb(); 260cdf0e10cSrcweirtestAllAvailable(); 261cdf0e10cSrcweir 262cdf0e10cSrcweirprint "**************************\n"; 263cdf0e10cSrcweirif($state) { 264cdf0e10cSrcweir print "****** tests passed ******\n"; 265cdf0e10cSrcweir} 266cdf0e10cSrcweirelse { 267cdf0e10cSrcweir print "**** tests NOT passed ****\n"; 268cdf0e10cSrcweir print "Commnent:\n", $comment, "\n"; 269cdf0e10cSrcweir} 270cdf0e10cSrcweirprint "**************************\n"; 271cdf0e10cSrcweir 272cdf0e10cSrcweir 273cdf0e10cSrcweir 274