[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patches] cross-testing instructions



Mark Mitchell <mark@xxxxxxxxxxxxxxxx> writes:
> Jim Blandy wrote:
>
>> In the mean time, comments on this are welcome.  It's written for
>> people who are familiar with GLIBC and how to build it, but not
>> familiar with EGLIBC; if you see something which would be confusing or
>> unclear to such a reader, I would love to hear about it.
>
> I think these are very good instructions!
>
> Now, we just need that patch. :-)

Okay.  This one seems to go through all the tests in the expected
way.  With this patch, my expected failures are:

Timer-related issues, known problems with the simulator I'm using
(qemu):

nptl/tst-mutex5
nptl/tst-mutex5a
rt/tst-{cpu{clock{1,2},timer{1,2,3}},clock2}

Known failures, due to ARM floating point quirks:

math/{test-{fenv,float,double,ifloat,idouble},bug-next{after,toward}}

Listed as a known failure in CodeSourcery's files, for reasons I don't
know:

touch posix/globtest.out
touch login/tst-utmp.out
touch login/tst-utmpx.out


The only revision I've needed to make to the instructions are to note
that the glibc source tree must be shared between the build and host
systems, as well as the build tree.  (I don't actually know that this
true, but I'd be very surprised if it weren't.)


It's pretty big.

2007-02-02  Jim Blandy	<jimb@xxxxxxxxxxxxxxxx>

	Add support for cross-testing.

	Remove Make conditionals that disable running tests or generating
	test input files when cross-compiling.
	* Rules: Disable conditionals.
	* stdlib/Makefile: Same.
	* libio/Makefile: Same.
	* intl/Makefile: Same.
	* iconvdata/Makefile: Same.
	* localedata/Makefile: Same.
	* catgets/Makefile: Same.
	* misc/Makefile: Same.
	* posix/Makefile: Same.
	* string/Makefile: Same.
	* stdio-common/Makefile: Same.
	* resolv/Makefile: Same.
	* iconv/Makefile: Same.
	* grp/Makefile: Same.
	* elf/Makefile: Same.
	* malloc/Makefile: Same.
	* io/Makefile: Same.

	Where tests run binaries, have them use cross-test-wrapper, if
	set.
	* Makeconfig (run-program-prefix): Split this into two pieces:
	(run-via-rtld-prefix): Prefix to run something via the dynamic linker.
	(run-program-prefix): Prefix to run something via the
	cross-testing wrapper and the dynamic linker.
	(built-program-command): Run the rule's second dependency, using the
	cross-test-wrapper and dynamic linker.
	(local-built-program-cmd): Like built-program-command, but don't
	use cross-test-wrapper.
	* intl/Makefile: Pass cross-test-wrapper to scripts.
	* intl/tst-codeset.sh, intl/tst-gettext.sh, intl/tst-gettext2.sh:
	* intl/tst-gettext3.sh, intl/tst-translit.sh: Expect and use wrapper.
	* iconvdata/Makefile: Pass cross-test-wrapper to scripts.
	* iconvdata/run-iconv-test.sh, iconvdata/tst-table.sh:
	* iconvdata/tst-tables.sh: Expect and use wrapper.
	* posix/Makefile: Pass cross-test-wrapper to scripts.  Pass
	local-built-program-command to tests which run subprograms.
	* posix/tst-getconf.sh, posix/globtest.sh:
	* posix/workexp-tst.sh: Expect and use wrapper.
	* grp/Makefile: Pass cross-test-wrapper to scripts.
	* grp/tst-fgetgrent.sh: Expect and use wrapper.
	* elf/Makefile: Pass cross-test-wrapper to scripts.  Use
	cross-test-wrapper to run binaries.  Pass
	local-built-program-command to tests which run subprograms.
	* elf/tst-pathopt.sh: Expect and use wrapper.
	* malloc/Makefile: Pass cross-test-wrapper to scripts.
	* malloc/tst-mtrace.sh: Expect and use wrapper.
	* io/Makefile: Pass cross-test-wrapper to scripts.
	* io/ftwtest-sh: Expect and use wrapper.
	* nptl/Makefile: Pass cross-test-wrapper to scripts.  Pass
	local-built-program-command to tests which run subprograms.
	* nptl/tst-tls6.sh: Expect and use wrapper.
	* rt/makefile (tst-mqueue7-ARGS): Pass local-built-program-command.

	Make sure cross-testing wrappers don't steal input from test
	script loops.

	* iconvdata/run-iconv-test.sh: Use non-stdin file descriptor for
	while loop input.
	* iconvdata/tst-tables.sh: Redirect loop body input from /dev/null.
	* localedata/tst-rpmatch.sh, localedata/tst-fmon.sh: Same.
	* localedata/tst-numeric.sh: Same.
	* posix/tst-getconf.sh: Same.

	* localedata/tst-wctype.sh: Take the command to run as an
	argument, as passed by the Makefile, not run_program_prefix.

	* io/Makefile ($(objpfx)/ftwtest.out): If cross-testing, use build
	tree for temporary directory.

	* localedata/Makefile ($(addprefix $(objpfx),$(CTYPE_FILES))): Use
	cross-localedef program, if specified.

	* scripts/cross-test-ssh.sh: New file: sample cross-test wrapper.

Index: stdlib/Makefile
===================================================================
--- stdlib/Makefile	(revision 161775)
+++ stdlib/Makefile	(working copy)
@@ -124,9 +124,9 @@
 # Run a test on the header files we use.
 tests: $(objpfx)isomac.out
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 tests: $(objpfx)tst-fmtmsg.out
-endif
+# eglibc: endif
 
 $(objpfx)isomac.out: $(objpfx)isomac
 	$(dir $<)$(notdir $<) '$(CC)'  \
