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