about summary refs log tree commit diff
path: root/localedata
diff options
context:
space:
mode:
authorJoseph Myers <joseph@codesourcery.com>2014-06-06 22:19:27 +0000
committerJoseph Myers <joseph@codesourcery.com>2014-06-06 22:19:27 +0000
commit8540f6d2a74fe9d67440535ebbcfa252180a3172 (patch)
tree8c82c4e25cc9e66a958846f33b49a1fcdcacf743 /localedata
parented36bfa18faf9be457575568e64b8409e46caa22 (diff)
downloadglibc-8540f6d2a74fe9d67440535ebbcfa252180a3172.tar.gz
glibc-8540f6d2a74fe9d67440535ebbcfa252180a3172.tar.xz
glibc-8540f6d2a74fe9d67440535ebbcfa252180a3172.zip
Don't require test wrappers to preserve environment variables, use more consistent environment.
One wart in the original support for test wrappers for cross testing,
as noted in
<https://sourceware.org/ml/libc-alpha/2012-10/msg00722.html>, is the
requirement for test wrappers to pass a poorly-defined set of
environment variables from the build system to the system running the
glibc under test.  Although some variables are passed explicitly via
$(test-wrapper-env), including LD_* variables that simply can't be
passed implicitly because of the side effects they'd have on the build
system's dynamic linker, others are passed implicitly, including
variables such as GCONV_PATH and LOCPATH that could potentially affect
the build system's libc (so effectively relying on any such effects
not breaking the wrappers).  In addition, the code in
cross-test-ssh.sh for preserving environment variables is fragile (it
depends on how bash formats a list of exported variables, and could
well break for multi-line variable definitions where the contents
contain things looking like other variable definitions).

This patch moves to explicitly passing environment variables via
$(test-wrapper-env).  Makefile variables that previously used
$(test-wrapper) are split up into -before-env and -after-env parts
that can be passed separately to the various .sh files used in
testing, so those files can then insert environment settings between
the two parts.

The common default environment settings in make-test-out are made into
a separate makefile variable that can also be passed to scripts,
rather than many scripts duplicating those settings (for testing an
installed glibc, it is desirable to have the GCONV_PATH setting on
just one place, so just that one place needs to support it pointing to
an installed sysroot instead of the build tree).  The default settings
are included in the variables such as $(test-program-prefix), so that
if tests do not need any non-default settings they can continue to use
single variables rather than the split-up variables.

Although this patch cleans up LC_ALL=C settings (that being part of
the common defaults), various LANG=C and LANGUAGE=C settings remain.
Those are generally unnecessary and I propose a subsequent cleanup to
remove them.  LC_ALL takes precedence over LANG, and while LANGUAGE
takes precedence over LC_ALL, it only does so for settings other than
LC_ALL=C.  So LC_ALL=C on its own is sufficient to ensure the C
locale, and anything that gets LC_ALL=C does not need the other
settings.

While preparing this patch I noticed some tests with .sh files that
appeared to do nothing beyond what the generic makefile support for
tests can do (localedata/tst-wctype.sh - the makefiles support -ENV
variables and .input files - and localedata/tst-mbswcs.sh - just runs
five tests that could be run individually from the makefile).  So I
propose another subsequent cleanup to move those to using the generic
support instead of special .sh files.