Index: scripts/cross-test-ssh.sh
===================================================================
--- scripts/cross-test-ssh.sh	(revision 0)
+++ scripts/cross-test-ssh.sh	(revision 0)
@@ -0,0 +1,116 @@
+#!/usr/bin/env bash
+# usage: cross-test-ssh.sh [--ssh SSH] HOST COMMAND ...
+# Run with --help flag to get more detailed help.
+
+progname="$(basename $0)"
+env_blacklist='HOME LOGNAME MAIL PATH SHELL SHLVL SSH_CLIENT SSH_CONNECTION USER'
+
+usage="usage: ${progname} [--ssh SSH] HOST COMMAND ..."
+help="Run an EGLIBC test COMMAND on the remote machine HOST, via ssh,
+passing environment variables, preserving the current working directory,
+and respecting quoting.
+
+If the '--ssh SSH' flag is present, use SSH as the SSH command,
+instead of ordinary 'ssh'.
+
+To use this to run EGLIBC tests, invoke the tests as follows:
+
+  $ make cross-test-wrapper='ABSPATH/cross-test-ssh.sh HOST' tests
+
+where ABSPATH is the absolute path to this script, and HOST is the
+name of the machine to connect to via ssh.
+
+HOST and the build machines (on which 'make check' is being run) must
+share a filesystem; all files needed by the tests must be visible at
+the same paths on both machines.
+
+${progname} runs COMMAND in the same directory on the HOST that
+${progname} itself is run in on the build machine.
+
+The command and arguments are passed to the remote host in a way that
+avoids any further shell substitution or expansion, on the assumption
+that the shell on the build machine has already done them
+appropriately.
+
+${progname} propagates the values all environment variables through to
+the remote target, except the following:
+${env_blacklist}"
+
+ssh='ssh'
+while true; do
+    case "$1" in
+
+        "--ssh")
+            shift; ssh="$1"
+            ;;
+
+        "--help")
+            echo "$usage"
+            echo "$help"
+            exit 0
+            ;;
+
+        *)
+            break
+            ;;
+    esac
+    shift
+done
+
+if [ $# -lt 1 ]; then
+    echo "$usage" >&2
+    echo "Type '${progname} --help' for more detailed help." >&2
+    exit 1
+fi
+
+host="$1"; shift
+
+# Return all input as a properly quoted Bourne shell string.
+bourne_quote () {
+    echo -n '"'
+    sed -n \
+        -e '1h' \
+        -e '2,$H' \
+        -e '${g
+              s/["$\`]/\\&/g
+              p
+             }'
+    echo -n '"'
+}
+
+# Echo all lines of input except those starting with 'export VAR=',
+# where VAR is a blacklisted variable.  Turn lines starting with
+# 'declare -x VAR=' into the analogous export commands, before
+# blacklisting.
+blacklist_exports () {
+    local pat
+    pat="$(for var in ${env_blacklist}; do
+             echo "^export ${var}="
+           done)"
+    sed -e 's|^declare -x |export |' \
+        | grep -v -e "$pat"
+}
+
+# Produce properly quoted Bourne shell arguments for 'env' to carry
+# over the current environment, less blacklisted variables.
+# The 'export -p' command munges the values of environment variables if
+# they contain newlines.
+exports="$(export -p | blacklist_exports)"
+
+# Transform the current argument list into a properly quoted Bourne shell
+# command string.
+command="$(for word in "$@"; do
+               echo -n "$word" | bourne_quote
+               echo -n ' '
+           done)"
+
+# Add commands to set environment variables and the current directory.
+command="${exports}
+cd $PWD
+${command}"
+
+# HOST's sshd simply concatenates its arguments with spaces and
+# passes them to some shell.  We want to force the use of /bin/sh,
+# so we need to re-quote the whole command to ensure it appears as
+# the sole argument of the '-c' option.
+$ssh "$host" /bin/sh -c "$(echo "${command}" | bourne_quote)"

Property changes on: scripts/cross-test-ssh.sh
___________________________________________________________________
Name: svn:executable
   + *

Index: Rules
===================================================================
--- Rules	(revision 161775)
+++ Rules	(working copy)
@@ -91,17 +91,17 @@
 else
 others: $(addprefix $(objpfx),$(extra-objs))
 endif
-ifeq ($(cross-compiling),yes)
-tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
-xtests: tests
-else
+# eglibc: ifeq ($(cross-compiling),yes)
+# eglibc: tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
+# eglibc: xtests: tests
+# eglibc: else
 ifeq ($(build-bounded),yes)
 tests-bp.out = $(tests:%=$(objpfx)%-bp.out)
 xtests-bp.out = $(xtests:%=$(objpfx)%-bp.out)
 endif
 tests: $(tests:%=$(objpfx)%.out) $(tests-bp.out)
 xtests: tests $(xtests:%=$(objpfx)%.out) $(xtests-bp.out)
-endif
+# eglibc: endif
 
 ifeq ($(build-programs),yes)
 binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs)
Index: libio/Makefile
===================================================================
--- libio/Makefile	(revision 161775)
+++ libio/Makefile	(working copy)
@@ -172,9 +172,9 @@
 
 include ../Rules
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 tests: $(objpfx)test-freopen.out $(objpfx)tst-fopenloc.check
-endif
+# eglibc: endif
 
 $(objpfx)test-freopen.out: test-freopen.sh $(objpfx)test-freopen
 	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)'	\
Index: intl/tst-gettext2.sh
===================================================================
--- intl/tst-gettext2.sh	(revision 161775)
+++ intl/tst-gettext2.sh	(working copy)
@@ -21,6 +21,7 @@
 
 common_objpfx=$1
 objpfx=$2
+cross_test_wrapper=$3
 
 LC_ALL=C
 export LC_ALL
@@ -66,6 +67,7 @@
 export LOCPATH
 
 # Now run the test.
+${cross_test_wrapper} \
 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-gettext2 > ${objpfx}tst-gettext2.out ${objpfx}domaindir &&
 cmp ${objpfx}tst-gettext2.out - <<EOF
Index: intl/tst-codeset.sh
===================================================================
--- intl/tst-codeset.sh	(revision 161775)
+++ intl/tst-codeset.sh	(working copy)
@@ -21,6 +21,7 @@
 
 common_objpfx=$1
 objpfx=$2
+cross_test_wrapper=$3
 
 LC_ALL=C
 export LC_ALL
@@ -37,6 +38,7 @@
 LOCPATH=${common_objpfx}localedata
 export LOCPATH
 
+${cross_test_wrapper} \
 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-codeset > ${objpfx}tst-codeset.out
 
Index: intl/Makefile
===================================================================
--- intl/Makefile	(revision 161775)
+++ intl/Makefile	(working copy)
@@ -61,7 +61,7 @@
 
 include ../Rules
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 ifeq (yes,$(build-shared))
 ifneq ($(strip $(MSGFMT)),:)
 tests: $(objpfx)tst-translit.out $(objpfx)tst-gettext2.out \
@@ -77,21 +77,25 @@
 	$(common-objpfx)malloc/mtrace $(objpfx)tst-gettext.mtrace > $@
 $(objpfx)tst-gettext.out: tst-gettext.sh $(objpfx)tst-gettext
 	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
-	  $(objpfx)tst-gettext.mtrace
+	  $(objpfx)tst-gettext.mtrace '$(cross-test-wrapper)'
 $(objpfx)tst-translit.out: tst-translit.sh $(objpfx)tst-translit
-	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
+	'$(cross-test-wrapper)'
 $(objpfx)tst-gettext2.out: tst-gettext2.sh $(objpfx)tst-gettext2
-	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
+	'$(cross-test-wrapper)'
 $(objpfx)tst-codeset.out: tst-codeset.sh $(objpfx)tst-codeset
-	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
+	'$(cross-test-wrapper)'
 $(objpfx)tst-gettext3.out: tst-gettext3.sh $(objpfx)tst-gettext3
-	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/
+	$(SHELL) -e $< $(common-objpfx) $(common-objpfx)intl/ \
+	'$(cross-test-wrapper)'
 $(objpfx)tst-gettext4.out: tst-gettext4.sh $(objpfx)tst-gettext4
 	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
 $(objpfx)tst-gettext5.out: tst-gettext5.sh $(objpfx)tst-gettext5
 	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
 endif
-endif
+# eglibc: endif
 
 $(objpfx)msgs.h: po2test.sed ../po/de.po
 	$(make-target-directory)
Index: intl/tst-translit.sh
===================================================================
--- intl/tst-translit.sh	(revision 161775)
+++ intl/tst-translit.sh	(working copy)
@@ -21,6 +21,7 @@
 
 common_objpfx=$1
 objpfx=$2
+cross_test_wrapper=$3
 
 LC_ALL=C
 export LC_ALL
@@ -36,6 +37,7 @@
 LOCPATH=${common_objpfx}localedata
 export LOCPATH
 
+${cross_test_wrapper} \
 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-translit > ${objpfx}tst-translit.out ${objpfx}domaindir
 
Index: intl/tst-gettext3.sh
===================================================================
--- intl/tst-gettext3.sh	(revision 161775)
+++ intl/tst-gettext3.sh	(working copy)
@@ -22,6 +22,7 @@
 
 common_objpfx=$1
 objpfx=$2
+cross_test_wrapper=$3
 
 LC_ALL=C
 export LC_ALL
@@ -38,6 +39,7 @@
 LOCPATH=${common_objpfx}localedata
 export LOCPATH
 
+${cross_test_wrapper} \
 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-gettext3 > ${objpfx}tst-gettext3.out
 
