update dev300-m57
[ooovba.git] / cppuhelper / test / testdefaultbootstrapping.pl
blobb90943784285aaf098a44bab30653b31e22f8c88
2 eval 'exec perl -wS $0 ${1+"$@"}'
3 if 0;
4 #*************************************************************************
6 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 #
8 # Copyright 2008 by Sun Microsystems, Inc.
10 # OpenOffice.org - a multi-platform office productivity suite
12 # $RCSfile: testdefaultbootstrapping.pl,v $
14 # $Revision: 1.7 $
16 # This file is part of OpenOffice.org.
18 # OpenOffice.org is free software: you can redistribute it and/or modify
19 # it under the terms of the GNU Lesser General Public License version 3
20 # only, as published by the Free Software Foundation.
22 # OpenOffice.org is distributed in the hope that it will be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 # GNU Lesser General Public License version 3 for more details
26 # (a copy is included in the LICENSE file that accompanied this code).
28 # You should have received a copy of the GNU Lesser General Public License
29 # version 3 along with OpenOffice.org. If not, see
30 # <http://www.openoffice.org/license.html>
31 # for a copy of the LGPLv3 License.
33 #*************************************************************************
36 # deliver.pl - copy from module output tree to solver
39 my $progname = "testdefaultbootstrapping";
40 my $defExeExt;
42 if ($ENV{GUI} eq "WNT") {
43 %services = (
44 'com.sun.star.uno.NamingService' => 'namingservice.uno.dll',
45 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.dll',
46 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.dll',
49 $defExeExt = ".exe";
52 else {
53 %services = (
54 'com.sun.star.uno.NamingService' => 'namingservice.uno.so',
55 'com.sun.star.reflection.CoreReflection' => 'reflection.uno.so',
56 'com.sun.star.script.InvocationAdapterFactory' => 'invocadapt.uno.so'
59 $defExeExt = "";
62 sub extendProgName($) {
63 my $_extension = shift;
64 my $_result;
66 if ($ENV{GUI} eq "WNT") {
67 $_result = $progname . $_extension;
69 else {
70 $_result = $ENV{PWD} . "/" . $progname . $_extension;
73 return $_result;
77 sub rmDefRDB() {
78 unlink $progname . "_services.rdb";
82 sub unregisterService($){
83 my $service_name = shift;
85 my $rdb_name = $service_name . '.rdb';
87 unlink $rdb_name;
89 return 1;
92 sub testForServices($$$) {
93 my $_services = shift;
94 my $_pars = shift;
95 my $_testexe = shift;
98 # my $_rc = system 'echo', $_testexe, @{$_services}, $_pars;
99 my $_rc = system $_testexe, @{$_services}, $_pars;
101 return $_rc >> 8;
105 sub registerService($$){
106 my $service_lib = shift;
107 my $rdb_name = shift;
109 # system 'echo', "regcomp -register -r " . $rdb_name . " -c $service_lib";
110 my $rc = system "regcomp -register -r " . $rdb_name . " -c $service_lib";
113 return ! ( $rc >> 8 );
118 my $state = 1;
119 my @allservices;
120 my $allservices_rdbs="";
121 my $rc;
122 my $comment;
123 my $testexe;
126 sub registerServices() {
127 use Cwd;
129 # ensure that services can not be instantiated
130 foreach $service ( keys %services ) {
131 # ensure that the current service is not reachable
132 unregisterService($service);
133 $rc = !testForServices([$service], "", $testexe);
134 if(!$rc) {
135 $comment = $comment . "\tcouldn't unregister service " . $service . "\n";
136 $state = 0;
140 # register the service and ensure that it is reachable
141 $rc = registerService($services{$service}, $service . '.rdb');
142 if(!$rc) {
143 $comment = $comment . "\tcouldn't register service " . $service . "\n";
144 $state = 0;
147 $rc = testForServices([$service], "-env:UNO_SERVICES=" . $service . ".rdb", $testexe);
148 if(!$rc) {
149 $comment = $comment . "\tcouldn't reach service " . $service . "\n";
150 $state = 0;
153 # memorize all services
154 if (length($allservices_rdbs)) {
155 $allservices_rdbs = $allservices_rdbs . " ";
157 $allservices_rdbs = $allservices_rdbs . "file://" . getcwd() . "/" . $service . ".rdb";
158 push @allservices, $service;
162 sub testIndirection() {
163 #test indirection
164 $rc = testForServices(['com.sun.star.uno.NamingService'], '-env:UNO_SERVICES=${testrc:Tests:TestKey1}', $testexe);
165 if (!$rc) {
166 $comment = $comment . "\tindirection test not passed\n";
167 $state = 0;
172 sub testBeneathExe() {
173 my $service = 'com.sun.star.reflection.CoreReflection';
174 my $_testexe;
176 my @_exes = (extendProgName(".exe"),
177 extendProgName(".Exe"),
178 extendProgName(".bin"),
179 extendProgName(".Bin"));
181 foreach $_testexe ( @_exes ) {
182 #test rdb found beneath executable
183 registerService($services{$service}, $progname . "_services.rdb");
184 my $_rc = testForServices([$service], "", $_testexe);
185 if (!$_rc) {
186 $comment = $comment . "\tbeneath executable test not passed: " . $_testexe . "\n";
187 $state = 0;
192 sub testBeneathLib_rdb() {
193 my $_service = 'com.sun.star.uno.NamingService';
195 use UNO;
197 my $_rdb_name;
199 if ($ENV{GUI} eq "WNT") {
200 $_rdb_name = "UNO" . "_services.rdb";
202 else {
203 $_rdb_name = "../lib/UNO" . "_services.rdb";
206 registerService($services{$_service}, $_rdb_name);
207 my $_rc = UNO::tryService($_service);
208 if (!$_rc) {
209 $comment = $comment . "\tbeneath lib test not passed\n";
210 $state = 0;
212 unlink $_rdb_name;
215 sub testBeneathLib_rc() {
216 my $_service = 'com.sun.star.uno.NamingService';
218 use UNO;
220 my $_rc_name;
222 if ($ENV{GUI} eq "WNT") {
223 $_rc_name = "UNO.ini";
225 else {
226 $_rc_name = "../lib/UNOrc";
229 my $_rdb_name = "../lib/test.rdb";
231 my $_handle;
232 open $_handle, ">" . $_rc_name;
233 print $_handle "UNO_SERVICES=" . $_rdb_name . "\n";
234 close $_handle;
236 registerService($services{$_service}, $_rdb_name);
237 my $_rc = UNO::tryService($_service);
238 if (!$_rc) {
239 $comment = $comment . "\tbeneath lib rc test not passed\n";
240 $state = 0;
242 unlink $_rdb_name;
243 unlink $_rc_name;
246 sub testAllAvailable() {
247 # test that all services are reachable through different rdbs
248 # change the directory to ensure, that all paths become expanded
249 chdir "..";
251 $rc = testForServices(\@allservices, "-env:UNO_SERVICES=" . $allservices_rdbs, $testexe);
252 if (!$rc) {
253 $comment = $comment . "\tmulti rdb test not passed\n";
254 $state = 0;
258 $testexe = extendProgName($defExeExt);
260 rmDefRDB();
261 registerServices();
262 #print "alls:", @allservices, $allservices_rdbs, "\n";
264 testIndirection();
265 testBeneathExe();
266 testBeneathLib_rc();
267 testBeneathLib_rdb();
268 testAllAvailable();
270 print "**************************\n";
271 if($state) {
272 print "****** tests passed ******\n";
274 else {
275 print "**** tests NOT passed ****\n";
276 print "Commnent:\n", $comment, "\n";
278 print "**************************\n";