Makefile.testshell revision 7c2fbfb345896881c631598ee3852ce9ce33fb07
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
# Run the ksh93 minimum set of tests
#
#
# Notes:
# - "builtins.sh" may fail in some locales like this:
# -- snip --
# ## Running ksh test: LANG='zh_TW.EUC' script='builtins.sh'
# builtins.sh[274]: printf "%T" now
# -- snip --
#
# - "options.sh" may currently fail in some locales with:
# -- snip --
# 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'
# 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'
# -- snip --
# This may be simply a different sort order or a bug in the test suite.
# Currently under investigation.
#
# - These tests need a working system clock, otherwise they'll bite you.
#
# - The current list of locales was mainly composed to cover various encodings
# and all important markets based on suggestions by Sun's i18n team.
#
# - More locales should be tested here (via ON_KSH_TEST_LOCALES below).
# Locales like "ru_RU.KOI8-R","de_DE.UTF-8", "is_IS.ISO8859-1",
# "is_IS.UTF-8" and "nl_BE.ISO8859-15" are on our wishlist - but
# that is getting little bit more compliciated because these locales use
# ',' as decimal delimter. The best solution may be to wait for ksh93
# being integrated into OS/Net and then change the test sequence to
# use ksh93's associative/compound variables (this may require a flag
# day... ;-( ).
#
# - Due to the timing sensitivity of some of the tests, these tests should
# be run on a quiet system with no other activity.
#
TESTSRC= $(LIBSHELLBASE)/common/tests
# ON_KSH_TEST_LOCALES can be overridden via
# $ export ON_KSH_TEST_LOCALES=<value> # before $ make install #
ON_KSH_TEST_LOCALES = \
C \
en_US.UTF-8 en_US en_US.ISO8859-15@euro \
he_IL.UTF-8 \
hi_IN.UTF-8 \
ja ja_JP.PCK ja_JP.UTF-8 ja_JP.eucJP \
ko_KR.UTF-8 ko_KR.EUC \
th_TH.TIS620 \
zh_CN.EUC zh_CN.GBK \
zh_CN.GB18030 zh_CN.GB18030@pinyin zh_CN.GB18030@radical zh_CN.GB18030@stroke \
zh_CN.UTF-8 zh_CN.UTF-8@pinyin zh_CN.UTF-8@radical zh_CN.UTF-8@stroke \
zh_HK.BIG5HK \
zh_TW.BIG5 zh_TW.EUC zh_TW.UTF-8
# ON_KSH_TEST_LIST can be overridden via
# $ export ON_KSH_TEST_LIST=<value> # before $ make install #
ON_KSH_TEST_LIST = $(TESTSRC)/*.sh
# Flag to control whether we should make test failures non-fatal
ON_KSH_TEST_IGNORE_TESTFAILURE=false
# We must wait for other things in this subdir to finish before running
# the test suite, otherwise we may run into trouble that this activity
# may disturb the test suite run (resulting in weird "heisenbug"-like
# test failures).
testshell: $(PROG)
@ \
builtin basename ; \
print '# NOTE: Make sure your binaries in ROOT match your kernel!' ; \
( \
set +o errexit ; \
export PATH="$(SRC)/cmd/ksh/$(LIBSHELLMACH):/bin:/usr/bin" ; \
printf "# which ksh='%s', ksh93='%s'\n" \
"$$(which ksh)" "$$(which ksh93)" ; \
) ; \
if [[ "$$(isalist)" != ~(E)$(LIBSHELLMACH) ]] ; then \
printf \
"# ISA='%s' not available on this system, skipping tests...\n" \
"$(LIBSHELLMACH)" ; \
exit 0 ; \
fi ; \
print "# Libraries used:" ; \
LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" \
/usr/bin/ldd "$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" ; \
print "# Running tests:" ; \
redirect 2>&1 ; \
(supported_locales="$$(/usr/bin/locale -a)" ; \
for test_lang in $(ON_KSH_TEST_LOCALES) ; do \
if [[ "$$(egrep "^$${test_lang}\$$" <<< "$${supported_locales}")" == "" ]] ; then \
printf \
"# Locale '%s' not supported, skipping tests...\n" \
"$${test_lang}" ; \
continue ; \
fi ; \
(for test_item in $(ON_KSH_TEST_LIST) ; do \
[[ "$${test_item}" == "$(TESTSRC)/builtins.sh" || \
"$${test_item}" == "$(TESTSRC)/options.sh" ]] || \
$(ON_KSH_TEST_IGNORE_TESTFAILURE) && \
set +o errexit ; \
for mode in 'plain_script:-s' 'compiled_script:-c' ; do \
printf \
"## Running %s test: LANG='%s' script='%s', mode='%s'\n" \
"$(LIBSHELLMACH)/ksh" \
"$${test_lang}" \
"$$(basename "$${test_item}")" \
"$${mode%:*}"; \
( \
test_output="$$( ( \
export \
SHELL="$(SRC)/cmd/ksh/$(LIBSHELLMACH)/ksh" \
LD_LIBRARY_PATH_64="$(ROOTLIB64)/" \
LD_LIBRARY_PATH_32="$(ROOTLIB)/" \
LD_LIBRARY_PATH="$(ROOTLIB64)/:$(ROOTLIB)/" ; \
"$${SHELL}" "$(TESTSRC)/shtests" -t "$${mode#*:}" \
LD_LIBRARY_PATH_64="$${LD_LIBRARY_PATH_64}" \
LD_LIBRARY_PATH_32="$${LD_LIBRARY_PATH_32}" \
LD_LIBRARY_PATH="$${LD_LIBRARY_PATH}" \
SHELL="$${SHELL}" \
LANG="$${test_lang}" \
LC_ALL="$${test_lang}" \
VMDEBUG=a \
SHCOMP="$(ROOTBIN)/shcomp" \
"$${test_item}" \
) 2>&1 | while read ; do \
printf "#\t%s\n" "$${REPLY}" ; \
done | tee /dev/stderr)" ; \
[[ "$${test_output}" == ~(E)test.*passed\ \[\ [[:digit:]]*\ test.*\ 0\ errors\ \] ]] || \
(print "##--------> test failed" ; exit 1) \
) ; \
done ; \
set -o errexit ; \
done) ; \
done)