Index: intl/tst-gettext.sh
===================================================================
--- intl/tst-gettext.sh	(revision 161775)
+++ intl/tst-gettext.sh	(working copy)
@@ -22,6 +22,7 @@
 common_objpfx=$1
 objpfx=$2
 malloc_trace=$3
+cross_test_wrapper=$4
 
 LC_ALL=C
 export LC_ALL
@@ -53,6 +54,7 @@
 
 # Now run the test.
 MALLOC_TRACE=$malloc_trace LOCPATH=${objpfx}localedir:$LOCPATH \
+${cross_test_wrapper} \
 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-gettext > ${objpfx}tst-gettext.out ${objpfx}domaindir
 
Index: iconvdata/run-iconv-test.sh
===================================================================
--- iconvdata/run-iconv-test.sh	(revision 161775)
+++ iconvdata/run-iconv-test.sh	(working copy)
@@ -21,6 +21,7 @@
 # 02111-1307 USA.
 
 codir=$1
+cross_test_wrapper="$2"
 
 # We use always the same temporary file.
 temp1=$codir/iconvdata/iconv-test.xxx
@@ -39,6 +40,7 @@
 # How the start the iconv(1) program.
 ICONV='$codir/elf/ld.so --library-path $LIBPATH --inhibit-rpath ${from}.so \
        $codir/iconv/iconv_prog'
+ICONV="$cross_test_wrapper $ICONV"
 
 # Which echo?
 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
@@ -49,8 +51,13 @@
 
 # We read the file named TESTS.  All non-empty lines not starting with
 # `#' are interpreted as commands.
+# Avoid reading from stdin, since the while loop's body inherits that;
+# if cross_test_wrapper is a program like ssh that reads its input
+# even if the program running on the remote side doesn't, it will
+# steal input from the loop.
 failed=0
-while read from to subset targets; do
+exec 5< TESTS
+while read from to subset targets <&5; do
   # Ignore empty and comment lines.
   if test -z "$subset" || test "$from" = '#'; then continue; fi
 
@@ -141,11 +148,18 @@
       { echo "/FAILED"; failed=1; continue; }
     echo "/OK"
   fi
-done < TESTS
+done
+# Close TESTS.
+exec 5<&-
 
 # We read the file named TESTS2.  All non-empty lines not starting with
 # `#' are interpreted as commands.
-while read utf8 from filename; do
+# Avoid reading from stdin, since the while loop's body inherits that;
+# if cross_test_wrapper is a program like ssh that reads its input
+# even if the program running on the remote side doesn't, it will
+# steal input from the loop.
+exec 5< TESTS2
+while read utf8 from filename <&5; do
   # Ignore empty and comment lines.
   if test -z "$filename" || test "$utf8" = '#'; then continue; fi
 
@@ -184,7 +198,8 @@
     { echo "/FAILED"; failed=1; continue; }
   echo "OK"
 
-done < TESTS2
+done
+exec 5<&-
 
 exit $failed
 # Local Variables:
Index: iconvdata/tst-tables.sh
===================================================================
--- iconvdata/tst-tables.sh	(revision 161775)
+++ iconvdata/tst-tables.sh	(working copy)
@@ -24,6 +24,7 @@
 
 common_objpfx=$1
 objpfx=$2
+cross_test_wrapper="$3"
 
 status=0
 
@@ -249,7 +250,10 @@
   if test "$charset" = GB18030; then echo "This might take a while" 1>&2; fi
   case ${charset} in \#*) continue;; esac
   echo -n "Testing ${charset}" 1>&2
-  if ${SHELL} tst-table.sh ${common_objpfx} ${objpfx} ${charset} ${charmap}; then
+  # Redirect input from /dev/null, so that using ssh (which reads its
+  # input before the remote program needs it) won't consume the rest of the 
+  # charset/charmap table, making the while loop terminate early.
+  if ${SHELL} tst-table.sh ${common_objpfx} ${objpfx} "${cross_test_wrapper}" ${charset} ${charmap} < /dev/null; then
     echo 1>&2
   else
     echo "failed: ./tst-table.sh ${common_objpfx} ${objpfx} ${charset} ${charmap}"
Index: iconvdata/tst-table.sh
===================================================================
--- iconvdata/tst-table.sh	(revision 161775)
+++ iconvdata/tst-table.sh	(working copy)
@@ -24,8 +24,9 @@
 
 common_objpfx=$1
 objpfx=$2
-charset=$3
-charmap=$4
+cross_test_wrapper="$3"
+charset=$4
+charmap=$5
 
 GCONV_PATH=${common_objpfx}iconvdata
 export GCONV_PATH
@@ -60,12 +61,12 @@
 fi
 
 # iconv in one direction.
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${cross_test_wrapper} ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-table-from ${charset} \
   > ${objpfx}tst-${charset}.table
 
 # iconv in the other direction.
-${common_objpfx}elf/ld.so --library-path $common_objpfx \
+${cross_test_wrapper} ${common_objpfx}elf/ld.so --library-path $common_objpfx \
 ${objpfx}tst-table-to ${charset} | sort \
   > ${objpfx}tst-${charset}.inverse.table
 
Index: iconvdata/Makefile
===================================================================
--- iconvdata/Makefile	(revision 161775)
+++ iconvdata/Makefile	(working copy)
@@ -316,7 +316,7 @@
 	$(do-install-program)
 $(inst_gconvdir)/gconv-modules: gconv-modules $(+force)
 	$(do-install)
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 # Update the $(prefix)/lib/gconv/gconv-modules.cache file. This is necessary
 # if this libc has more gconv modules than the previously installed one.
 	if test -f "$(inst_gconvdir)/gconv-modules.cache"; then \
@@ -325,22 +325,22 @@
 	   $(common-objpfx)iconv/iconvconfig \
 	     $(addprefix --prefix=,$(install_root)); \
 	fi
-else
-	@echo '*@*@*@ You should recreate $(inst_gconvdir)/gconv-modules.cache'
-endif
+# eglibc: else
+# eglibc:	@echo '*@*@*@ You should recreate $(inst_gconvdir)/gconv-modules.cache'
+# eglibc: endif
 
 endif # build-shared = yes
 
 include ../Rules
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 ifeq (yes,$(build-shared))
 tests: $(objpfx)iconv-test.out $(objpfx)tst-tables.out
 ifneq (no,$(PERL))
 tests: $(objpfx)mtrace-tst-loading
 endif
 endif
-endif
+# eglibc: endif
 
 tst-loading-ENV = MALLOC_TRACE=$(objpfx)tst-loading.mtrace
 $(objpfx)mtrace-tst-loading: $(objpfx)tst-loading.out
@@ -361,12 +361,13 @@
 $(objpfx)iconv-test.out: run-iconv-test.sh $(objpfx)gconv-modules \
 			 $(addprefix $(objpfx),$(modules.so)) \
 			 $(common-objdir)/iconv/iconv_prog TESTS
-	$(SHELL) -e $< $(common-objdir) > $@
+	$(SHELL) -e $< $(common-objdir) '$(cross-test-wrapper)' > $@
 
 $(objpfx)tst-tables.out: tst-tables.sh $(objpfx)gconv-modules \
 			 $(addprefix $(objpfx),$(modules.so)) \
 			 $(objpfx)tst-table-from $(objpfx)tst-table-to
-	$(SHELL) $< $(common-objpfx) $(common-objpfx)iconvdata/ > $@
+	$(SHELL) $< $(common-objpfx) $(common-objpfx)iconvdata/ \
+		    '$(cross-test-wrapper)' > $@
 
 do-tests-clean common-mostlyclean: tst-tables-clean
 
