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