xref: /titanic_41/usr/src/cmd/ksh/Makefile.testshell (revision 24fe0b3bf671e123467ce1df0b67cadd3614c8e4)
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 2008 Sun Microsystems, Inc.  All rights reserved.
24# Use is subject to license terms.
25#
26
27#
28# Run the ksh93 minimum set of tests
29#
30
31#
32# Notes:
33# - "builtins.sh" may fail in some locales like this:
34#   -- snip --
35#   ## Running ksh test: LANG='zh_TW.EUC' script='builtins.sh'
36#   builtins.sh[274]: printf "%T" now
37#   -- snip --
38#
39# - "options.sh" may currently fail in some locales with:
40#   -- snip --
41#   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'
42#   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'
43#   -- snip --
44#   This may be simply a different sort order or a bug in the test suite.
45#   Currently under investigation.
46#
47# - These tests need a working system clock, otherwise they'll bite you.
48#
49# - The current list of locales was mainly composed to cover various encodings
50#   and all important markets based on suggestions by Sun's i18n team.
51#
52# - More locales should be tested here (via ON_KSH_TEST_LOCALES below).
53#   Locales like "ru_RU.KOI8-R","de_DE.UTF-8", "is_IS.ISO8859-1",
54#   "is_IS.UTF-8" and "nl_BE.ISO8859-15" are on our wishlist - but
55#   that is getting little bit more compliciated because these locales use
56#   ',' as decimal delimter. The best solution may be to wait for ksh93
57#   being integrated into OS/Net and then change the test sequence to
58#   use ksh93's associative/compound variables (this may require a flag
59#   day... ;-( ).
60#
61# - Due to the timing sensitivity of some of the tests, these tests should
62#   be run on a quiet system with no other activity.
63#
64
65TESTSRC= $(LIBSHELLBASE)/common/tests
66
67# ON_KSH_TEST_LOCALES can be overridden via
68# $ export ON_KSH_TEST_LOCALES=<value> # before $ make install #
69ON_KSH_TEST_LOCALES = \
70	C \
71	en_US.UTF-8 en_US en_US.ISO8859-15@euro \
72	he_IL.UTF-8 \
73	hi_IN.UTF-8 \
74	ja ja_JP.PCK ja_JP.UTF-8 ja_JP.eucJP \
75	ko_KR.UTF-8 ko_KR.EUC \
76	th_TH.TIS620 \
77	zh_CN.EUC zh_CN.GBK \
78	zh_CN.GB18030 zh_CN.GB18030@pinyin zh_CN.GB18030@radical zh_CN.GB18030@stroke \
79	zh_CN.UTF-8 zh_CN.UTF-8@pinyin zh_CN.UTF-8@radical zh_CN.UTF-8@stroke \
80	zh_HK.BIG5HK \
81	zh_TW.BIG5 zh_TW.EUC zh_TW.UTF-8
82
83# ON_KSH_TEST_LIST can be overridden via
84# $ export ON_KSH_TEST_LIST=<value> # before $ make install #
85ON_KSH_TEST_LIST = $(TESTSRC)/*.sh
86
87# Flag to control whether we should make test failures non-fatal
88ON_KSH_TEST_IGNORE_TESTFAILURE=false
89
90# We must wait for other things in this subdir to finish before running
91# the test suite, otherwise we may run into trouble that this activity
92# may disturb the test suite run (resulting in weird "heisenbug"-like
93# test failures).
94testshell: $(PROG)
95	@ \
96	builtin basename ; \
97	print '# NOTE: Make sure your binaries in ROOT match your kernel!' ; \
98	( \
99	    set +o errexit ; \
100	    export PATH="$(SRC)/cmd/ksh/$(LIBSHELLMACH):/bin:/usr/bin" ; \
101	    printf "# which ksh='%s', ksh93='%s'\n" \
102	        "$$(which ksh)" "$$(which ksh93)" ; \
103	) ; \
104	if [[ "$$(isalist)" != ~(E)$(LIBSHELLMACH) ]] ; then \
105	    printf \
106	        "# ISA='%s' not available on this system, skipping tests...\n" \
107	        "$(LIBSHELLMACH)" ; \
108	    exit 0 ; \
109	fi ; \
110	print "# Libraries used:" ; \
111	LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
112	LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
113	LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" \
114		/usr/bin/ldd "$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" ; \
115	print "# Running tests:" ; \
116	redirect 2>&1 ; \
117	(supported_locales="$$(/usr/bin/locale -a)" ; \
118	for test_lang in $(ON_KSH_TEST_LOCALES) ; do \
119	    if [[ "$$(egrep "^$${test_lang}\$$" <<< "$${supported_locales}")" == "" ]] ; then \
120	        printf \
121		    "# Locale '%s' not supported, skipping tests...\n" \
122		    "$${test_lang}" ; \
123	        continue ; \
124	    fi ; \
125	    (for test_item in $(ON_KSH_TEST_LIST) ; do \
126	        [[ "$${test_item}" == "$(TESTSRC)/builtins.sh" || \
127	           "$${test_item}" == "$(TESTSRC)/options.sh" ]] || \
128		   $(ON_KSH_TEST_IGNORE_TESTFAILURE) && \
129		   set +o errexit ; \
130		   for mode in 'plain_script:-s' 'compiled_script:-c' ; do \
131		        printf \
132			    "## Running %s test: LANG='%s' script='%s', mode='%s'\n" \
133			    "$(LIBSHELLMACH)/ksh" \
134			    "$${test_lang}" \
135			    "$$(basename "$${test_item}")" \
136			    "$${mode%:*}"; \
137			( \
138		            test_output="$$( ( \
139		        	export \
140		        	    SHELL="$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" \
141		        	    LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
142		        	    LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
143		        	    LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" ; \
144		        	"$${SHELL}" "$(TESTSRC)/shtests" -t "$${mode#*:}" \
145		        	    LD_LIBRARY_PATH_64="$${LD_LIBRARY_PATH_64}" \
146		        	    LD_LIBRARY_PATH_32="$${LD_LIBRARY_PATH_32}" \
147		        	    LD_LIBRARY_PATH="$${LD_LIBRARY_PATH}" \
148		        	    SHELL="$${SHELL}" \
149		        	    LANG="$${test_lang}" \
150		        	    LC_ALL="$${test_lang}" \
151				    VMDEBUG=a \
152				    SHCOMP="$(ROOTBIN)/shcomp" \
153		        	      "$${test_item}" \
154		            ) 2>&1 | while read ; do \
155			                 printf "#\t%s\n" "$${REPLY}" ; \
156				     done | tee /dev/stderr)" ; \
157			    [[ "$${test_output}" == ~(E)test.*passed\ \[\ [[:digit:]]*\ test.*\ 0\ errors\ \] ]] || \
158				      (print "##--------> test failed" ; exit 1) \
159			) ; \
160		   done ; \
161		   set -o errexit ; \
162	    done) ; \
163	done)
164