Index: rt/Makefile
===================================================================
--- rt/Makefile	(revision 161775)
+++ rt/Makefile	(working copy)
@@ -80,7 +80,7 @@
 $(tests:%=$(objpfx)%-bp): $(objpfx)librt_b.a $(bounded-thread-library)
 endif
 
-tst-mqueue7-ARGS = -- $(built-program-cmd)
+tst-mqueue7-ARGS = -- $(local-built-program-cmd)
 
 ifeq (yes,$(build-static-nss))
 otherlibs += $(nssobjdir)/libnss_files.a $(resolvobjdir)/libnss_dns.a \
Index: localedata/tst-rpmatch.sh
===================================================================
--- localedata/tst-rpmatch.sh	(revision 161775)
+++ localedata/tst-rpmatch.sh	(working copy)
@@ -25,9 +25,12 @@
 rc=0
 while IFS=\& read locale string result dummy; do
     if [ "$locale" != "#" ]; then
+        # If tst_rpmatch includes a cross-testing wrapper based on a
+        # program like ssh, it may steal input from the while loop, so
+        # redirect its stdin from /dev/null.
 	LOCPATH=${common_objpfx}localedata \
 	GCONV_PATH=${common_objpfx}/iconvdata \
-	${tst_rpmatch} $locale $string $result \
+	${tst_rpmatch} $locale $string $result < /dev/null \
 	|| { echo "$locale $string $result  FAILED"; exit 1; }
     fi
 done <<EOF
Index: localedata/tst-fmon.sh
===================================================================
--- localedata/tst-fmon.sh	(revision 161775)
+++ localedata/tst-fmon.sh	(working copy)
@@ -32,10 +32,13 @@
 for cns in `cd ./tst-fmon-locales && ls tstfmon_*`; do
     cn=tst-fmon-locales/$cns
     fn=charmaps/ISO-8859-1
+    # If run_program_prefix includes a cross-testing wrapper based on a
+    # program like ssh, it may steal input from the while loop, so
+    # redirect its stdin from /dev/null.
     I18NPATH=. GCONV_PATH=${common_objpfx}iconvdata \
     LOCPATH=${common_objpfx}localedata LC_ALL=C LANGUAGE=C \
     ${run_program_prefix} ${common_objpfx}locale/localedef \
-    --quiet -i $cn -f $fn ${common_objpfx}localedata/$cns
+    --quiet -i $cn -f $fn ${common_objpfx}localedata/$cns < /dev/null
 done
 
 # Run the tests.
@@ -45,10 +48,13 @@
     case "$locale" in '#'*) continue ;; esac
     if [ -n "$format" ]; then
 	expect=`echo "$expect" | sed 's/^\"\(.*\)\"$/\1/'`
+        # If run_program_prefix includes a cross-testing wrapper based on a
+        # program like ssh, it may steal input from the while loop, so
+        # redirect its stdin from /dev/null.
 	LOCPATH=${common_objpfx}localedata \
 	GCONV_PATH=${common_objpfx}/iconvdata \
 	${run_program_prefix} ${common_objpfx}localedata/tst-fmon \
-	"$locale" "$format" "$value" "$expect" ||
+	"$locale" "$format" "$value" "$expect" < /dev/null ||
 	errcode=$?
     fi
 done < $datafile
Index: localedata/Makefile
===================================================================
--- localedata/Makefile	(revision 161775)
+++ localedata/Makefile	(working copy)
@@ -86,7 +86,7 @@
 # Get $(inst_i18ndir) defined.
 include ../Makeconfig
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 locale_test_suite := tst_iswalnum tst_iswalpha tst_iswcntrl            \
 		     tst_iswctype tst_iswdigit tst_iswgraph            \
 		     tst_iswlower tst_iswprint tst_iswpunct            \
@@ -110,7 +110,7 @@
 tests: $(objpfx)mtrace-tst-leaks
 endif
 endif
-endif
+# eglibc: endif
 
 # Files to install.
 install-others := $(addprefix $(inst_i18ndir)/, \
@@ -138,7 +138,7 @@
 CFLAGS-tst-trans.c = -Wno-format
 
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 # We have to generate locales
 LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ANSI_X3.4-1968 \
 	   en_US.ISO-8859-1 ja_JP.EUC-JP da_DK.ISO-8859-1 \
@@ -157,7 +157,11 @@
 $(addprefix $(objpfx),$(CTYPE_FILES)): %: \
   gen-locale.sh $(common-objpfx)locale/localedef Makefile \
   $(addprefix charmaps/,$(CHARMAPS)) $(addprefix locales/,$(LOCALE_SRCS))
-	@$(SHELL) -e gen-locale.sh $(common-objpfx) '$(built-program-cmd)' $@
+	@$(SHELL) -e gen-locale.sh $(common-objpfx)	\
+		 '$(if $(cross-localedef), 		\
+		       $(cross-localedef),		\
+		       $(built-program-cmd))'		\
+		 $@
 
 $(addsuffix .out,$(addprefix $(objpfx),$(tests))): %: \
   $(addprefix $(objpfx),$(CTYPE_FILES))
@@ -210,7 +214,7 @@
 	$(SHELL) -e $< $(common-objpfx) '$(built-program-cmd)'
 $(objpfx)tst-digits.out: $(objpfx)tst-locale.out
 $(objpfx)tst-mbswcs6.out: $(addprefix $(objpfx),$(CTYPE_FILES))
-endif
+# eglibc: endif
 
 include SUPPORTED
 
Index: localedata/tst-numeric.sh
===================================================================
--- localedata/tst-numeric.sh	(revision 161775)
+++ localedata/tst-numeric.sh	(working copy)
@@ -30,10 +30,13 @@
 while IFS="	" read locale format value expect; do
     case "$locale" in '#'*) continue ;; esac
     if [ -n "$format" ]; then
+        # If run_program_prefix includes a cross-testing wrapper based
+        # on a program like ssh, it may steal input from the while
+        # loop, so redirect its stdin from /dev/null.
 	if LOCPATH=${common_objpfx}localedata \
 	    GCONV_PATH=${common_objpfx}/iconvdata \
 	    ${run_program_prefix} ${common_objpfx}localedata/tst-numeric \
-	    "$locale" "$format" "$value" "$expect"
+	    "$locale" "$format" "$value" "$expect" < /dev/null
 	then
 	    echo "Locale: \"${locale}\" Format: \"${format}\"" \
 		 "Value: \"${value}\" Expect: \"${expect}\"  passed"
Index: localedata/tst-wctype.sh
===================================================================
--- localedata/tst-wctype.sh	(revision 161775)
+++ localedata/tst-wctype.sh	(working copy)
@@ -20,12 +20,11 @@
 # 02111-1307 USA.
 
 common_objpfx=$1
-run_program_prefix=$2
+tst_wctype=$2
 
 # Run the test program.
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
-LC_ALL=ja_JP.EUC-JP ${run_program_prefix} \
-  ${common_objpfx}localedata/tst-wctype < tst-wctype.input \
+LC_ALL=ja_JP.EUC-JP ${tst_wctype} < tst-wctype.input \
     > ${common_objpfx}localedata/tst-wctype.out
 
 exit $?
Index: catgets/Makefile
===================================================================
--- catgets/Makefile	(revision 161775)
+++ catgets/Makefile	(working copy)
@@ -55,7 +55,7 @@
 
 tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
 
-ifneq ($(cross-compiling),yes)
+# eglibc: ifneq ($(cross-compiling),yes)
 tests: $(objpfx)de/libc.cat $(objpfx)test1.cat $(objpfx)test2.cat \
        $(objpfx)test-gencat.out
 # This test just checks whether the program produces any error or not.
