xref: /trunk/main/sal/test/bootstrap.pl (revision 86e1cf34)
1cdf0e10cSrcweir:
2cdf0e10cSrcweireval 'exec perl -wS $0 ${1+"$@"}'
3cdf0e10cSrcweir    if 0;
47e90fac2SAndrew Rist#**************************************************************
57e90fac2SAndrew Rist#
67e90fac2SAndrew Rist#  Licensed to the Apache Software Foundation (ASF) under one
77e90fac2SAndrew Rist#  or more contributor license agreements.  See the NOTICE file
87e90fac2SAndrew Rist#  distributed with this work for additional information
97e90fac2SAndrew Rist#  regarding copyright ownership.  The ASF licenses this file
107e90fac2SAndrew Rist#  to you under the Apache License, Version 2.0 (the
117e90fac2SAndrew Rist#  "License"); you may not use this file except in compliance
127e90fac2SAndrew Rist#  with the License.  You may obtain a copy of the License at
137e90fac2SAndrew Rist#
147e90fac2SAndrew Rist#    http://www.apache.org/licenses/LICENSE-2.0
157e90fac2SAndrew Rist#
167e90fac2SAndrew Rist#  Unless required by applicable law or agreed to in writing,
177e90fac2SAndrew Rist#  software distributed under the License is distributed on an
187e90fac2SAndrew Rist#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
197e90fac2SAndrew Rist#  KIND, either express or implied.  See the License for the
207e90fac2SAndrew Rist#  specific language governing permissions and limitations
217e90fac2SAndrew Rist#  under the License.
227e90fac2SAndrew Rist#
237e90fac2SAndrew Rist#**************************************************************
247e90fac2SAndrew Rist
257e90fac2SAndrew Rist
26cdf0e10cSrcweir
27cdf0e10cSrcweir
28cdf0e10cSrcweirmy $rc;
29cdf0e10cSrcweirmy $state = 1;
30cdf0e10cSrcweirmy $comment = "";
31cdf0e10cSrcweir
32cdf0e10cSrcweir$ENV{MYBOOTSTRAPTESTVALUE}=0;
33cdf0e10cSrcweir
34cdf0e10cSrcweir$rc = system "./testbootstrap", 1, "-env:MYBOOTSTRAPTESTVALUE=1";
35cdf0e10cSrcweirif (!$rc) {
36cdf0e10cSrcweir	$comment = $comment . "commandline over environment test not passed\n";
37cdf0e10cSrcweir	$state = 0;
38cdf0e10cSrcweir}
39cdf0e10cSrcweir
40cdf0e10cSrcweir$rc = system "./testbootstrap", "0", "-env:INIFILENAME=";
41cdf0e10cSrcweirif (!$rc) {
42cdf0e10cSrcweir	$comment = $comment . "exe custom ini test not passed\n";
43cdf0e10cSrcweir	$state = 0;
44cdf0e10cSrcweir}
45cdf0e10cSrcweir
46cdf0e10cSrcweirdelete $ENV{MYBOOTSTRAPTESTVALUE};
47cdf0e10cSrcweir
48cdf0e10cSrcweir$rc = system "./testbootstrap.bin", "file";
49cdf0e10cSrcweirif (!$rc) {
50cdf0e10cSrcweir	$comment = $comment . "extensions cut test not passed with .bin\n";
51cdf0e10cSrcweir	$state = 0;
52cdf0e10cSrcweir}
53cdf0e10cSrcweir
54cdf0e10cSrcweir$rc = system "./testbootstrap.Bin", "file";
55cdf0e10cSrcweirif (!$rc) {
56cdf0e10cSrcweir	$comment = $comment . "extensions cut test not passed with .Bin\n";
57cdf0e10cSrcweir	$state = 0;
58cdf0e10cSrcweir}
59cdf0e10cSrcweir
60cdf0e10cSrcweir$rc = system "./testbootstrap.exe", "file";
61cdf0e10cSrcweirif (!$rc) {
62cdf0e10cSrcweir	$comment = $comment . "extensions cut test not passed with .exe\n";
63cdf0e10cSrcweir	$state = 0;
64cdf0e10cSrcweir}
65cdf0e10cSrcweir
66cdf0e10cSrcweir$rc = system "./testbootstrap.Exe", "file";
67cdf0e10cSrcweirif (!$rc) {
68cdf0e10cSrcweir	$comment = $comment . "extensions cut test not passed with .Exe\n";
69cdf0e10cSrcweir	$state = 0;
70cdf0e10cSrcweir}
71cdf0e10cSrcweir
72cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
73cdf0e10cSrcweir	$rc = system "./testbootstrap", "auxaux", "-env:iniName=ini.ini", '-env:MYBOOTSTRAPTESTVALUE=$CUSTOMINIVALUE';
74cdf0e10cSrcweir}
75cdf0e10cSrcweirelse {
76cdf0e10cSrcweir	$rc = system "./testbootstrap", "auxaux", "-env:iniName=inirc", '-env:MYBOOTSTRAPTESTVALUE=$CUSTOMINIVALUE';
77cdf0e10cSrcweir}
78cdf0e10cSrcweirif (!$rc) {
79cdf0e10cSrcweir	$comment = $comment . "custom ini test not passed\n";
80cdf0e10cSrcweir	$state = 0;
81cdf0e10cSrcweir}
82cdf0e10cSrcweir
83cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
84cdf0e10cSrcweir	$comment = $comment . '$SYSUSERHOME not testable under windows' . "\n";
85cdf0e10cSrcweir}
86cdf0e10cSrcweirelse {
87cdf0e10cSrcweir	$rc = system "./testbootstrap", "file://$ENV{HOME}", '-env:MYBOOTSTRAPTESTVALUE=$SYSUSERHOME';
88cdf0e10cSrcweir	if (!$rc) {
89cdf0e10cSrcweir		$comment = $comment . '$SYSUSERHOME test not passed' . "\n";
90cdf0e10cSrcweir		$state = 0;
91cdf0e10cSrcweir	}
92cdf0e10cSrcweir}
93cdf0e10cSrcweir
94cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
95cdf0e10cSrcweir	$comment = $comment . '$SYSUSERCONFIG' . " not testable under windows\n";
96cdf0e10cSrcweir}
97cdf0e10cSrcweirelse {
98cdf0e10cSrcweir	$rc = system "./testbootstrap", "file://$ENV{HOME}", '-env:MYBOOTSTRAPTESTVALUE=$SYSUSERCONFIG';
99cdf0e10cSrcweir	if (!$rc) {
100cdf0e10cSrcweir		$comment = $comment . '$SYSUSERCONFIG test not passed' . "\n";
101cdf0e10cSrcweir		$state = 0;
102cdf0e10cSrcweir	}
103cdf0e10cSrcweir}
104cdf0e10cSrcweir
105cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
106cdf0e10cSrcweir	$comment = $comment . '$SYSBINDIR' . " not testable under windows\n";
107cdf0e10cSrcweir}
108cdf0e10cSrcweirelse {
109cdf0e10cSrcweir	$rc = system "./testbootstrap", "file://$ENV{PWD}", '-env:MYBOOTSTRAPTESTVALUE=$SYSBINDIR';
110cdf0e10cSrcweir	if (!$rc) {
111cdf0e10cSrcweir		$comment = $comment . '$SYSBINDIR test not passed' . "\n";
112cdf0e10cSrcweir		$state = 0;
113cdf0e10cSrcweir	}
114cdf0e10cSrcweir}
115cdf0e10cSrcweir
116cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
117cdf0e10cSrcweir	$rc = system "./testbootstrap", "inherited_value", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_VALUE', "-env:iniName=ini.ini";
118cdf0e10cSrcweir}
119cdf0e10cSrcweirelse {
120cdf0e10cSrcweir	$rc = system "./testbootstrap", "inherited_value", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_VALUE', "-env:iniName=inirc";
121cdf0e10cSrcweir}
122cdf0e10cSrcweirif (!$rc) {
123cdf0e10cSrcweir	$comment = $comment . "inherited value not passed\n";
124cdf0e10cSrcweir	$state = 0;
125cdf0e10cSrcweir}
126cdf0e10cSrcweir
127cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
128cdf0e10cSrcweir	$rc = system "./testbootstrap", "not_overwritten", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_OVERWRITTEN_VALUE', "-env:iniName=ini.ini";
129cdf0e10cSrcweir}
130cdf0e10cSrcweirelse {
131cdf0e10cSrcweir	$rc = system "./testbootstrap", "not_overwritten", '-env:MYBOOTSTRAPTESTVALUE=$INHERITED_OVERWRITTEN_VALUE', "-env:iniName=inirc";
132cdf0e10cSrcweir}
133cdf0e10cSrcweirif (!$rc) {
134cdf0e10cSrcweir	$comment = $comment . "inherited overwritten value not passed\n";
135cdf0e10cSrcweir	$state = 0;
136cdf0e10cSrcweir}
137cdf0e10cSrcweir
138cdf0e10cSrcweir
139cdf0e10cSrcweir$rc = system "./testbootstrap", "defaultvalue", "-env:INIFILENAME=", "-env:Default=defaultvalue", "-env:USEDEFAULT=1";
140cdf0e10cSrcweirif (!$rc) {
141cdf0e10cSrcweir	$comment = $comment . "default test from parameter not passed\n";
142cdf0e10cSrcweir	$state = 0;
143cdf0e10cSrcweir}
144cdf0e10cSrcweir
145cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
146cdf0e10cSrcweir	$rc = system "./testbootstrap",  "defaultValue", "-env:iniName=default.ini", "-env:INIFILENAME=", "-env:USEDEFAULT=1";
147cdf0e10cSrcweir}
148cdf0e10cSrcweirelse {
149cdf0e10cSrcweir	$rc = system "./testbootstrap",  "defaultValue", "-env:iniName=defaultrc", "-env:INIFILENAME=", "-env:USEDEFAULT=1";
150cdf0e10cSrcweir}
151cdf0e10cSrcweirif (!$rc) {
152cdf0e10cSrcweir	$comment = $comment . "default test from custom ini not passed\n";
153cdf0e10cSrcweir	$state = 0;
154cdf0e10cSrcweir}
155cdf0e10cSrcweir
156cdf0e10cSrcweir# simple macro expansion
157cdf0e10cSrcweir$rc = system "./testbootstrap",
158cdf0e10cSrcweir	"_first_second_third_",
159cdf0e10cSrcweir	"-env:FIRST=first",
160cdf0e10cSrcweir	"-env:SECOND=second",
161cdf0e10cSrcweir	"-env:THIRD=third",
162cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=_${FIRST}_${SECOND}_${THIRD}_';
163cdf0e10cSrcweirif (!$rc) {
164cdf0e10cSrcweir	$comment = $comment . "simple macro expansion test not passed\n";
165cdf0e10cSrcweir	$state = 0;
166cdf0e10cSrcweir}
167cdf0e10cSrcweir
168cdf0e10cSrcweir# simple quoting
169cdf0e10cSrcweir$rc = system "./testbootstrap",
170cdf0e10cSrcweir	'_${FIRST}_${SECOND}_${THIRD}_',
171cdf0e10cSrcweir	"-env:FIRST=first",
172cdf0e10cSrcweir	"-env:SECOND=second",
173cdf0e10cSrcweir	"-env:THIRD=third",
174cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=_\$\{FIRST\}_\$\{SECOND\}_\$\{THIRD\}_';
175cdf0e10cSrcweirif (!$rc) {
176cdf0e10cSrcweir	$comment = $comment . "simple macro quoting test not passed\n";
177cdf0e10cSrcweir	$state = 0;
178cdf0e10cSrcweir}
179cdf0e10cSrcweir
180cdf0e10cSrcweir# simple ini access
181cdf0e10cSrcweir$rc = system "./testbootstrap",
182cdf0e10cSrcweir	"TheIniKeysValue",
183cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheIniKey}';
184cdf0e10cSrcweirif (!$rc) {
185cdf0e10cSrcweir	$comment = $comment . "simple macro ini access test not passed\n";
186cdf0e10cSrcweir	$state = 0;
187cdf0e10cSrcweir}
188cdf0e10cSrcweir
189cdf0e10cSrcweir# simple profile access
190cdf0e10cSrcweir$rc = system "./testbootstrap",
191cdf0e10cSrcweir	"TheKeysValue",
192cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=${./bootstraptest.ini:TheSection:TheKey}';
193cdf0e10cSrcweirif (!$rc) {
194cdf0e10cSrcweir	$comment = $comment . "simple macro profile access test not passed\n";
195cdf0e10cSrcweir	$state = 0;
196cdf0e10cSrcweir}
197cdf0e10cSrcweir
198cdf0e10cSrcweir# profile access with simple macro expansion
199cdf0e10cSrcweir$rc = system "./testbootstrap",
200cdf0e10cSrcweir	"TheKeysValue",
201cdf0e10cSrcweir	"-env:ININAME=./bootstraptest.ini",
202cdf0e10cSrcweir	"-env:SECTIONNAME=TheSection",
203cdf0e10cSrcweir	"-env:KEYNAME=TheKey",
204cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=${$ININAME:$SECTIONNAME:$KEYNAME}';
205cdf0e10cSrcweirif (!$rc) {
206cdf0e10cSrcweir	$comment = $comment . "profile access with simple macro expansion test not passed\n";
207cdf0e10cSrcweir	$state = 0;
208cdf0e10cSrcweir}
209cdf0e10cSrcweir
210cdf0e10cSrcweir# profile access with complex macro expansion
211cdf0e10cSrcweir$rc = system "./testbootstrap",
212cdf0e10cSrcweir	"TheKeysValue",
213cdf0e10cSrcweir	"-env:ININAME=./bootstraptest.ini",
214cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=${$ININAME:${$ININAME:SecondSection:IndirectSection}:${$ININAME:SecondSection:IndirectKey}}';
215cdf0e10cSrcweirif (!$rc) {
216cdf0e10cSrcweir	$comment = $comment . "profile access with complex macro expansion test not passed\n";
217cdf0e10cSrcweir	$state = 0;
218cdf0e10cSrcweir}
219cdf0e10cSrcweir
220*86e1cf34SPedro Giffuni# test no infinite recursion
221cdf0e10cSrcweirif ($ENV{GUI} eq "WNT") {
222cdf0e10cSrcweir	$rc = system "./testbootstrap",
223cdf0e10cSrcweir	'"***RECURSION DETECTED***"',
224cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE';
225cdf0e10cSrcweir}
226cdf0e10cSrcweirelse {
227cdf0e10cSrcweir	$rc = system "./testbootstrap",
228cdf0e10cSrcweir	'***RECURSION DETECTED***',
229cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=$MYBOOTSTRAPTESTVALUE';
230cdf0e10cSrcweir}
231cdf0e10cSrcweirif (!$rc) {
232*86e1cf34SPedro Giffuni	$comment = $comment . "no infinite recursion test not passed\n";
233cdf0e10cSrcweir	$state = 0;
234cdf0e10cSrcweir}
235cdf0e10cSrcweir
236cdf0e10cSrcweir# test unicode
237cdf0e10cSrcweir$rc = system "./testbootstrap",
238cdf0e10cSrcweir	"AAABBBCCC000",
239cdf0e10cSrcweir	'-env:MYBOOTSTRAPTESTVALUE=\u0041\u0041\u0041\u0042\u0042\u0042\u0043\u0043\u0043\u0030\u0030\u0030';
240cdf0e10cSrcweirif (!$rc) {
241cdf0e10cSrcweir	$comment = $comment . "uncode not passed\n";
242cdf0e10cSrcweir	$state = 0;
243cdf0e10cSrcweir}
244cdf0e10cSrcweir
245cdf0e10cSrcweirprint "**************************\n";
246cdf0e10cSrcweirif($state) {
247cdf0e10cSrcweir	print "****** tests passed ******\n";
248cdf0e10cSrcweir}
249cdf0e10cSrcweirelse {
250cdf0e10cSrcweir	print "**** tests NOT passed ****\n";
251cdf0e10cSrcweir	print "Commnent:\n", $comment, "\n";
252cdf0e10cSrcweir}
253cdf0e10cSrcweirprint "**************************\n";
254cdf0e10cSrcweir
255cdf0e10cSrcweir
256cdf0e10cSrcweir
257