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