@@ -85,4 +85,4 @@
 $(objpfx)sample.SJIS.cat: sample.SJIS $(objpfx)gencat
 	GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
 	$(built-program-cmd) -H $(objpfx)test-gencat.h < $(word 1,$^) > $@
-endif
+# eglibc: endif
Index: misc/Makefile
===================================================================
--- misc/Makefile	(revision 161775)
+++ misc/Makefile	(working copy)
@@ -79,9 +79,9 @@
 
 tests := tst-dirname tst-tsearch tst-fdset tst-efgcvt tst-mntent tst-hsearch \
 	 tst-error1 tst-pselect tst-insremque tst-mntent2
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 tests: $(objpfx)tst-error1-mem
-endif
+# eglibc: endif
 
 CFLAGS-tsearch.c = $(uses-callbacks)
 CFLAGS-lsearch.c = $(uses-callbacks)
Index: posix/tst-getconf.sh
===================================================================
--- posix/tst-getconf.sh	(revision 161775)
+++ posix/tst-getconf.sh	(working copy)
@@ -2,14 +2,17 @@
 
 common_objpfx=$1; shift
 elf_objpfx=$1; shift
+cross_test_wrapper=$1; shift
 if [ $# -eq 0 ]; then
   # Static case.
   runit() {
+    ${cross_test_wrapper} \
     "$@"
   }
 else
   rtld_installed_name=$1; shift
   runit() {
+    ${cross_test_wrapper} \
     ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} "$@"
   }
 fi
@@ -26,7 +29,10 @@
 result=0
 while read name; do
   echo -n "getconf $name: " >> $logfile
-  runit ${common_objpfx}posix/getconf "$name" 2>> $logfile >> $logfile
+  # Redirect input from /dev/null in case runit consumes input when it
+  # shouldn't (ssh, say)
+  runit ${common_objpfx}posix/getconf "$name" \
+        < /dev/null 2>> $logfile >> $logfile
   if test $? -ne 0; then
     echo "*** $name FAILED" >> $logfile
     result=1
@@ -204,7 +210,10 @@
 
 while read name; do
   echo -n "getconf $name /: " >> $logfile
-  runit ${common_objpfx}posix/getconf "$name" / 2>> $logfile >> $logfile
+  # Redirect input from /dev/null in case runit consumes input when it
+  # shouldn't (ssh, say)
+  runit ${common_objpfx}posix/getconf "$name" / \
+      < /dev/null 2>> $logfile >> $logfile
   if test $? -ne 0; then
     echo "*** $name FAILED" >> $logfile
     result=1
Index: posix/globtest.sh
===================================================================
--- posix/globtest.sh	(revision 161775)
+++ posix/globtest.sh	(working copy)
@@ -3,6 +3,7 @@
 common_objpfx=$1; shift
 elf_objpfx=$1; shift
 rtld_installed_name=$1; shift
+cross_test_wrapper=$1; shift
 logfile=$common_objpfx/posix/globtest.out
 
 #CMP=cmp
@@ -20,6 +21,9 @@
 # We have to find the libc and the NSS modules.
 library_path=${common_objpfx}:${common_objpfx}nss:${common_objpfx}nis:${common_objpfx}db2:${common_objpfx}hesiod
 
+run_program_prefix="${cross_test_wrapper} \
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path}"
+
 # Since we use `sort' we must make sure to use the same locale everywhere.
 LC_ALL=C
 export LC_ALL
@@ -62,7 +66,7 @@
 
 # Normal test
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -89,7 +93,7 @@
 
 # Don't let glob sort it
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -s "$testdir" "*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -116,7 +120,7 @@
 
 # Mark directories
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -m "$testdir" "*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -143,7 +147,7 @@
 
 # Find files starting with .
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -p "$testdir" "*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -173,7 +177,7 @@
 
 # Test braces
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b "$testdir" "file{1,2}" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -186,7 +190,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -200,7 +204,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b "$testdir" "{" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -213,7 +217,7 @@
 
 # Test NOCHECK
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -c "$testdir" "abc" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -226,7 +230,7 @@
 
 # Test NOMAGIC without magic characters
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -g "$testdir" "abc" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -239,7 +243,7 @@
 
 # Test NOMAGIC with magic characters
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -252,7 +256,7 @@
 
 # Test NOMAGIC for subdirs
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -g "$testdir" "*/does-not-exist" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -265,7 +269,7 @@
 
 # Test subdirs correctly
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -281,7 +285,7 @@
 
 # Test subdirs for invalid names
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/1" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -294,7 +298,7 @@
 
 # Test subdirs with wildcard
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -308,7 +312,7 @@
 
 # Test subdirs with ?
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -323,7 +327,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -336,7 +340,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*-/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -348,7 +352,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*-" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -361,7 +365,7 @@
 
 # Test subdirs with ?
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -377,7 +381,7 @@
 
 # Test subdirs with [ .. ]
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -393,7 +397,7 @@
 
 # Test ']' inside bracket expression
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -407,7 +411,7 @@
 
 # Test tilde expansion
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
 sort >$testout
 echo ~ | $CMP - $testout >> $logfile || failed=1
@@ -422,7 +426,7 @@
 
 # Test tilde expansion with trailing slash
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
 sort > $testout
 # Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
@@ -442,7 +446,7 @@
 
 # Test tilde expansion with username
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
 sort > $testout
 eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
@@ -457,7 +461,7 @@
 
 # Tilde expansion shouldn't match a file
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -470,7 +474,7 @@
 
 # Matching \** should only find *file6
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "\**" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -484,7 +488,7 @@
 # ... unless NOESCAPE is used, in which case it should entries with a
 # leading \.
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -e "$testdir" "\**" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -499,7 +503,7 @@
 
 # Matching \*file6 should find *file6
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "\*file6" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -512,7 +516,7 @@
 
 # GLOB_BRACE alone
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b "$testdir" '\{file7\,\}' |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -525,7 +529,7 @@
 
 # GLOB_BRACE and GLOB_NOESCAPE
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b -e "$testdir" '\{file9\,file9b\}' |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -538,7 +542,7 @@
 
 # Escaped comma
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b "$testdir" '{filea\,}' |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -551,7 +555,7 @@
 
 # Escaped closing brace
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -b "$testdir" '{fileb\}c}' |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -564,7 +568,7 @@
 
 # Try a recursive failed search
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -577,7 +581,7 @@
 
 # ... with GLOB_ERR
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -E "$testdir" "a*/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -590,7 +594,7 @@
 
 # Try a recursive search in unreadable directory
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "noread/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -602,7 +606,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "noread*/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -620,14 +624,14 @@
 fi
 if test "$user" != root; then
     # ... with GLOB_ERR
-    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${run_program_prefix} \
     ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
     sort > $testout
     cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
 GLOB_ABORTED
 EOF
 
-    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${run_program_prefix} \
     ${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
     sort > $testout
     cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -641,7 +645,7 @@
 
 # Try multiple patterns (GLOB_APPEND)
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -658,7 +662,7 @@
 
 # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -o "$testdir" "file1" "*/*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -676,7 +680,7 @@
 
 # Test NOCHECK with non-existing file in subdir.
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
@@ -689,7 +693,7 @@
 
 # Test [[:punct:]] not matching leading period.
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${run_program_prefix} \
 ${common_objpfx}posix/globtest -c "$testdir" "[[:punct:]]*" |
 sort > $testout
 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
Index: posix/Makefile
===================================================================
--- posix/Makefile	(revision 161775)
+++ posix/Makefile	(working copy)
@@ -120,18 +120,18 @@
 			$(resolvobjdir)/libresolv.a)
 endif
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 # globtest and wordexp-test currently only works with shared libraries
 ifeq (yes,$(build-shared))
 tests: $(objpfx)globtest.out $(objpfx)wordexp-tst.out
 $(objpfx)globtest.out: globtest.sh $(objpfx)globtest
 	$(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) \
