merged tag LIBREOFFICE_3_2_99_3
[LibreOffice.git] / cppuhelper / test / testdefaultbootstrapping.pl
blobc1756e90852975cc7d33bfcd5a323ea029b1ccd5
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8 # Copyright 2000, 2010 Oracle and/or its affiliates.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # This file is part of OpenOffice.org.
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.
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).
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.
29 #*************************************************************************
32 # deliver.pl - copy from module output tree to solver
35 my $progname = "testdefaultbootstrapping";
36 my $defExeExt;
38 if ($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',
45 $defExeExt = ".exe";
48 else {
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'
55 $defExeExt = "";
58 sub extendProgName($) {
59 my $_extension = shift;
60 my $_result;
62 if ($ENV{GUI} eq "WNT") {
63 $_result = $progname . $_extension;
65 else {
66 $_result = $ENV{PWD} . "/" . $progname . $_extension;
69 return $_result;
73 sub rmDefRDB() {
74 unlink $progname . "_services.rdb";
78 sub unregisterService($){
79 my $service_name = shift;
81 my $rdb_name = $service_name . '.rdb';
83 unlink $rdb_name;
85 return 1;
88 sub testForServices($$$) {
89 my $_services = shift;
90 my $_pars = shift;
91 my $_testexe = shift;
94 # my $_rc = system 'echo', $_testexe, @{$_services}, $_pars;
95 my $_rc = system $_testexe, @{$_services}, $_pars;
97 return $_rc >> 8;
101 sub registerService($$){
102 my $service_lib = shift;
103 my $rdb_name = shift;
105 # system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib";
106 my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib";
109 return ! ( $rc >> 8 );
114 my $state = 1;
115 my @allservices;
116 my $allservices_rdbs="";
117 my $rc;
118 my $comment;
119 my $testexe;
122 sub registerServices() {
123 use Cwd;
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;
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;
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;
149 # memorize all services
150 if (length($allservices_rdbs)) {
151 $allservices_rdbs = $allservices_rdbs . " ";
153 $allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb";
154 push @allservices, $service;
158 sub 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;
168 sub testBeneathExe() {
169 my $service = 'com.sun.star.reflection.CoreReflection';
170 my $_testexe;
172 my @_exes = (extendProgName(".exe"),
173 extendProgName(".Exe"),
174 extendProgName(".bin"),
175 extendProgName(".Bin"));
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;
188 sub testBeneathLib_rdb() {
189 my $_service = 'com.sun.star.uno.NamingService';
191 use UNO;
193 my $_rdb_name;
195 if ($ENV{GUI} eq "WNT") {
196 $_rdb_name = "UNO" . "_services.rdb";
198 else {
199 $_rdb_name = "../lib/UNO" . "_services.rdb";
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;
208 unlink $_rdb_name;
211 sub testBeneathLib_rc() {
212 my $_service = 'com.sun.star.uno.NamingService';
214 use UNO;
216 my $_rc_name;
218 if ($ENV{GUI} eq "WNT") {
219 $_rc_name = "UNO.ini";
221 else {
222 $_rc_name = "../lib/UNOrc";
225 my $_rdb_name = "../lib/test.rdb";
227 my $_handle;
228 open $_handle, ">" . $_rc_name;
229 print $_handle "UNO_SERVICES=" . $_rdb_name . "\n";
230 close $_handle;
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;
238 unlink $_rdb_name;
239 unlink $_rc_name;
242 sub testAllAvailable() {
243 # test that all services are reachable through different rdbs
244 # change the directory to ensure, that all paths become expanded
245 chdir "..";
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;
254 $testexe = extendProgName($defExeExt);
256 rmDefRDB();
257 registerServices();
258 #print "alls:", @allservices, $allservices_rdbs, "\n";
260 testIndirection();
261 testBeneathExe();
262 testBeneathLib_rc();
263 testBeneathLib_rdb();
264 testAllAvailable();
266 print "**************************\n";
267 if($state) {
268 print "****** tests passed ******\n";
270 else {
271 print "**** tests NOT passed ****\n";
272 print "Commnent:\n", $comment, "\n";
274 print "**************************\n";