Tested x86_64 (native) and powerpc32 (cross).

	* Makeconfig (run-program-env): New variable.
	(run-program-prefix-before-env): Likewise.
	(run-program-prefix-after-env): Likewise.
	(run-program-prefix): Define in terms of new variables.
	(built-program-cmd-before-env): New variable.
	(built-program-cmd-after-env): Likewise.
	(built-program-cmd): Define in terms of new variables.
	(test-program-prefix-before-env): New variable.
	(test-program-prefix-after-env): Likewise.
	(test-program-prefix): Define in terms of new variables.
	(test-program-cmd-before-env): New variable.
	(test-program-cmd-after-env): Likewise.
	(test-program-cmd): Define in terms of new variables.
	* Rules (make-test-out): Use $(run-program-env).
	* scripts/cross-test-ssh.sh (env_blacklist): Remove variable.
	(help): Do not mention environment variables.  Mention
	--timeoutfactor option.
	(timeoutfactor): New variable.
	(blacklist_exports): Remove function.
	(exports): Remove variable.
	(command): Do not include ${exports}.
	* manual/install.texi (Configuring and compiling): Do not mention
	test wrappers preserving environment variables.  Mention that last
	assignment to a variable must take precedence.
	* INSTALL: Regenerated.
	* benchtests/Makefile (run-bench): Use $(run-program-env).
	* catgets/Makefile ($(objpfx)test1.cat): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)test2.cat): Do not specify environment variables
	explicitly.
	($(objpfx)de/libc.cat): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)test-gencat.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)sample.SJIS.cat): Do not specify environment variables
	explicitly.
	* catgets/test-gencat.sh: Use test_program_cmd_before_env,
	run_program_env and test_program_cmd_after_env arguments.
	* elf/Makefile ($(objpfx)tst-pathopt.out): Use $(run-program-env).
	* elf/tst-pathopt.sh: Use run_program_env argument.
	* iconvdata/Makefile ($(objpfx)iconv-test.out): Use
	$(test-wrapper-env) and $(run-program-env).
	* iconvdata/run-iconv-test.sh: Use test_wrapper_env and
	run_program_env arguments.
	* iconvdata/tst-table.sh: Do not set GCONV_PATH explicitly.
	* intl/Makefile ($(objpfx)tst-gettext.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-gettext2.out): Likewise.
	* intl/tst-gettext.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* intl/tst-gettext2.sh: Likewise.
	* intl/tst-gettext4.sh: Do not set environment variables
	explicitly.
	* intl/tst-gettext6.sh: Likewise.
	* intl/tst-translit.sh: Likewise.
	* malloc/Makefile ($(objpfx)tst-mtrace.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* malloc/tst-mtrace.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* math/Makefile (run-regen-ulps): Use $(run-program-env).
	* nptl/Makefile ($(objpfx)tst-tls6.out): Use $(run-program-env).
	* nptl/tst-tls6.sh: Use run_program_env argument.  Set LANG=C
	explicitly with each use of ${test_wrapper_env}.
	* posix/Makefile ($(objpfx)wordexp-tst.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* posix/tst-getconf.sh: Do not set environment variables
	explicitly.
	* posix/wordexp-tst.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* stdio-common/tst-printf.sh: Do not set environment variables
	explicitly.
	* stdlib/Makefile ($(objpfx)tst-fmtmsg.out): Use
	$(test-program-prefix-before-env), $(run-program-env) and
	$(test-program-prefix-after-env).
	* stdlib/tst-fmtmsg.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	Split $test calls into $test_pre and $test.
	* timezone/Makefile (build-testdata): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).

localedata/ChangeLog:
	* Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
	$(built-program-cmd-before-env), $(run-program-env) and
	$(built-program-cmd-after-env).
	($(objpfx)sort-test.out): Use $(test-program-prefix-before-env),
	$(run-program-env) and $(test-program-prefix-after-env).
	($(objpfx)tst-fmon.out): Use $(run-program-prefix-before-env),
	$(run-program-env) and $(run-program-prefix-after-env).
	($(objpfx)tst-locale.out): Use $(built-program-cmd-before-env),
	$(run-program-env) and $(built-program-cmd-after-env).
	($(objpfx)tst-trans.out): Use $(run-program-prefix-before-env),
	$(run-program-env), $(run-program-prefix-after-env),
	$(test-program-prefix-before-env) and
	$(test-program-prefix-after-env).
	($(objpfx)tst-ctype.out): Use $(test-program-cmd-before-env),
	$(run-program-env) and $(test-program-cmd-after-env).
	($(objpfx)tst-wctype.out): Likewise.
	($(objpfx)tst-langinfo.out): Likewise.
	($(objpfx)tst-langinfo-static.out): Likewise.
	* gen-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* sort-test.sh: Use test_program_prefix_before_env,
	run_program_env and test_program_prefix_after_env arguments.
	* tst-ctype.sh: Use tst_ctype_before_env, run_program_env and
	tst_ctype_after_env arguments.
	* tst-fmon.sh: Use run_program_prefix_before_env, run_program_env
	and run_program_prefix_after_env arguments.
	* tst-langinfo.sh: Use tst_langinfo_before_env, run_program_env
	and tst_langinfo_after_env arguments.
	* tst-locale.sh: Use localedef_before_env, run_program_env and
	localedef_after_env arguments.
	* tst-mbswcs.sh: Do not set environment variables explicitly.
	* tst-numeric.sh: Likewise.
	* tst-rpmatch.sh: Likewise.
	* tst-trans.sh: Use run_program_prefix_before_env,
	run_program_env, run_program_prefix_after_env,
	test_program_prefix_before_env and test_program_prefix_after_env
	arguments.
	* tst-wctype.sh: Use tst_wctype_before_env, run_program_env and
	tst_wctype_after_env arguments.
Diffstat (limited to 'localedata')
-rw-r--r--localedata/ChangeLog42
-rw-r--r--localedata/Makefile33
-rw-r--r--localedata/gen-locale.sh10
-rw-r--r--localedata/sort-test.sh14
-rwxr-xr-xlocaledata/tst-ctype.sh9
-rwxr-xr-xlocaledata/tst-fmon.sh17
-rwxr-xr-xlocaledata/tst-langinfo.sh9
-rwxr-xr-xlocaledata/tst-locale.sh11
-rwxr-xr-xlocaledata/tst-mbswcs.sh5
-rw-r--r--localedata/tst-numeric.sh4
-rwxr-xr-xlocaledata/tst-rpmatch.sh2
-rwxr-xr-xlocaledata/tst-trans.sh18
-rwxr-xr-xlocaledata/tst-wctype.sh9
13 files changed, 127 insertions, 56 deletions
diff --git a/localedata/ChangeLog b/localedata/ChangeLog
index 134af04c99..7d91d38314 100644
--- a/localedata/ChangeLog
+++ b/localedata/ChangeLog
@@ -1,3 +1,45 @@
+2014-06-06  Joseph Myers  <joseph@codesourcery.com>
+
+	* Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
+	$(built-program-cmd-before-env), $(run-program-env) and
+	$(built-program-cmd-after-env).
+	($(objpfx)sort-test.out): Use $(test-program-prefix-before-env),
+	$(run-program-env) and $(test-program-prefix-after-env).
+	($(objpfx)tst-fmon.out): Use $(run-program-prefix-before-env),
+	$(run-program-env) and $(run-program-prefix-after-env).
+	($(objpfx)tst-locale.out): Use $(built-program-cmd-before-env),
+	$(run-program-env) and $(built-program-cmd-after-env).
+	($(objpfx)tst-trans.out): Use $(run-program-prefix-before-env),
+	$(run-program-env), $(run-program-prefix-after-env),
+	$(test-program-prefix-before-env) and
+	$(test-program-prefix-after-env).
+	($(objpfx)tst-ctype.out): Use $(test-program-cmd-before-env),
+	$(run-program-env) and $(test-program-cmd-after-env).
+	($(objpfx)tst-wctype.out): Likewise.
+	($(objpfx)tst-langinfo.out): Likewise.
+	($(objpfx)tst-langinfo-static.out): Likewise.
+	* gen-locale.sh: Use localedef_before_env, run_program_env and
+	localedef_after_env arguments.
+	* sort-test.sh: Use test_program_prefix_before_env,
+	run_program_env and test_program_prefix_after_env arguments.
+	* tst-ctype.sh: Use tst_ctype_before_env, run_program_env and
+	tst_ctype_after_env arguments.
+	* tst-fmon.sh: Use run_program_prefix_before_env, run_program_env
+	and run_program_prefix_after_env arguments.
+	* tst-langinfo.sh: Use tst_langinfo_before_env, run_program_env
+	and tst_langinfo_after_env arguments.
+	* tst-locale.sh: Use localedef_before_env, run_program_env and
+	localedef_after_env arguments.
+	* tst-mbswcs.sh: Do not set environment variables explicitly.
+	* tst-numeric.sh: Likewise.
+	* tst-rpmatch.sh: Likewise.
+	* tst-trans.sh: Use run_program_prefix_before_env,
+	run_program_env, run_program_prefix_after_env,
+	test_program_prefix_before_env and test_program_prefix_after_env
+	arguments.
+	* tst-wctype.sh: Use tst_wctype_before_env, run_program_env and
+	tst_wctype_after_env arguments.
+
 2014-06-05  Andreas Schwab  <schwab@suse.de>
 
 	[BZ #16095]
diff --git a/localedata/Makefile b/localedata/Makefile
index 20da00cf16..6dc25244e1 100644
--- a/localedata/Makefile
+++ b/localedata/Makefile
@@ -143,7 +143,9 @@ generated-dirs += $(LOCALES)
 $(addprefix $(objpfx),$(CTYPE_FILES)): %: \
   gen-locale.sh $(common-objpfx)locale/localedef Makefile \
   $(addprefix charmaps/,$(CHARMAPS)) $(addprefix locales/,$(LOCALE_SRCS))
-	@$(SHELL) gen-locale.sh $(common-objpfx) '$(built-program-cmd)' $@; \
+	@$(SHELL) gen-locale.sh $(common-objpfx) \
+		  '$(built-program-cmd-before-env)' '$(run-program-env)' \
+		  '$(built-program-cmd-after-env)' $@; \
 	$(evaluate-test)
 
 $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
@@ -151,14 +153,17 @@ $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
 
 $(objpfx)sort-test.out: sort-test.sh $(objpfx)collate-test $(objpfx)xfrm-test \
 		       $(test-input-data) $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(test-program-prefix)' $(test-input) \
+	$(SHELL) $< $(common-objpfx) '$(test-program-prefix-before-env)' \
+	  '$(run-program-env)' '$(test-program-prefix-after-env)' \
+	  $(test-input) \
 	  > $@; \
 	$(evaluate-test)
 $(objpfx)tst-fmon.out: tst-fmon.sh $(objpfx)tst-fmon tst-fmon.data \
 		       $(objpfx)sort-test.out \
 		       $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(run-program-prefix)' \
-		'$(test-program-prefix)' tst-fmon.data  \
+	$(SHELL) $< $(common-objpfx) '$(run-program-prefix-before-env)' \
+		 '$(run-program-env)' '$(run-program-prefix-after-env)' \
+		 '$(test-program-prefix)' tst-fmon.data \
 	  > $@; \
 	$(evaluate-test)
 $(objpfx)tst-numeric.out: tst-numeric.sh $(objpfx)tst-numeric tst-numeric.data \
@@ -169,7 +174,8 @@ $(objpfx)tst-numeric.out: tst-numeric.sh $(objpfx)tst-numeric tst-numeric.data \
 	$(evaluate-test)
 $(objpfx)tst-locale.out: tst-locale.sh $(common-objpfx)locale/localedef \
 			 $(ld-test-srcs) $(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(built-program-cmd)' > $@; \
+	$(SHELL) $< $(common-objpfx) '$(built-program-cmd-before-env)' \
+		 '$(run-program-env)' '$(built-program-cmd-after-env)' > $@; \
 	$(evaluate-test)
 $(objpfx)tst-rpmatch.out: tst-rpmatch.sh $(objpfx)tst-rpmatch \
 			  $(objpfx)tst-fmon.out \
@@ -178,7 +184,10 @@ $(objpfx)tst-rpmatch.out: tst-rpmatch.sh $(objpfx)tst-rpmatch \
 	$(evaluate-test)
 $(objpfx)tst-trans.out: tst-trans.sh $(objpfx)tst-trans \
 			$(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(run-program-prefix)' '$(test-program-prefix)'; \
+	$(SHELL) $< $(common-objpfx) '$(run-program-prefix-before-env)' \
+		 '$(run-program-env)' '$(run-program-prefix-after-env)' \
+		 '$(test-program-prefix-before-env)' \
+		 '$(test-program-prefix-after-env)'; \
 	$(evaluate-test)
 $(objpfx)tst-mbswcs.out: tst-mbswcs.sh $(objpfx)tst-mbswcs1 \
 			 $(objpfx)tst-mbswcs2 $(objpfx)tst-mbswcs3 \
@@ -189,22 +198,26 @@ $(objpfx)tst-mbswcs.out: tst-mbswcs.sh $(objpfx)tst-mbswcs1 \
 $(objpfx)tst-ctype.out: tst-ctype.sh $(objpfx)tst-ctype \
 			$(objpfx)sort-test.out \
 			$(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)'; \
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
+		 '$(run-program-env)' '$(test-program-cmd-after-env)'; \
 	$(evaluate-test)
 $(objpfx)tst-wctype.out: tst-wctype.sh $(objpfx)tst-wctype \
 			$(objpfx)sort-test.out tst-wctype.input \
 			$(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)'; \
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
+		 '$(run-program-env)' '$(test-program-cmd-after-env)'; \
 	$(evaluate-test)
 $(objpfx)tst-langinfo.out: tst-langinfo.sh $(objpfx)tst-langinfo \
 			$(objpfx)sort-test.out \
 			$(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
+		 '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
 	$(evaluate-test)
 $(objpfx)tst-langinfo-static.out: tst-langinfo.sh $(objpfx)tst-langinfo-static \
 			$(objpfx)sort-test.out \
 			$(addprefix $(objpfx),$(CTYPE_FILES))
-	$(SHELL) $< $(common-objpfx) '$(test-program-cmd)' > $@; \
+	$(SHELL) $< $(common-objpfx) '$(test-program-cmd-before-env)' \
+		 '$(run-program-env)' '$(test-program-cmd-after-env)' > $@; \
 	$(evaluate-test)
 $(objpfx)tst-digits.out: $(objpfx)tst-locale.out
 $(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
diff --git a/localedata/gen-locale.sh b/localedata/gen-locale.sh
index d2fde61e32..151634ba14 100644
--- a/localedata/gen-locale.sh
+++ b/localedata/gen-locale.sh
@@ -20,7 +20,9 @@
 set -e
 
 common_objpfx="$1"; shift
-localedef="$1"; shift
+localedef_before_env="$1"; shift
+run_program_env="$1"; shift
+localedef_after_env="$1"; shift
 locfile="$1"; shift
 
 generate_locale ()
@@ -28,9 +30,9 @@ generate_locale ()
   charmap=$1
   input=$2
   out=$3
-  if I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
-     ${localedef} --quiet -c -f $charmap -i $input \
-		  ${common_objpfx}localedata/$out
+  if ${localedef_before_env} ${run_program_env} I18NPATH=. \
+     ${localedef_after_env} --quiet -c -f $charmap -i $input \
+			    ${common_objpfx}localedata/$out
   then
     # The makefile checks the timestamp of the LC_CTYPE file,
     # but localedef won't have touched it if it was able to
diff --git a/localedata/sort-test.sh b/localedata/sort-test.sh
index 8a7ca89688..e37129a032 100644
--- a/localedata/sort-test.sh
+++ b/localedata/sort-test.sh
@@ -20,7 +20,9 @@
 set -e
 
 common_objpfx=$1; shift
-test_program_prefix=$1; shift
+test_program_prefix_before_env=$1; shift
+run_program_env=$1; shift
+test_program_prefix_after_env=$1; shift
 lang=$*
 
 id=${PPID:-100}
@@ -31,8 +33,9 @@ status=0
 for l in $lang; do
   here=0
   cns=`echo $l | sed 's/\(.*\)[.][^.]*/\1/'`
-  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}/iconvdata \
-   LC_ALL=$l ${test_program_prefix} \
+  ${test_program_prefix_before_env} \
+   ${run_program_env} \
+   LC_ALL=$l ${test_program_prefix_after_env} \
    ${common_objpfx}localedata/collate-test $id < $cns.in \
    > ${common_objpfx}localedata/$cns.out || here=1
   cmp -s $cns.in ${common_objpfx}localedata/$cns.out || here=1
@@ -44,8 +47,9 @@ for l in $lang; do
     status=1
   fi
 
-  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}/iconvdata \
-   LC_ALL=$l ${test_program_prefix} \
+  ${test_program_prefix_before_env} \
+   ${run_program_env} \
+   LC_ALL=$l ${test_program_prefix_after_env} \
    ${common_objpfx}localedata/xfrm-test $id < $cns.in \
    > ${common_objpfx}localedata/$cns.xout || here=1
   cmp -s $cns.in ${common_objpfx}localedata/$cns.xout || here=1
diff --git a/localedata/tst-ctype.sh b/localedata/tst-ctype.sh
index 472f8dc8b0..ae105baaab 100755
--- a/localedata/tst-ctype.sh
+++ b/localedata/tst-ctype.sh
@@ -20,7 +20,9 @@
 set -e
 
 common_objpfx=$1; shift
-tst_ctype=$1; shift
+tst_ctype_before_env=$1; shift
+run_program_env=$1; shift
+tst_ctype_after_env=$1; shift
 status=0
 
 # Run the test programs.
@@ -31,8 +33,9 @@ for loc in C de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 ja_JP.EUC-JP; do
   else
     input=/dev/null
   fi
-  LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-  LC_ALL=$loc ${tst_ctype} < $input \
+  ${tst_ctype_before_env} \
+  ${run_program_env} \
+  LC_ALL=$loc ${tst_ctype_after_env} < $input \
     >> ${common_objpfx}localedata/tst-ctype.out || status=1
 done
 
diff --git a/localedata/tst-fmon.sh b/localedata/tst-fmon.sh
index e68aa96409..7f1b2488a2 100755
--- a/localedata/tst-fmon.sh
+++ b/localedata/tst-fmon.sh
@@ -21,9 +21,11 @@
 set -e
 
 common_objpfx=$1
-run_program_prefix=$2
-test_program_prefix=$3
-datafile=$4
+run_program_prefix_before_env=$2
+run_program_env=$3
+run_program_prefix_after_env=$4
+test_program_prefix=$5
+datafile=$6
 
 here=`pwd`
 
@@ -33,9 +35,10 @@ lang=`sed -e '/^#/d' -e '/^$/d' -e '/^C	/d' -e '/^tstfmon/d' -e 's/^\([^	]*\).*/
 for cns in `cd ./tst-fmon-locales && ls tstfmon_*`; do
     cn=tst-fmon-locales/$cns
     fn=charmaps/ISO-8859-1
-    I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
-    LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
-    ${run_program_prefix} ${common_objpfx}locale/localedef \
+    ${run_program_prefix_before_env} \
+    ${run_program_env} \
+    I18NPATH=. LANGUAGE=C \
+    ${run_program_prefix_after_env} ${common_objpfx}locale/localedef \
     --quiet -i $cn -f $fn ${common_objpfx}localedata/$cns
 done
 
@@ -46,8 +49,6 @@ while IFS="	" read locale format value expect; do
     case "$locale" in '#'*) continue ;; esac
     if [ -n "$format" ]; then
 	expect=`echo "$expect" | sed 's/^\"\(.*\)\"$/\1/'`
-	LOCPATH=${common_objpfx}localedata \
-	GCONV_PATH=${common_objpfx}/iconvdata \
 	${test_program_prefix} ${common_objpfx}localedata/tst-fmon \
 	"$locale" "$format" "$value" "$expect" < /dev/null ||
 	errcode=$?
diff --git a/localedata/tst-langinfo.sh b/localedata/tst-langinfo.sh
index bd489d024f..df5aed3f55 100755
--- a/localedata/tst-langinfo.sh
+++ b/localedata/tst-langinfo.sh
@@ -20,7 +20,9 @@
 set -e
 
 common_objpfx=$1
-tst_langinfo=$2
+tst_langinfo_before_env=$2
+run_program_env=$3
+tst_langinfo_after_env=$4
 
 # Run the test program.
 cat <<"EOF" |
@@ -339,7 +341,8 @@ ja_JP.EUC-JP         NOEXPR      ^([nNnN]|いいえ|イイエ)
 # ja_JP.EUC-JP         CRNCYSTR    JPY
 ja_JP.EUC-JP         CODESET     EUC-JP
 EOF
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-LC_ALL=tt_TT ${tst_langinfo}
+${tst_langinfo_before_env} \
+${run_program_env} \
+LC_ALL=tt_TT ${tst_langinfo_after_env}
 
 exit $?
diff --git a/localedata/tst-locale.sh b/localedata/tst-locale.sh
index b89dc095fa..7c71dcf72c 100755
--- a/localedata/tst-locale.sh
+++ b/localedata/tst-locale.sh
@@ -21,7 +21,9 @@
 set -e
 
 common_objpfx=$1; shift
-localedef=$1; shift
+localedef_before_env=$1; shift
+run_program_env=$1; shift
+localedef_after_env=$1; shift
 
 test_locale ()
 {
@@ -32,9 +34,10 @@ test_locale ()
     if test $rep; then
       rep="--repertoire-map $rep"
     fi
-    I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
-    LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
-    ${localedef} --quiet -c -f $charmap -i $input \
+    ${localedef_before_env} \
+    ${run_program_env} \
+    I18NPATH=. LANGUAGE=C \
+    ${localedef_after_env} --quiet -c -f $charmap -i $input \
       ${rep} ${common_objpfx}localedata/$out
 
     if [ $? -ne 0 ]; then
diff --git a/localedata/tst-mbswcs.sh b/localedata/tst-mbswcs.sh
index 6a70fd7b62..1cfc482307 100755
--- a/localedata/tst-mbswcs.sh
+++ b/localedata/tst-mbswcs.sh
@@ -25,23 +25,18 @@ test_program_prefix=$1; shift
 status=0
 
 # Run the test programs.
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
 ${test_program_prefix} ${common_objpfx}localedata/tst-mbswcs1 \
   > ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
 ${test_program_prefix} ${common_objpfx}localedata/tst-mbswcs2 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
 ${test_program_prefix} ${common_objpfx}localedata/tst-mbswcs3 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
 ${test_program_prefix} ${common_objpfx}localedata/tst-mbswcs4 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
 ${test_program_prefix} ${common_objpfx}localedata/tst-mbswcs5 \
   >> ${common_objpfx}localedata/tst-mbswcs.out || status=1
 
diff --git a/localedata/tst-numeric.sh b/localedata/tst-numeric.sh
index ff797cd9fa..734466e975 100644
--- a/localedata/tst-numeric.sh
+++ b/localedata/tst-numeric.sh
@@ -30,9 +30,7 @@ errcode=0
 while IFS="	" read locale format value expect; do
     case "$locale" in '#'*) continue ;; esac
     if [ -n "$format" ]; then
-	if LOCPATH=${common_objpfx}localedata \
-	    GCONV_PATH=${common_objpfx}/iconvdata \
-	    ${test_program_prefix} ${common_objpfx}localedata/tst-numeric \
+	if ${test_program_prefix} ${common_objpfx}localedata/tst-numeric \
 	    "$locale" "$format" "$value" "$expect" < /dev/null
 	then
 	    echo "Locale: \"${locale}\" Format: \"${format}\"" \
diff --git a/localedata/tst-rpmatch.sh b/localedata/tst-rpmatch.sh
index bdb3b7c269..a0fd9140f2 100755
--- a/localedata/tst-rpmatch.sh
+++ b/localedata/tst-rpmatch.sh
@@ -26,8 +26,6 @@ tst_rpmatch=$2
 rc=0
 while IFS=\& read locale string result dummy; do
     if [ "$locale" != "#" ]; then
-	LOCPATH=${common_objpfx}localedata \
-	GCONV_PATH=${common_objpfx}/iconvdata \
 	${tst_rpmatch} $locale $string $result < /dev/null \
 	|| { echo "$locale $string $result  FAILED"; exit 1; }
     fi
diff --git a/localedata/tst-trans.sh b/localedata/tst-trans.sh
index e82e4f8b63..99190a5623 100755
--- a/localedata/tst-trans.sh
+++ b/localedata/tst-trans.sh
@@ -20,20 +20,26 @@
 set -e
 
 common_objpfx=$1
-run_program_prefix=$2
-test_program_prefix=$3
+run_program_prefix_before_env=$2
+run_program_env=$3
+run_program_prefix_after_env=$4
+test_program_prefix_before_env=$5
+test_program_prefix_after_env=$6
 
 # Generate the necessary locale data.
-I18NPATH=. GCONV_PATH=${common_objpfx}/iconvdata \
-${run_program_prefix} \
+${run_program_prefix_before_env} \
+${run_program_env} \
+I18NPATH=. \
+${run_program_prefix_after_env} \
 ${common_objpfx}locale/localedef --quiet \
 -i tests/trans.def -f charmaps/ISO-8859-1 \
 ${common_objpfx}localedata/tt_TT ||
 exit 1
 
 # Run the test program.
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-LC_ALL=tt_TT ${test_program_prefix} \
+${test_program_prefix_before_env} \
+${run_program_env} \
+LC_ALL=tt_TT ${test_program_prefix_after_env} \
 ${common_objpfx}localedata/tst-trans > ${common_objpfx}localedata/tst-trans.out
 
 exit $?
diff --git a/localedata/tst-wctype.sh b/localedata/tst-wctype.sh
index 31d57bc514..53b88b50b6 100755
--- a/localedata/tst-wctype.sh
+++ b/localedata/tst-wctype.sh
@@ -20,11 +20,14 @@
 set -e
 
 common_objpfx=$1
-tst_wctype=$2
+tst_wctype_before_env=$2
+run_program_env=$3
+tst_wctype_after_env=$4
 
 # Run the test program.
-LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-LC_ALL=ja_JP.EUC-JP ${tst_wctype} < tst-wctype.input \
+${tst_wctype_before_env} \
+${run_program_env} \
+LC_ALL=ja_JP.EUC-JP ${tst_wctype_after_env} < tst-wctype.input \
     > ${common_objpfx}localedata/tst-wctype.out
 
 exit $?