xref: /illumos-gate/usr/src/cmd/ast/ksh/Makefile.testshell (revision b30d193948be5a7794d7ae3ba0ed9c2f72c88e0f)
1*b30d1939SAndy Fiddaman#
2*b30d1939SAndy Fiddaman# CDDL HEADER START
3*b30d1939SAndy Fiddaman#
4*b30d1939SAndy Fiddaman# The contents of this file are subject to the terms of the
5*b30d1939SAndy Fiddaman# Common Development and Distribution License (the "License").
6*b30d1939SAndy Fiddaman# You may not use this file except in compliance with the License.
7*b30d1939SAndy Fiddaman#
8*b30d1939SAndy Fiddaman# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*b30d1939SAndy Fiddaman# or http://www.opensolaris.org/os/licensing.
10*b30d1939SAndy Fiddaman# See the License for the specific language governing permissions
11*b30d1939SAndy Fiddaman# and limitations under the License.
12*b30d1939SAndy Fiddaman#
13*b30d1939SAndy Fiddaman# When distributing Covered Code, include this CDDL HEADER in each
14*b30d1939SAndy Fiddaman# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*b30d1939SAndy Fiddaman# If applicable, add the following below this CDDL HEADER, with the
16*b30d1939SAndy Fiddaman# fields enclosed by brackets "[]" replaced with your own identifying
17*b30d1939SAndy Fiddaman# information: Portions Copyright [yyyy] [name of copyright owner]
18*b30d1939SAndy Fiddaman#
19*b30d1939SAndy Fiddaman# CDDL HEADER END
20*b30d1939SAndy Fiddaman#
21*b30d1939SAndy Fiddaman
22*b30d1939SAndy Fiddaman#
23*b30d1939SAndy Fiddaman# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24*b30d1939SAndy Fiddaman#
25*b30d1939SAndy Fiddaman
26*b30d1939SAndy Fiddaman#
27*b30d1939SAndy Fiddaman# Run the ksh93 minimum set of tests
28*b30d1939SAndy Fiddaman#
29*b30d1939SAndy Fiddaman
30*b30d1939SAndy Fiddaman#
31*b30d1939SAndy Fiddaman# Notes:
32*b30d1939SAndy Fiddaman# - "builtins.sh" may fail in some locales like this:
33*b30d1939SAndy Fiddaman#   -- snip --
34*b30d1939SAndy Fiddaman#   ## Running ksh test: LANG='zh_TW.EUC' script='builtins.sh'
35*b30d1939SAndy Fiddaman#   builtins.sh[274]: printf "%T" now
36*b30d1939SAndy Fiddaman#   -- snip --
37*b30d1939SAndy Fiddaman#
38*b30d1939SAndy Fiddaman# - "options.sh" may currently fail in some locales with:
39*b30d1939SAndy Fiddaman#   -- snip --
40*b30d1939SAndy Fiddaman#   options.sh[145]: -G ** failed -- expected 'bam.c bar bar.c bar/bam.c bar/foo.c foo foo/bam.c', got 'bam.c bar bar/bam.c bar.c bar/foo.c foo foo/bam.c'
41*b30d1939SAndy Fiddaman#   options.sh[149]: -G **/*.c failed -- expected 'bam.c bar.c bar/bam.c bar/foo.c foo/bam.c', got 'bam.c bar/bam.c bar.c bar/foo.c foo/bam.c'
42*b30d1939SAndy Fiddaman#   -- snip --
43*b30d1939SAndy Fiddaman#   This may be simply a different sort order or a bug in the test suite.
44*b30d1939SAndy Fiddaman#   Currently under investigation.
45*b30d1939SAndy Fiddaman#
46*b30d1939SAndy Fiddaman# - "glob.sh" may currently fail in some locales (e.g. en_US.UTF-8) with:
47*b30d1939SAndy Fiddaman#   -- snip --
48*b30d1939SAndy Fiddaman#   glob.sh[157] glob -- expected '<d> <dd> <de> <Beware>', got '<Beware> <d> <dd> <de>'
49*b30d1939SAndy Fiddaman#   glob.sh[277] glob -- expected '<abc> <abe> <bdir> <ca> <de> <man> <Beware>', got '<abc> <abe> <bdir> <Beware> <ca> <de> <man>'
50*b30d1939SAndy Fiddaman#   -- snip --
51*b30d1939SAndy Fiddaman#   This may be simply a different sort order or a bug in the test suite.
52*b30d1939SAndy Fiddaman#   Currently under investigation.
53*b30d1939SAndy Fiddaman#
54*b30d1939SAndy Fiddaman# - These tests need a working system clock, otherwise they'll bite you.
55*b30d1939SAndy Fiddaman#
56*b30d1939SAndy Fiddaman# - The current list of locales was mainly composed to cover various encodings
57*b30d1939SAndy Fiddaman#   and all important markets based on suggestions by Sun's i18n team.
58*b30d1939SAndy Fiddaman#
59*b30d1939SAndy Fiddaman# - More locales should be tested here (via ON_KSH_TEST_LOCALES below).
60*b30d1939SAndy Fiddaman#   Locales like "ru_RU.KOI8-R","de_DE.UTF-8", "is_IS.ISO8859-1",
61*b30d1939SAndy Fiddaman#   "is_IS.UTF-8" and "nl_BE.ISO8859-15" are on our wishlist - but
62*b30d1939SAndy Fiddaman#   that is getting little bit more compliciated because these locales use
63*b30d1939SAndy Fiddaman#   ',' as decimal delimter. The best solution may be to wait for ksh93
64*b30d1939SAndy Fiddaman#   being integrated into OS/Net and then change the test sequence to
65*b30d1939SAndy Fiddaman#   use ksh93's associative/compound variables (this may require a flag
66*b30d1939SAndy Fiddaman#   day... ;-( ).
67*b30d1939SAndy Fiddaman#
68*b30d1939SAndy Fiddaman# - Due to the timing sensitivity of some of the tests, these tests should
69*b30d1939SAndy Fiddaman#   be run on a quiet system with no other activity.
70*b30d1939SAndy Fiddaman#
71*b30d1939SAndy Fiddaman
72*b30d1939SAndy FiddamanTESTSRC= $(LIBSHELLBASE)/common/tests
73*b30d1939SAndy Fiddaman
74*b30d1939SAndy Fiddaman# ON_KSH_TEST_LOCALES can be overridden via
75*b30d1939SAndy Fiddaman# $ export ON_KSH_TEST_LOCALES=<value> # before $ make install #
76*b30d1939SAndy FiddamanON_KSH_TEST_LOCALES = \
77*b30d1939SAndy Fiddaman	C \
78*b30d1939SAndy Fiddaman	en_US.UTF-8 en_US en_US.ISO8859-15@euro \
79*b30d1939SAndy Fiddaman	he_IL.UTF-8 \
80*b30d1939SAndy Fiddaman	hi_IN.UTF-8 \
81*b30d1939SAndy Fiddaman	ja ja_JP.PCK ja_JP.UTF-8 ja_JP.eucJP \
82*b30d1939SAndy Fiddaman	ko_KR.UTF-8 ko_KR.EUC \
83*b30d1939SAndy Fiddaman	th_TH.TIS620 \
84*b30d1939SAndy Fiddaman	zh_CN.EUC zh_CN.GBK \
85*b30d1939SAndy Fiddaman	zh_CN.GB18030 zh_CN.GB18030@pinyin zh_CN.GB18030@radical zh_CN.GB18030@stroke \
86*b30d1939SAndy Fiddaman	zh_CN.UTF-8 zh_CN.UTF-8@pinyin zh_CN.UTF-8@radical zh_CN.UTF-8@stroke \
87*b30d1939SAndy Fiddaman	zh_HK.BIG5HK \
88*b30d1939SAndy Fiddaman	zh_TW.BIG5 zh_TW.EUC zh_TW.UTF-8
89*b30d1939SAndy Fiddaman
90*b30d1939SAndy Fiddaman# ON_KSH_TEST_LIST can be overridden via
91*b30d1939SAndy Fiddaman# $ export ON_KSH_TEST_LIST=<value> # before $ make install #
92*b30d1939SAndy FiddamanON_KSH_TEST_LIST = $(TESTSRC)/*.sh
93*b30d1939SAndy Fiddaman
94*b30d1939SAndy Fiddaman# Boolean (true/false) flag to control whether we should make test
95*b30d1939SAndy Fiddaman# failures non-fatal
96*b30d1939SAndy FiddamanON_KSH_TEST_IGNORE_TESTFAILURE=false
97*b30d1939SAndy Fiddaman
98*b30d1939SAndy Fiddaman# We must wait for other things in this subdir to finish before running
99*b30d1939SAndy Fiddaman# the test suite, otherwise we may run into trouble that this activity
100*b30d1939SAndy Fiddaman# may disturb the test suite run (resulting in weird "heisenbug"-like
101*b30d1939SAndy Fiddaman# test failures).
102*b30d1939SAndy Fiddamantestshell: $(PROG)
103*b30d1939SAndy Fiddaman	@ \
104*b30d1939SAndy Fiddaman	builtin basename ; \
105*b30d1939SAndy Fiddaman	print '# NOTE: Make sure your binaries in ROOT match your kernel!' ; \
106*b30d1939SAndy Fiddaman	( \
107*b30d1939SAndy Fiddaman	    set +o errexit ; \
108*b30d1939SAndy Fiddaman	    export PATH="$(SRC)/cmd/ksh/$(LIBSHELLMACH):/bin:/usr/bin" ; \
109*b30d1939SAndy Fiddaman	    printf "# which ksh='%s', ksh93='%s'\n" \
110*b30d1939SAndy Fiddaman		"$$(which ksh)" "$$(which ksh93)" ; \
111*b30d1939SAndy Fiddaman	) ; \
112*b30d1939SAndy Fiddaman	if [[ "$$(isalist)" != ~(F)$(LIBSHELLMACH) ]] ; then \
113*b30d1939SAndy Fiddaman	    printf \
114*b30d1939SAndy Fiddaman		"# ISA='%s' not available on this system, skipping tests...\n" \
115*b30d1939SAndy Fiddaman		"$(LIBSHELLMACH)" ; \
116*b30d1939SAndy Fiddaman	    exit 0 ; \
117*b30d1939SAndy Fiddaman	fi ; \
118*b30d1939SAndy Fiddaman	print "# Libraries used:" ; \
119*b30d1939SAndy Fiddaman	LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
120*b30d1939SAndy Fiddaman	LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
121*b30d1939SAndy Fiddaman	LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" \
122*b30d1939SAndy Fiddaman		/usr/bin/ldd "$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" ; \
123*b30d1939SAndy Fiddaman	print "# Running tests:" ; \
124*b30d1939SAndy Fiddaman	redirect 2>&1 ; \
125*b30d1939SAndy Fiddaman	(supported_locales="$$(/usr/bin/locale -a)" ; \
126*b30d1939SAndy Fiddaman	for test_lang in $(ON_KSH_TEST_LOCALES) ; do \
127*b30d1939SAndy Fiddaman	    if [[ "$$(egrep "^$${test_lang}\$$" <<< "$${supported_locales}")" == "" ]] ; then \
128*b30d1939SAndy Fiddaman		printf \
129*b30d1939SAndy Fiddaman		    "# Locale '%s' not supported, skipping tests...\n" \
130*b30d1939SAndy Fiddaman		    "$${test_lang}" ; \
131*b30d1939SAndy Fiddaman		continue ; \
132*b30d1939SAndy Fiddaman	    fi ; \
133*b30d1939SAndy Fiddaman	    (for test_item in $(ON_KSH_TEST_LIST) ; do \
134*b30d1939SAndy Fiddaman		[[ "$${test_item}" == "$(TESTSRC)/builtins.sh" || \
135*b30d1939SAndy Fiddaman		   "$${test_item}" == "$(TESTSRC)/glob.sh" || \
136*b30d1939SAndy Fiddaman		   "$${test_item}" == "$(TESTSRC)/options.sh" ]] || \
137*b30d1939SAndy Fiddaman		   $(ON_KSH_TEST_IGNORE_TESTFAILURE) && \
138*b30d1939SAndy Fiddaman		   set +o errexit ; \
139*b30d1939SAndy Fiddaman		   for mode in 'plain_script:-s' 'compiled_script:-c' ; do \
140*b30d1939SAndy Fiddaman			printf \
141*b30d1939SAndy Fiddaman			    "## Running %s test: LANG='%s' script='%s', mode='%s'\n" \
142*b30d1939SAndy Fiddaman			    "$(LIBSHELLMACH)/ksh" \
143*b30d1939SAndy Fiddaman			    "$${test_lang}" \
144*b30d1939SAndy Fiddaman			    "$$(basename "$${test_item}")" \
145*b30d1939SAndy Fiddaman			    "$${mode%:*}"; \
146*b30d1939SAndy Fiddaman			( \
147*b30d1939SAndy Fiddaman			    ulimit -s 65536 ; \
148*b30d1939SAndy Fiddaman			    test_output="$$( ( \
149*b30d1939SAndy Fiddaman				export \
150*b30d1939SAndy Fiddaman				    SHELL="$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" \
151*b30d1939SAndy Fiddaman				    LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
152*b30d1939SAndy Fiddaman				    LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
153*b30d1939SAndy Fiddaman				    LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" ; \
154*b30d1939SAndy Fiddaman				"$${SHELL}" "$(TESTSRC)/shtests" -t "$${mode#*:}" \
155*b30d1939SAndy Fiddaman				    LD_LIBRARY_PATH_64="$${LD_LIBRARY_PATH_64}" \
156*b30d1939SAndy Fiddaman				    LD_LIBRARY_PATH_32="$${LD_LIBRARY_PATH_32}" \
157*b30d1939SAndy Fiddaman				    LD_LIBRARY_PATH="$${LD_LIBRARY_PATH}" \
158*b30d1939SAndy Fiddaman				    SHELL="$${SHELL}" \
159*b30d1939SAndy Fiddaman				    LANG="$${test_lang}" \
160*b30d1939SAndy Fiddaman				    LC_ALL="$${test_lang}" \
161*b30d1939SAndy Fiddaman				    VMALLOC_OPTIONS=abort \
162*b30d1939SAndy Fiddaman				    SHCOMP="$(ROOTBIN)/shcomp" \
163*b30d1939SAndy Fiddaman				      "$${test_item}" \
164*b30d1939SAndy Fiddaman			    ) 2>&1 | while read ; do \
165*b30d1939SAndy Fiddaman					 printf "#\t%s\n" "$${REPLY}" ; \
166*b30d1939SAndy Fiddaman				     done | tee /dev/stderr)" ; \
167*b30d1939SAndy Fiddaman			    [[ "$${test_output}" == ~(E)test.*passed\ \[\ [[:digit:]]*\ test.*\ 0\ errors\ \] ]] || \
168*b30d1939SAndy Fiddaman				      (print "##--------> test failed" ; exit 1) \
169*b30d1939SAndy Fiddaman			) ; \
170*b30d1939SAndy Fiddaman		   done ; \
171*b30d1939SAndy Fiddaman		   set -o errexit ; \
172*b30d1939SAndy Fiddaman	    done) ; \
173*b30d1939SAndy Fiddaman	done)
174