xref: /titanic_41/usr/src/cmd/ksh/Makefile.testshell (revision 1dd08564e4a3aafe66b00aee6f222b0885346fe8)
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# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23# Use is subject to license terms.
24#
25# ident	"%Z%%M%	%I%	%E% SMI"
26#
27
28#
29# run the ksh93 minimum set of tests
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# - "io.sh" may fail due a subtle bug in ksh93 or the test suite which
47#   only happens when ksh93 is NOT called "ksh"; to work around the
48#   problem the test sequence currently uses $(SRC)/cmd/ksh/$(CMDTRANSMACH)/ksh
49#   instead of $(SRC)/cmd/ksh/$(CMDTRANSMACH)/$(PROG) until we+upstream figure
50#   out what exactly is going wrong in this case.
51#   -- snip --
52#   ./close0[2]: ./close1: cannot execute [Exec format error]
53#	    io.sh[81]: picked up file descriptor zero for opening script file
54#   -- snip --
55#
56# - These tests need a working system clock, otherwise they'll bite you.
57#
58# - The test frontend in this Makefile should be rewritten in ksh93
59#   instead of the current /usr/bin/ksh (=ksh88i). This would be far less
60#   complicated.
61#
62# - More locales should be tested here (via ON_KSH_TEST_LOCALES below).
63#   Locales like "ru_RU.KOI8-R","de_DE.UTF-8", "is_IS.ISO8859-1",
64#   "is_IS.UTF-8" and "nl_BE.ISO8859-15" are on our wishlist - but
65#   that is getting little bit more compliciated because these locales use
66#   ',' as decimal delimter. The best solution may be to wait for ksh93
67#   being integrated into OS/Net and then change the test sequence to
68#   use ksh93's associate/compound variables (this may require a flag
69#   day... ;-( ).
70#   The current list was mainly composed to cover various encodings and
71#   all important markets based on suggestions by Sun's i18n team.
72#
73# - Due to the timing sensitivity of some of the tests, these tests should
74#   be run on a quiet system with no other activity.
75#
76
77TESTSRC= $(LIBSHELLSRC)/../tests
78
79# ON_KSH_TEST_LOCALES can be overridden via
80# $ export ON_KSH_TEST_LOCALES=<value> # before $ make install #
81ON_KSH_TEST_LOCALES = \
82	C \
83	en_US en_US.UTF-8 \
84	he_IL.UTF-8 \
85	hi_IN.UTF-8 \
86	ja_JP.PCK ja_JP.UTF-8 ja_JP.eucJP \
87	ko_KR.EUC \
88	th_TH.TIS620 \
89	zh_CN.EUC zh_CN.GBK zh_CN.GB18030 zh_CN.UTF-8 \
90	zh_HK.BIG5HK \
91	zh_TW.BIG5 zh_TW.EUC zh_TW.UTF-8
92
93# ON_KSH_TEST_LIST can be overridden via
94# $ export ON_KSH_TEST_LIST=<value> # before $ make install #
95ON_KSH_TEST_LIST = $(TESTSRC)/*.sh
96
97# Flag to control whether we should make test failures non-fatal
98ON_KSH_TEST_IGNORE_TESTFAILURE=false
99
100# We must wait for other things in this subdir to finish before running
101# the test suite, otherwise we may run into trouble that this activity
102# may disturb the test suite run (resulting in weird "heisenbug"-like
103# test failures).
104testshell: $(PROG)
105	@ \
106	print '# NOTE: Make sure your binaries in ROOT match your kernel!' ; \
107	( \
108	    set +o errexit ; \
109	    export PATH="$(SRC)/cmd/ksh/$(CMDTRANSMACH):/bin:/usr/bin" ; \
110	    printf "# which ksh='%s', ksh93='%s'\n" \
111	        "$$(which ksh)" "$$(which ksh93)" ; \
112	) ; \
113	if [[ "$$(isalist | fgrep "$(CMDTRANSMACH)")" = "" ]] ; then \
114	    printf \
115	        "# ISA='%s' not available on this system, skipping tests...\n" \
116	        "$(CMDTRANSMACH)" ; \
117	    exit 0 ; \
118	fi ; \
119	exec 2>&1 ; \
120	(supported_locales="$$(/usr/bin/locale -a)" ; \
121	for test_lang in $(ON_KSH_TEST_LOCALES) ; do \
122	    if [[ "$$(print "$${supported_locales}" | \
123	             egrep "^$${test_lang}\$$")" = "" ]] ; then \
124	        printf \
125		    "# Locale '%s' not supported, skipping tests...\n" \
126		    "$${test_lang}" ; \
127	        continue ; \
128	    fi ; \
129	    (for test_item in $(ON_KSH_TEST_LIST) ; do \
130	        [[ "$${test_item}" = "$(TESTSRC)/builtins.sh" || \
131	           "$${test_item}" = "$(TESTSRC)/options.sh" ]] || \
132		   $(ON_KSH_TEST_IGNORE_TESTFAILURE) && \
133		   set +o errexit ; \
134	        printf \
135		    "## Running %s test: LANG='%s' script='%s'\n" \
136		    "$(CMDTRANSMACH)/ksh" \
137		    "$${test_lang}" \
138		    "$$(basename "$${test_item}")"; \
139                ( \
140	            test_output="$$( ( \
141	        	export \
142	        	    SHELL="$(SRC)/cmd/ksh/$(CMDTRANSMACH)/ksh" \
143	        	    LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
144	        	    LD_LIBRARY_PATH_32="$(ROOTLIB)/" ; \
145	        	    LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" ; \
146	        	"$${SHELL}" "$(TESTSRC)/shtests" -t \
147	        	    LD_LIBRARY_PATH_64="$${LD_LIBRARY_PATH_64}" \
148	        	    LD_LIBRARY_PATH_32="$${LD_LIBRARY_PATH_32}" \
149	        	    LD_LIBRARY_PATH="$${LD_LIBRARY_PATH}" \
150	        	    SHELL="$${SHELL}" \
151	        	    LANG="$${test_lang}" \
152	        	    LC_ALL="$${test_lang}" \
153	        	      "$${test_item}" \
154	            ) 2>&1 | while read ; do \
155		                 printf "#\t%s\n" "$${REPLY}" ; \
156			     done | tee /dev/stderr)" ; \
157	            [[ "$$(print "$${test_output}" | \
158		          egrep 'passed \[ .* tests 0 errors \]')" != "" ]] || \
159			      (print "##> test failed" ; exit 1) \
160                ) ; \
161	        set -o errexit ; \
162	    done) ; \
163	done)
164