-		 $(rtld-installed-name)
+		 $(rtld-installed-name) '$(cross-test-wrapper)'
 $(objpfx)wordexp-tst.out: wordexp-tst.sh $(objpfx)wordexp-test
 	$(SHELL) -e wordexp-tst.sh $(common-objpfx) $(elf-objpfx) \
-		 $(rtld-installed-name)
+		 $(rtld-installed-name) '$(cross-test-wrapper)'
 endif
-endif
+# eglibc: endif
 
 CFLAGS-regex.c = -Wno-strict-prototypes
 CFLAGS-getaddrinfo.c = -DRESOLVER -fexceptions -DUSE_NSCD
@@ -170,8 +170,8 @@
 tstgetopt-ARGS = -a -b -cfoobar --required foobar --optional=bazbug \
 		--none random --col --color --colour
 
-tst-exec-ARGS = -- $(built-program-cmd)
-tst-spawn-ARGS = -- $(built-program-cmd)
+tst-exec-ARGS = -- $(local-built-program-cmd)
+tst-spawn-ARGS = -- $(local-built-program-cmd)
 tst-dir-ARGS = `pwd` `cd $(common-objdir)/$(subdir); pwd` `cd $(common-objdir); pwd` $(objpfx)tst-dir
 tst-chmod-ARGS = `pwd`
 
@@ -214,13 +214,13 @@
 # Run a test on the header files we use.
 # XXX Please note that for now we ignore the result of this test.
 tests: $(objpfx)annexc.out
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 tests: $(objpfx)bug-regex2-mem $(objpfx)bug-regex14-mem \
   $(objpfx)bug-regex21-mem $(objpfx)tst-rxspencer-mem \
   $(objpfx)tst-pcre-mem $(objpfx)tst-boost-mem $(objpfx)tst-getconf.out \
   $(objpfx)bug-glob2-mem
 xtests: $(objpfx)bug-ga2-mem
-endif
+# eglibc: endif
 
 $(objpfx)annexc.out: $(objpfx)annexc
 	-$(dir $<)$(notdir $<) '$(CC)' \
@@ -263,7 +263,8 @@
 	$(common-objpfx)malloc/mtrace $(objpfx)tst-boost.mtrace > $@
 
 $(objpfx)tst-getconf.out: tst-getconf.sh $(objpfx)getconf
-	$(SHELL) -e $< $(common-objpfx) $(elf-objpfx) $(rtld-installed-name)
+	$(SHELL) -e $< $(common-objpfx) $(elf-objpfx) \
+		'$(cross-test-wrapper)' $(rtld-installed-name)
 
 ifeq (yes,$(build-shared))
 $(objpfx)tst-regex: $(common-objpfx)rt/librt.so
Index: posix/wordexp-tst.sh
===================================================================
--- posix/wordexp-tst.sh	(revision 161775)
+++ posix/wordexp-tst.sh	(working copy)
@@ -7,6 +7,11 @@
 common_objpfx=$1; shift
 elf_objpfx=$1; shift
 rtld_installed_name=$1; shift
+cross_test_wrapper=$1; shift
+
+run_program_prefix="${cross_test_wrapper} \
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx}"
+
 logfile=${common_objpfx}posix/wordexp-tst.out
 testout=${common_objpfx}posix/wordexp-test-result
 
@@ -20,7 +25,7 @@
 export IFS
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
 cat <<"EOF" | cmp - ${testout}1 >> $logfile || failed=1
 wordexp returned 0
@@ -32,7 +37,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
 cat <<"EOF" | cmp - ${testout}2 >> $logfile || failed=1
 wordexp returned 0
@@ -45,7 +50,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
 cat <<"EOF" | cmp - ${testout}3 >> $logfile || failed=1
 wordexp returned 0
@@ -58,7 +63,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
 cat <<"EOF" | cmp - ${testout}4 >> $logfile || failed=1
 wordexp returned 0
@@ -70,7 +75,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
 cat <<"EOF" | cmp - ${testout}5 >> $logfile || failed=1
 wordexp returned 0
@@ -84,7 +89,7 @@
 # Why?  Because bash does it that way..
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
 cat <<"EOF" | cmp - ${testout}6 >> $logfile || failed=1
 wordexp returned 0
@@ -96,7 +101,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
 cat <<"EOF" | cmp - ${testout}7 >> $logfile || failed=1
 wordexp returned 0
@@ -111,7 +116,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
 cat <<"EOF" | cmp - ${testout}8 >> $logfile || failed=1
 wordexp returned 0
@@ -123,7 +128,7 @@
 fi
 
 failed=0
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
 cat <<"EOF" | cmp - ${testout}9 >> $logfile || failed=1
 wordexp returned 0
@@ -136,7 +141,7 @@
   status=1
 fi
 
-${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${run_program_prefix} \
 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
 cat <<"EOF" | cmp - ${testout}10 || failed=1
 wordexp returned 0
Index: Makeconfig
===================================================================
--- Makeconfig	(revision 161775)
+++ Makeconfig	(working copy)
@@ -553,18 +553,24 @@
 $(subst $(empty) ,:,$(strip $(patsubst -Wl$(comma)-rpath-link=%, %,\
 				       $(filter -Wl$(comma)-rpath-link=%,\
 						$(sysdep-LDFLAGS)))))
-run-program-prefix = $(if $(filter $(notdir $(built-program-file)),\
-				   $(tests-static) $(xtests-static)),, \
-			  $(elf-objpfx)$(rtld-installed-name) \
-			  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
+# Never use $(run-via-rtld-prefix) for the statically-linked %-bp test
+# programs, or for tests listed in tests-static or xtests-static.
+run-via-rtld-prefix =							      \
+  $(if $(strip $(filter $(notdir $(built-program-file)),		      \
+			$(tests-static) $(xtests-static))		      \
+	       $(filter %-bp,$(built-program-file))),,			      \
+       $(elf-objpfx)$(rtld-installed-name)				      \
+	 --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)))
 else
-run-program-prefix =
+run-via-rtld-prefix =
 endif
-# Never use $(run-program-prefix) for the statically-linked %-bp test programs
-built-program-cmd = $(patsubst %,$(run-program-prefix),\
-			$(filter-out %-bp,$(built-program-file))) \
-		    $(built-program-file)
+run-program-prefix = $(cross-test-wrapper) $(run-via-rtld-prefix)
+built-program-cmd = $(cross-test-wrapper) $(run-via-rtld-prefix) $(built-program-file)
 
+# Same as built-program-cmd, but without the cross-test-wrapper.  Used 
+# to run programs from the test machine, as in nptl/tst-cancel7.
+local-built-program-cmd = $(run-via-rtld-prefix) $(built-program-file)
+
 ifndef LD
 LD := ld -X
 endif
Index: string/Makefile
===================================================================
--- string/Makefile	(revision 161775)
+++ string/Makefile	(working copy)
@@ -73,10 +73,10 @@
 CFLAGS-test-ffs.c = -fno-builtin
 CFLAGS-tst-inlcall.c = -fno-builtin
 
-ifeq ($(cross-compiling),no)
+# eglibc: ifeq ($(cross-compiling),no)
 tests: $(objpfx)tst-svc.out
 $(objpfx)tst-svc.out: tst-svc.input $(objpfx)tst-svc
 	GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
 	  $(built-program-cmd) < $(word 1,$^) > $@
 	-cmp tst-svc.expect $(objpfx)tst-svc.out
