xref: /onnv-gate/usr/src/cmd/ksh/Makefile.testshell (revision 12068:08a39a083754)
14887Schin#
24887Schin# CDDL HEADER START
34887Schin#
44887Schin# The contents of this file are subject to the terms of the
54887Schin# Common Development and Distribution License (the "License").
64887Schin# You may not use this file except in compliance with the License.
74887Schin#
84887Schin# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
94887Schin# or http://www.opensolaris.org/os/licensing.
104887Schin# See the License for the specific language governing permissions
114887Schin# and limitations under the License.
124887Schin#
134887Schin# When distributing Covered Code, include this CDDL HEADER in each
144887Schin# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
154887Schin# If applicable, add the following below this CDDL HEADER, with the
164887Schin# fields enclosed by brackets "[]" replaced with your own identifying
174887Schin# information: Portions Copyright [yyyy] [name of copyright owner]
184887Schin#
194887Schin# CDDL HEADER END
204887Schin#
218462SApril.Chin@Sun.COM
224887Schin#
23*12068SRoger.Faulkner@Oracle.COM# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
244887Schin#
254887Schin
264887Schin#
278462SApril.Chin@Sun.COM# Run the ksh93 minimum set of tests
288462SApril.Chin@Sun.COM#
298462SApril.Chin@Sun.COM
304887Schin#
314887Schin# Notes:
324887Schin# - "builtins.sh" may fail in some locales like this:
334887Schin#   -- snip --
344887Schin#   ## Running ksh test: LANG='zh_TW.EUC' script='builtins.sh'
354887Schin#   builtins.sh[274]: printf "%T" now
364887Schin#   -- snip --
374887Schin#
384887Schin# - "options.sh" may currently fail in some locales with:
394887Schin#   -- snip --
404887Schin#   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'
414887Schin#   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'
424887Schin#   -- snip --
434887Schin#   This may be simply a different sort order or a bug in the test suite.
444887Schin#   Currently under investigation.
454887Schin#
46*12068SRoger.Faulkner@Oracle.COM# - "glob.sh" may currently fail in some locales (e.g. en_US.UTF-8) with:
47*12068SRoger.Faulkner@Oracle.COM#   -- snip --
48*12068SRoger.Faulkner@Oracle.COM#   glob.sh[157] glob -- expected '<d> <dd> <de> <Beware>', got '<Beware> <d> <dd> <de>'
49*12068SRoger.Faulkner@Oracle.COM#   glob.sh[277] glob -- expected '<abc> <abe> <bdir> <ca> <de> <man> <Beware>', got '<abc> <abe> <bdir> <Beware> <ca> <de> <man>'
50*12068SRoger.Faulkner@Oracle.COM#   -- snip --
51*12068SRoger.Faulkner@Oracle.COM#   This may be simply a different sort order or a bug in the test suite.
52*12068SRoger.Faulkner@Oracle.COM#   Currently under investigation.
53*12068SRoger.Faulkner@Oracle.COM#
544887Schin# - These tests need a working system clock, otherwise they'll bite you.
554887Schin#
568462SApril.Chin@Sun.COM# - The current list of locales was mainly composed to cover various encodings
578462SApril.Chin@Sun.COM#   and all important markets based on suggestions by Sun's i18n team.
584887Schin#
594887Schin# - More locales should be tested here (via ON_KSH_TEST_LOCALES below).
604887Schin#   Locales like "ru_RU.KOI8-R","de_DE.UTF-8", "is_IS.ISO8859-1",
614887Schin#   "is_IS.UTF-8" and "nl_BE.ISO8859-15" are on our wishlist - but
624887Schin#   that is getting little bit more compliciated because these locales use
634887Schin#   ',' as decimal delimter. The best solution may be to wait for ksh93
644887Schin#   being integrated into OS/Net and then change the test sequence to
658462SApril.Chin@Sun.COM#   use ksh93's associative/compound variables (this may require a flag
664887Schin#   day... ;-( ).
674887Schin#
684887Schin# - Due to the timing sensitivity of some of the tests, these tests should
694887Schin#   be run on a quiet system with no other activity.
704887Schin#
714887Schin
728462SApril.Chin@Sun.COMTESTSRC= $(LIBSHELLBASE)/common/tests
734887Schin
744887Schin# ON_KSH_TEST_LOCALES can be overridden via
754887Schin# $ export ON_KSH_TEST_LOCALES=<value> # before $ make install #
764887SchinON_KSH_TEST_LOCALES = \
774887Schin	C \
788462SApril.Chin@Sun.COM	en_US.UTF-8 en_US en_US.ISO8859-15@euro \
794887Schin	he_IL.UTF-8 \
804887Schin	hi_IN.UTF-8 \
818462SApril.Chin@Sun.COM	ja ja_JP.PCK ja_JP.UTF-8 ja_JP.eucJP \
828462SApril.Chin@Sun.COM	ko_KR.UTF-8 ko_KR.EUC \
834887Schin	th_TH.TIS620 \
848462SApril.Chin@Sun.COM	zh_CN.EUC zh_CN.GBK \
858462SApril.Chin@Sun.COM	zh_CN.GB18030 zh_CN.GB18030@pinyin zh_CN.GB18030@radical zh_CN.GB18030@stroke \
868462SApril.Chin@Sun.COM	zh_CN.UTF-8 zh_CN.UTF-8@pinyin zh_CN.UTF-8@radical zh_CN.UTF-8@stroke \
874887Schin	zh_HK.BIG5HK \
884887Schin	zh_TW.BIG5 zh_TW.EUC zh_TW.UTF-8
894887Schin
904887Schin# ON_KSH_TEST_LIST can be overridden via
914887Schin# $ export ON_KSH_TEST_LIST=<value> # before $ make install #
924887SchinON_KSH_TEST_LIST = $(TESTSRC)/*.sh
934887Schin
94*12068SRoger.Faulkner@Oracle.COM# Boolean (true/false) flag to control whether we should make test
95*12068SRoger.Faulkner@Oracle.COM# failures non-fatal
964887SchinON_KSH_TEST_IGNORE_TESTFAILURE=false
974887Schin
984887Schin# We must wait for other things in this subdir to finish before running
994887Schin# the test suite, otherwise we may run into trouble that this activity
1004887Schin# may disturb the test suite run (resulting in weird "heisenbug"-like
1014887Schin# test failures).
1024887Schintestshell: $(PROG)
1034887Schin	@ \
1048462SApril.Chin@Sun.COM	builtin basename ; \
1054887Schin	print '# NOTE: Make sure your binaries in ROOT match your kernel!' ; \
1064887Schin	( \
1074887Schin	    set +o errexit ; \
1088462SApril.Chin@Sun.COM	    export PATH="$(SRC)/cmd/ksh/$(LIBSHELLMACH):/bin:/usr/bin" ; \
1094887Schin	    printf "# which ksh='%s', ksh93='%s'\n" \
1104887Schin	        "$$(which ksh)" "$$(which ksh93)" ; \
1114887Schin	) ; \
11210898Sroland.mainz@nrubsig.org	if [[ "$$(isalist)" != ~(F)$(LIBSHELLMACH) ]] ; then \
1134887Schin	    printf \
1144887Schin	        "# ISA='%s' not available on this system, skipping tests...\n" \
1158462SApril.Chin@Sun.COM	        "$(LIBSHELLMACH)" ; \
1164887Schin	    exit 0 ; \
1174887Schin	fi ; \
1188462SApril.Chin@Sun.COM	print "# Libraries used:" ; \
1198462SApril.Chin@Sun.COM	LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
1208462SApril.Chin@Sun.COM	LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
1218462SApril.Chin@Sun.COM	LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" \
1228462SApril.Chin@Sun.COM		/usr/bin/ldd "$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" ; \
1238462SApril.Chin@Sun.COM	print "# Running tests:" ; \
1248462SApril.Chin@Sun.COM	redirect 2>&1 ; \
1254887Schin	(supported_locales="$$(/usr/bin/locale -a)" ; \
1264887Schin	for test_lang in $(ON_KSH_TEST_LOCALES) ; do \
1278462SApril.Chin@Sun.COM	    if [[ "$$(egrep "^$${test_lang}\$$" <<< "$${supported_locales}")" == "" ]] ; then \
1284887Schin	        printf \
1294887Schin		    "# Locale '%s' not supported, skipping tests...\n" \
1304887Schin		    "$${test_lang}" ; \
1314887Schin	        continue ; \
1324887Schin	    fi ; \
1334887Schin	    (for test_item in $(ON_KSH_TEST_LIST) ; do \
1348462SApril.Chin@Sun.COM	        [[ "$${test_item}" == "$(TESTSRC)/builtins.sh" || \
135*12068SRoger.Faulkner@Oracle.COM	           "$${test_item}" == "$(TESTSRC)/glob.sh" || \
1368462SApril.Chin@Sun.COM	           "$${test_item}" == "$(TESTSRC)/options.sh" ]] || \
1374887Schin		   $(ON_KSH_TEST_IGNORE_TESTFAILURE) && \
1384887Schin		   set +o errexit ; \
1398462SApril.Chin@Sun.COM		   for mode in 'plain_script:-s' 'compiled_script:-c' ; do \
1408462SApril.Chin@Sun.COM		        printf \
1418462SApril.Chin@Sun.COM			    "## Running %s test: LANG='%s' script='%s', mode='%s'\n" \
1428462SApril.Chin@Sun.COM			    "$(LIBSHELLMACH)/ksh" \
1438462SApril.Chin@Sun.COM			    "$${test_lang}" \
1448462SApril.Chin@Sun.COM			    "$$(basename "$${test_item}")" \
1458462SApril.Chin@Sun.COM			    "$${mode%:*}"; \
1468462SApril.Chin@Sun.COM			( \
14710898Sroland.mainz@nrubsig.org			    ulimit -s 65536 ; \
1488462SApril.Chin@Sun.COM		            test_output="$$( ( \
1498462SApril.Chin@Sun.COM		        	export \
1508462SApril.Chin@Sun.COM		        	    SHELL="$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" \
1518462SApril.Chin@Sun.COM		        	    LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
1528462SApril.Chin@Sun.COM		        	    LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
1538462SApril.Chin@Sun.COM		        	    LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" ; \
1548462SApril.Chin@Sun.COM		        	"$${SHELL}" "$(TESTSRC)/shtests" -t "$${mode#*:}" \
1558462SApril.Chin@Sun.COM		        	    LD_LIBRARY_PATH_64="$${LD_LIBRARY_PATH_64}" \
1568462SApril.Chin@Sun.COM		        	    LD_LIBRARY_PATH_32="$${LD_LIBRARY_PATH_32}" \
1578462SApril.Chin@Sun.COM		        	    LD_LIBRARY_PATH="$${LD_LIBRARY_PATH}" \
1588462SApril.Chin@Sun.COM		        	    SHELL="$${SHELL}" \
1598462SApril.Chin@Sun.COM		        	    LANG="$${test_lang}" \
1608462SApril.Chin@Sun.COM		        	    LC_ALL="$${test_lang}" \
161*12068SRoger.Faulkner@Oracle.COM				    VMALLOC_OPTIONS=abort \
1628462SApril.Chin@Sun.COM				    SHCOMP="$(ROOTBIN)/shcomp" \
1638462SApril.Chin@Sun.COM		        	      "$${test_item}" \
1648462SApril.Chin@Sun.COM		            ) 2>&1 | while read ; do \
1658462SApril.Chin@Sun.COM			                 printf "#\t%s\n" "$${REPLY}" ; \
1668462SApril.Chin@Sun.COM				     done | tee /dev/stderr)" ; \
1678462SApril.Chin@Sun.COM			    [[ "$${test_output}" == ~(E)test.*passed\ \[\ [[:digit:]]*\ test.*\ 0\ errors\ \] ]] || \
1688462SApril.Chin@Sun.COM				      (print "##--------> test failed" ; exit 1) \
1698462SApril.Chin@Sun.COM			) ; \
1708462SApril.Chin@Sun.COM		   done ; \
1718462SApril.Chin@Sun.COM		   set -o errexit ; \
1724887Schin	    done) ; \
1734887Schin	done)
174