xref: /aoo4110/main/sal/test/bootstrap.pl (revision b1cdbd2c)
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
28my $rc;
29my $state = 1;
30my $comment = "";
31
32$ENV{MYBOOTSTRAPTESTVALUE}=0;
33
34$rc = system "./testbootstrap", 1, "-env:MYBOOTSTRAPTESTVALUE=1";
35if (!$rc) {
36	$comment = $comment . "commandline over environment test not passed\n";
37	$state = 0;
38}
39
40$rc = system "./testbootstrap", "0", "-env:INIFILENAME=";
41if (!$rc) {
42	$comment = $comment . "exe custom ini test not passed\n";
43	$state = 0;
44}
45
46delete $ENV{MYBOOTSTRAPTESTVALUE};
47
48$rc = system "./testbootstrap.bin", "file";
49if (!$rc) {
50	$comment = $comment . "extensions cut test not passed with .bin\n";
51	$state = 0;
52}
53
54$rc = system "./testbootstrap.Bin", "file";
55if (!$rc) {
56	$comment = $comment . "extensions cut test not passed with .Bin\n";
57	$state = 0;
58}
59
60$rc = system "./testbootstrap.exe", "file";
61if (!$rc) {
62	$comment = $comment . "extensions cut test not passed with .exe\n";
63	$state = 0;
64}
65
66$rc = system "./testbootstrap.Exe", "file";
67if (!$rc) {
68	$comment = $comment . "extensions cut test not passed with .Exe\n";
69	$state = 0;
70}
71
72if ($ENV{GUI} eq "WNT") {
73	$rc = system "./testbootstrap", "auxaux", "-env:iniName=ini.ini", '-env:MYBOOTSTRAPTESTVALUE=$CUSTOMINIVALUE';
74}
75else {
76	$rc = system "./testbootstrap", "auxaux", "-env:iniName=inirc", '-env:MYBOOTSTRAPTESTVALUE=$CUSTOMINIVALUE';
77}
78if (!$rc) {
79	$comment = $comment . "custom ini test not passed\n";
80	$state = 0;
81}
82
83if ($ENV{GUI} eq "WNT") {
84	$comment = $comment . '$SYSUSERHOME not testable under windows' . "\n";
85}
86else {
87	$rc = system "./testbootstrap", "file://$ENV{HOME}", '-env:MYBOOTSTRAPTESTVALUE=$SYSUSERHOME';
88	if (!$rc) {
89		$comment = $comment . '$SYSUSERHOME test not passed' . "\n";
90		$state = 0;
91	}
92}
93
94if ($ENV{GUI} eq "WNT") {
95	$comment = $comment . '$SYSUSERCONFIG' . " not testable under windows\n";
96}
97else {
98	$rc = system "./testbootstrap", "file://$ENV{HOME}", '-env:MYBOOTSTRAPTESTVALUE=$SYSUSERCONFIG';
99	if (!$rc) {
100		$comment = $comment . '$SYSUSERCONFIG test not passed' . "\n";
101		$state = 0;
102	}
103}
104
105if ($ENV{GUI} eq "WNT") {
106	$comment = $comment . '$SYSBINDIR' . " not testable under windows\n";
107}
108else {
109	$rc = system "./testbootstrap", "file://$ENV{PWD}", '-env:MYBOOTSTRAPTESTVALUE=$SYSBINDIR';
110	if (!$rc) {
111		$comment = $comment . '$SYSBINDIR test not passed' . "\n";
112		$state = 0;
113	}
114}
115
116if ($ENV{GUI} eq "WNT") {
117	$rc = system "./testbootstrap", "inherited_value", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_VALUE', "-env:iniName=ini.ini";
118}
119else {
120	$rc = system "./testbootstrap", "inherited_value", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_VALUE', "-env:iniName=inirc";
121}
122if (!$rc) {
123	$comment = $comment . "inherited value not passed\n";
124	$state = 0;
125}
126
127if ($ENV{GUI} eq "WNT") {
128	$rc = system "./testbootstrap", "not_overwritten", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_OVERWRITTEN_VALUE', "-env:iniName=ini.ini";
129}
130else {
131	$rc = system "./testbootstrap", "not_overwritten", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_OVERWRITTEN_VALUE', "-env:iniName=inirc";
132}
133if (!$rc) {
134	$comment = $comment . "inherited overwritten value not passed\n";
135	$state = 0;
136}
137
138
139$rc = system "./testbootstrap", "defaultvalue", "-env:INIFILENAME=", "-env:Default=defaultvalue", "-env:USEDEFAULT=1";
140if (!$rc) {
141	$comment = $comment . "default test from parameter not passed\n";
142	$state = 0;
143}
144
145if ($ENV{GUI} eq "WNT") {
146	$rc = system "./testbootstrap",  "defaultValue", "-env:iniName=default.ini", "-env:INIFILENAME=", "-env:USEDEFAULT=1";
147}
148else {
149	$rc = system "./testbootstrap",  "defaultValue", "-env:iniName=defaultrc", "-env:INIFILENAME=", "-env:USEDEFAULT=1";
150}
151if (!$rc) {
152	$comment = $comment . "default test from custom ini not passed\n";
153	$state = 0;
154}
155
156# simple macro expansion
157$rc = system "./testbootstrap",
158	"_first_second_third_",
159	"-env:FIRST=first",
160	"-env:SECOND=second",
161	"-env:THIRD=third",
162	'-env:MYBOOTSTRAPTESTVALUE=_${FIRST}_${SECOND}_${THIRD}_';
163if (!$rc) {
164	$comment = $comment . "simple macro expansion test not passed\n";
165	$state = 0;
166}
167
168# simple quoting
169$rc = system "./testbootstrap",
170	'_${FIRST}_${SECOND}_${THIRD}_',
171	"-env:FIRST=first",
172	"-env:SECOND=second",
173	"-env:THIRD=third",
174	'-env:MYBOOTSTRAPTESTVALUE=_\$\{FIRST\}_\$\{SECOND\}_\$\{THIRD\}_';
175if (!$rc) {
176	$comment = $comment . "simple macro quoting test not passed\n";
177	$state = 0;
178}
179
180# simple ini access
181$rc = system "./testbootstrap",
182	"TheIniKeysValue",
183	'-env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheIniKey}';
184if (!$rc) {
185	$comment = $comment . "simple macro ini access test not passed\n";
186	$state = 0;
187}
188
189# simple profile access
190$rc = system "./testbootstrap",
191	"TheKeysValue",
192	'-env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheSection:TheKey}';
193if (!$rc) {
194	$comment = $comment . "simple macro profile access test not passed\n";
195	$state = 0;
196}
197
198# profile access with simple macro expansion
199$rc = system "./testbootstrap",
200	"TheKeysValue",
201	"-env:ININAME=./bootstraptest.ini",
202	"-env:SECTIONNAME=TheSection",
203	"-env:KEYNAME=TheKey",
204	'-env:MYBOOTSTRAPTESTVALUE=${$ININAME:$SECTIONNAME:$KEYNAME}';
205if (!$rc) {
206	$comment = $comment . "profile access with simple macro expansion test not passed\n";
207	$state = 0;
208}
209
210# profile access with complex macro expansion
211$rc = system "./testbootstrap",
212	"TheKeysValue",
213	"-env:ININAME=./bootstraptest.ini",
214	'-env:MYBOOTSTRAPTESTVALUE=${$ININAME:${$ININAME:SecondSection:IndirectSection}:${$ININAME:SecondSection:IndirectKey}}';
215if (!$rc) {
216	$comment = $comment . "profile access with complex macro expansion test not passed\n";
217	$state = 0;
218}
219
220# test no infinit recursion
221if ($ENV{GUI} eq "WNT") {
222	$rc = system "./testbootstrap",
223	'"***RECURSION DETECTED***"',
224	'-env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE';
225}
226else {
227	$rc = system "./testbootstrap",
228	'***RECURSION DETECTED***',
229	'-env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE';
230}
231if (!$rc) {
232	$comment = $comment . "no infinit recursion test not passed\n";
233	$state = 0;
234}
235
236# test unicode
237$rc = system "./testbootstrap",
238	"AAABBBCCC000",
239	'-env:MYBOOTSTRAPTESTVALUE=\u0041\u0041\u0041\u0042\u0042\u0042\u0043\u0043\u0043\u0030\u0030\u0030';
240if (!$rc) {
241	$comment = $comment . "uncode not passed\n";
242	$state = 0;
243}
244
245print "**************************\n";
246if($state) {
247	print "****** tests passed ******\n";
248}
249else {
250	print "**** tests NOT passed ****\n";
251	print "Commnent:\n", $comment, "\n";
252}
253print "**************************\n";
254
255
256
257