-endif
+# eglibc: endif
Index: stdio-common/Makefile
===================================================================
--- stdio-common/Makefile	(revision 161775)
+++ stdio-common/Makefile	(working copy)
@@ -63,7 +63,7 @@
 $(inst_includedir)/bits/stdio_lim.h: $(common-objpfx)bits/stdio_lim.h $(+force)
 	$(do-install)
 
-ifeq ($(cross-compiling),no)
+# eglibc: ifeq ($(cross-compiling),no)
 .PHONY: do-tst-unbputc do-tst-printf
 tests: do-tst-unbputc do-tst-printf
 
@@ -74,7 +74,7 @@
 do-tst-printf: $(objpfx)tst-printf.out
 $(objpfx)tst-printf.out: $(objpfx)tst-printf tst-printf.sh
 	$(SHELL) -e tst-printf.sh $(common-objpfx) '$(run-program-prefix)'
-endif
+# eglibc: endif
 
 CFLAGS-vfprintf.c = -Wno-uninitialized
 CFLAGS-tst-printf.c = -Wno-format
Index: resolv/Makefile
===================================================================
--- resolv/Makefile	(revision 161775)
+++ resolv/Makefile	(working copy)
@@ -101,17 +101,17 @@
 tst-leaks-ENV = MALLOC_TRACE=$(objpfx)tst-leaks.mtrace
 $(objpfx)mtrace-tst-leaks: $(objpfx)tst-leaks.out
 	$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks.mtrace > $@
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 ifneq (no,$(PERL))
 tests: $(objpfx)mtrace-tst-leaks
 endif
-endif
+# eglibc: endif
 
 tst-leaks2-ENV = MALLOC_TRACE=$(objpfx)tst-leaks2.mtrace
 $(objpfx)mtrace-tst-leaks2: $(objpfx)tst-leaks2.out
 	$(common-objpfx)malloc/mtrace $(objpfx)tst-leaks2.mtrace > $@
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 ifneq (no,$(PERL))
 xtests: $(objpfx)mtrace-tst-leaks2
 endif
-endif
+# eglibc: endif
Index: iconv/Makefile
===================================================================
--- iconv/Makefile	(revision 161775)
+++ iconv/Makefile	(working copy)
@@ -79,9 +79,9 @@
 $(objpfx)iconv_prog: $(iconv_prog-modules:%=$(objpfx)%.o)
 $(objpfx)iconvconfig: $(iconvconfig-modules:%=$(objpfx)%.o)
 
-ifneq ($(cross-compiling),yes)
+# eglibc: ifneq ($(cross-compiling),yes)
 xtests: test-iconvconfig
-endif
+# eglibc: endif
 
 .PHONY: test-iconvconfig
 test-iconvconfig: /dev/null $(objpfx)iconvconfig
Index: grp/tst_fgetgrent.sh
===================================================================
--- grp/tst_fgetgrent.sh	(revision 161775)
+++ grp/tst_fgetgrent.sh	(working copy)
@@ -22,21 +22,26 @@
 common_objpfx=$1; shift
 elf_objpfx=$1; shift
 rtld_installed_name=$1; shift
+cross_test_wrapper="$1"; shift
 
 testout=${common_objpfx}/grp/tst_fgetgrent.out
 library_path=${common_objpfx}
 
 result=0
 
+${cross_test_wrapper} \
 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
 ${common_objpfx}grp/tst_fgetgrent 0 > ${testout} || result=1
 
+${cross_test_wrapper} \
 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
 ${common_objpfx}grp/tst_fgetgrent 1 >> ${testout} || result=1
 
+${cross_test_wrapper} \
 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
 ${common_objpfx}grp/tst_fgetgrent 2 >> ${testout} || result=1
 
+${cross_test_wrapper} \
 ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
 ${common_objpfx}grp/tst_fgetgrent 3 >> ${testout} || result=1
 
Index: grp/Makefile
===================================================================
--- grp/Makefile	(revision 161775)
+++ grp/Makefile	(working copy)
@@ -59,13 +59,13 @@
 
 endif
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 # tst_fgetgrent currently only works with shared libraries
 ifeq (yes,$(build-shared))
 tests: $(objpfx)tst_fgetgrent.out
 $(objpfx)tst_fgetgrent.out: tst_fgetgrent.sh $(objpfx)tst_fgetgrent
 	$(SHELL) -e tst_fgetgrent.sh $(common-objpfx) $(elf-objpfx) \
-		 $(rtld-installed-name)
+		 $(rtld-installed-name) "$(cross-test-wrapper)"
 
 endif
-endif
+# eglibc: endif
Index: elf/Makefile
===================================================================
--- elf/Makefile	(revision 161775)
+++ elf/Makefile	(working copy)
@@ -399,10 +399,10 @@
 generated += $(addsuffix .so,$(strip $(modules-names)))
 
 ifeq (yes,$(build-shared))
-ifeq ($(cross-compiling),no)
+# eglibc: ifeq ($(cross-compiling),no)
 tests: $(objpfx)tst-pathopt.out
+# eglibc: endif
 endif
-endif
 
 $(objpfx)testobj1.so: $(libdl)
 $(objpfx)testobj1_1.so: $(objpfx)testobj1.so $(libdl)
@@ -579,6 +579,7 @@
 $(objpfx)order: $(addprefix $(objpfx),dep4.so dep3.so dep2.so dep1.so)
 
 $(objpfx)order.out: $(objpfx)order
+	$(cross-test-wrapper) \
 	$(elf-objpfx)$(rtld-installed-name) \
 	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
 	  $(objpfx)order > $@
@@ -640,7 +641,7 @@
 $(objpfx)tst-pathopt: $(libdl)
 $(objpfx)tst-pathopt.out: tst-pathopt.sh $(objpfx)tst-pathopt \
 			  $(objpfx)pathoptobj.so
-	$(SHELL) -e $< $(common-objpfx)
+	$(SHELL) -e $< $(common-objpfx) "$(cross-test-wrapper)"
 
 $(objpfx)initfirst: $(libdl)
 $(objpfx)initfirst.out: $(objpfx)firstobj.so
@@ -802,6 +803,7 @@
 CFLAGS-tst-pie1.c += -fpie
 
 $(objpfx)tst-pie1.out: $(objpfx)tst-pie1
+	$(cross-test-wrapper) \
 	$(elf-objpfx)$(rtld-installed-name) \
 	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
 	  $< > $@
@@ -897,6 +899,7 @@
 $(objpfx)order2: $(libdl)
 $(objpfx)order2.out: $(objpfx)order2 $(objpfx)order2mod1.so \
 		     $(objpfx)order2mod2.so
+	$(cross-test-wrapper) \
 	$(elf-objpfx)$(rtld-installed-name) \
 	  --library-path $(rpath-link)$(patsubst %,:%,$(sysdep-library-path)) \
 	  $(objpfx)order2 > $@
@@ -906,7 +909,7 @@
 $(objpfx)order2mod2.so: $(objpfx)order2mod3.so
 order2mod2.so-no-z-defs = yes
 
-tst-stackguard1-ARGS = --command "$(built-program-cmd) --child"
+tst-stackguard1-ARGS = --command "$(local-built-program-cmd) --child"
 tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
 
 $(objpfx)tst-leaks1: $(libdl)
Index: elf/tst-pathopt.sh
===================================================================
--- elf/tst-pathopt.sh	(revision 161775)
+++ elf/tst-pathopt.sh	(working copy)
@@ -20,7 +20,7 @@
 # 02111-1307 USA.
 
 common_objpfx=$1
