From 36d32af6da4f910954e60190f850b55c3faeeaf9 Mon Sep 17 00:00:00 2001 From: Ichiroh Takiguchi <33543753+takiguc@users.noreply.github.com> Date: Wed, 8 Jun 2022 02:48:24 +0900 Subject: [PATCH] MBCS testcases may not work as expected if LC_ALL is defined or fallback encoding is UTF-8 (#3716) --- functional/MBCS_Tests/StAX/resultCheck.pl | 12 ++++++++++-- functional/MBCS_Tests/i18n/test.pl | 12 ++++++++++-- functional/MBCS_Tests/locale_matching/test.pl | 12 ++++++++++-- functional/MBCS_Tests/nio/test.sh | 4 +--- functional/MBCS_Tests/tools/check_env_unix.sh | 9 +++++++++ 5 files changed, 40 insertions(+), 9 deletions(-) diff --git a/functional/MBCS_Tests/StAX/resultCheck.pl b/functional/MBCS_Tests/StAX/resultCheck.pl index 0eecb9f13b..000cae685b 100755 --- a/functional/MBCS_Tests/StAX/resultCheck.pl +++ b/functional/MBCS_Tests/StAX/resultCheck.pl @@ -25,9 +25,17 @@ $OS=$^O; #OS name chomp($OS); -$SYSENC=`locale charmap`; +undef $ENV{'LC_ALL'}; +$SYSENC=`locale charmap 2>&1`; +$lang = $ENV{'LANG'}; +if (index($SYSENC," ") > -1) { + for($i = 0; $i < 4; $i+=1) { + ok(1 == 1,"skip"); + } + print "SKIPPED! $lang is not supported.\n"; + exit(0); +} chomp($SYSENC); -$lang = $ENV{LANG}; $lang =~ s/\..*$//; $FULLLANG = $OS."_".$lang.".".$SYSENC; undef %LOC; diff --git a/functional/MBCS_Tests/i18n/test.pl b/functional/MBCS_Tests/i18n/test.pl index c958da2a31..eb5ab5d00f 100755 --- a/functional/MBCS_Tests/i18n/test.pl +++ b/functional/MBCS_Tests/i18n/test.pl @@ -20,9 +20,17 @@ $OS=$^O; #OS name chomp($OS); -$SYSENC=`locale charmap`; +undef $ENV{'LC_ALL'}; +$SYSENC=`locale charmap 2>&1`; +$lang = $ENV{'LANG'}; +if (index($SYSENC," ") > -1) { + for($i = 0; $i < 3; $i+=1) { + ok(1 == 1,"skip"); + } + print "SKIPPED! $lang is not supported.\n"; + exit(0); +} chomp($SYSENC); -$lang = $ENV{LANG}; $i = index($lang,"."); if ($i == -1) { $i = length($lang); diff --git a/functional/MBCS_Tests/locale_matching/test.pl b/functional/MBCS_Tests/locale_matching/test.pl index a8181e06a9..ba2d8d5d07 100755 --- a/functional/MBCS_Tests/locale_matching/test.pl +++ b/functional/MBCS_Tests/locale_matching/test.pl @@ -22,9 +22,17 @@ $OS=$^O; #OS name chomp($OS); -$SYSENC=`locale charmap`; +undef $ENV{'LC_ALL'}; +$SYSENC=`locale charmap 2>&1`; +$lang = $ENV{'LANG'}; +if (index($SYSENC," ") > -1) { + for($i = 0; $i < 5; $i+=1) { + ok(1 == 1,"skip"); + } + print "SKIPPED! $lang is not supported.\n"; + exit(0); +} chomp($SYSENC); -$lang = $ENV{LANG}; $i = index($lang,"."); if ($i == -1) { $i = length($lang); diff --git a/functional/MBCS_Tests/nio/test.sh b/functional/MBCS_Tests/nio/test.sh index 9c25de2f37..f7fced3772 100755 --- a/functional/MBCS_Tests/nio/test.sh +++ b/functional/MBCS_Tests/nio/test.sh @@ -19,8 +19,7 @@ FULLLANG=${OS}_${LANG%.*}.${LOC} BASE=`dirname $0` export CLASSPATH=${BASE}/nio.jar -CHARMAP=${FULLLANG} -SOURCE="${CHARMAP}.txt" +. ${BASE}/check_env_unix.sh if [ "$FULLLANG" = "AIX_Zh_TW.big5" ]; then LOC="IBM-950"; @@ -30,7 +29,6 @@ fi echo "system code page is " ${LOC} -. ${BASE}/check_env_unix.sh echo "invoking ReadWriteTest..." ${JAVA_BIN}/java ReadWriteTest ${BASE}/expected_${FULLLANG}.txt ${LOC} converted.txt ${LOC} > log 2>&1 diff ${BASE}/expected_${FULLLANG}.txt ./converted.txt > diff.txt 2>&1 diff --git a/functional/MBCS_Tests/tools/check_env_unix.sh b/functional/MBCS_Tests/tools/check_env_unix.sh index 7f430ee54c..2cf20801cd 100755 --- a/functional/MBCS_Tests/tools/check_env_unix.sh +++ b/functional/MBCS_Tests/tools/check_env_unix.sh @@ -33,6 +33,15 @@ if [ "x$JAVA_BIN" = "x" ]; then fi fi +unset LC_ALL +OS=`uname` +LOC=`locale charmap 2>&1` +if [ "${LOC}" != "${LOC%% *}" ]; then + FULLLANG=${LANG} + showMessage +fi +FULLLANG=${OS}_${LANG%.*}.${LOC} + case "${FULLLANG}" in "AIX_Ja_JP.IBM-943"|\ "AIX_ja_JP.IBM-eucJP"|\