-run_program_prefix=$2
+cross_test_wrapper="$2"
 
 test -e ${common_objpfx}elf/will-be-empty &&
   rm -fr ${common_objpfx}elf/will-be-empty
@@ -31,7 +31,8 @@
 
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
 LC_ALL=C LD_LIBRARY_PATH=${common_objpfx}elf/will-be-empty:${common_objpfx}elf/for-renamed:${common_objpfx}.:${common_objpfx}dlfcn \
-  ${common_objpfx}elf/ld.so ${common_objpfx}elf/tst-pathopt \
+  ${cross_test_wrapper} ${common_objpfx}elf/ld.so \
+    ${common_objpfx}elf/tst-pathopt \
     > ${common_objpfx}elf/tst-pathopt.out
 
 exit $?
Index: malloc/tst-mtrace.sh
===================================================================
--- malloc/tst-mtrace.sh	(revision 161775)
+++ malloc/tst-mtrace.sh	(working copy)
@@ -20,12 +20,14 @@
 # 02111-1307 USA.
 
 common_objpfx=$1; shift
+cross_test_wrapper="$1"; shift
 
 status=0
 trap "rm -f ${common_objpfx}malloc/tst-mtrace.leak; exit 1" 1 2 15
 
 MALLOC_TRACE=${common_objpfx}malloc/tst-mtrace.leak \
 LOCPATH=${common_objpfx}localedata GCONV_PATH=${common_objpfx}iconvdata \
+${cross_test_wrapper} \
 ${common_objpfx}elf/ld.so --library-path $common_objpfx \
   ${common_objpfx}malloc/tst-mtrace || status=1
 
Index: malloc/Makefile
===================================================================
--- malloc/Makefile	(revision 161775)
+++ malloc/Makefile	(working copy)
@@ -112,15 +112,15 @@
 
 lib: $(objpfx)libmcheck.a
 
-ifeq (no,$(cross-compiling))
+# eglibc: ifeq (no,$(cross-compiling))
 ifeq (yes,$(build-shared))
 ifneq ($(PERL),no)
 tests: $(objpfx)tst-mtrace.out
 $(objpfx)tst-mtrace.out: tst-mtrace.sh $(objpfx)tst-mtrace
-	$(SHELL) -e $< $(common-objpfx)
+	$(SHELL) -e $< $(common-objpfx) '$(cross-test-wrapper)'
 endif
 endif
-endif
+# eglibc: endif
 
 tst-mcheck-ENV = MALLOC_CHECK_=3
 
Index: io/Makefile
===================================================================
--- io/Makefile	(revision 161775)
+++ io/Makefile	(working copy)
@@ -107,10 +107,20 @@
 
 tst-statvfs-ARGS = $(objpfx)tst-statvfs tst-statvfs.c /tmp
 
-ifeq ($(cross-compiling),no)
+# eglibc: ifeq ($(cross-compiling),no)
 tests: $(objpfx)ftwtest.out
 
+ifeq ($(cross-compiling),yes)
+# EGLIBC's cross-testing support does not require the build and host
+# machines to share a /tmp directory, so when cross-testing, construct
+# the sample directory tree for these tests in the build tree.
+ftwtest-tmpdir = TMPDIR=$(common-objpfx)
+endif
+
 $(objpfx)ftwtest.out: $(objpfx)ftwtest
+	$(ftwtest-tmpdir) \
 	$(SHELL) -e ftwtest-sh $(shell cd $(common-objpfx). && pwd)/ \
+		 '$(cross-test-wrapper)' \
 		 $(shell cd $(<D) && pwd)/$(<F) > $@
-endif
+
+# eglibc: endif
Index: io/ftwtest-sh
===================================================================
--- io/ftwtest-sh	(revision 161775)
+++ io/ftwtest-sh	(working copy)
@@ -3,6 +3,9 @@
 # The common objpfx, used to find libraries and the dynamic loader.
 objpfx=$1
 
+# The cross-testing wrapper.
+cross_test_wrapper="$2"
+
 # We expect one parameter which is the test program.  This must understand
 # a number options:
 #   --phys		use the FTW_PHYS flag
@@ -11,7 +14,7 @@
 #   --depth		use the FTW_DEPTH flag
 #   --early-exit 	print file@2 item only and return non-zero from the
 #			callback when it is seen
-testprogram=$2
+testprogram=$3
 
 # We cannot test this as root.
 if test `id | sed "s/uid=\([0-9]*\).*/\1/"` = 0; then
@@ -29,6 +32,7 @@
 tmpdir=$tmp/ftwtest.d
 
 [ -f ${objpfx}elf/ld.so ] && ldso=${objpfx}elf/ld.so
+ldso="${cross_test_wrapper:+$cross_test_wrapper }$ldso"
 
 trap 'chmod -fR a+x $tmpdir; rm -fr $tmpdir $testout' 1 2 3 15
 
Index: nptl/Makefile
===================================================================
--- nptl/Makefile	(revision 161775)
+++ nptl/Makefile	(working copy)
@@ -434,7 +434,7 @@
 CFLAGS-tst-initializers1-gnu89.c = $(CFLAGS-tst-initializers1-<)
 CFLAGS-tst-initializers1-gnu99.c = $(CFLAGS-tst-initializers1-<)
 
-tst-cancel7-ARGS = --command "$(built-program-cmd)"
+tst-cancel7-ARGS = --command "$(local-built-program-cmd)"
 tst-cancelx7-ARGS = $(tst-cancel7-ARGS)
 tst-umask1-ARGS = $(objpfx)tst-umask1.temp
 
@@ -470,7 +470,7 @@
 		       $(objpfx)tst-tls5modc.so $(objpfx)tst-tls5modd.so \
 		       $(objpfx)tst-tls5mode.so $(objpfx)tst-tls5modf.so
 	$(SHELL) -e tst-tls6.sh $(common-objpfx) $(elf-objpfx) \
-		    $(rtld-installed-name)
+		    $(rtld-installed-name) '$(cross-test-wrapper)'
 endif
 
 $(objpfx)tst-dlsym1: $(libdl) $(shared-thread-library)
@@ -604,7 +604,7 @@
 endif
 # eglibc: endif
 
-tst-exec4-ARGS = $(built-program-cmd)
+tst-exec4-ARGS = $(local-built-program-cmd)
 
 $(objpfx)tst-execstack: $(libdl)
 $(objpfx)tst-execstack.out: $(objpfx)tst-execstack-mod.so
@@ -612,7 +612,7 @@
 
 $(objpfx)tst-fini1mod.so: $(shared-thread-library)
 
-tst-stackguard1-ARGS = --command "$(built-program-cmd) --child"
+tst-stackguard1-ARGS = --command "$(local-built-program-cmd) --child"
 tst-stackguard1-static-ARGS = --command "$(objpfx)tst-stackguard1-static --child"
 
 # The tests here better do not run in parallel
Index: nptl/tst-tls6.sh
===================================================================
--- nptl/tst-tls6.sh	(revision 161775)
+++ nptl/tst-tls6.sh	(working copy)
@@ -3,12 +3,14 @@
 common_objpfx=$1; shift
 elf_objpfx=$1; shift
 rtld_installed_name=$1; shift
+cross_test_wrapper=$1; shift
 logfile=$common_objpfx/nptl/tst-tls6.out
 
 # We have to find libc and nptl
 library_path=${common_objpfx}:${common_objpfx}nptl
 tst_tls5="${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
 	  ${common_objpfx}/nptl/tst-tls5"
+tst_tls5="$cross_test_wrapper $tst_tls5"
 
 LC_ALL=C
 export LC_ALL