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

[patches] Cross-testing work in progress



Here's the patch I'm working with at the moment, if folks are curious.

The iconvdata tests all run (I'm especially proud of the redirection
from /dev/null in iconvdata/tst-tables.sh), as do most of the
localedata tests, so I think I've got the cross-locale issues under
control; you do need to set the 'cross-localedef' make variable to the
path of a build-machine localedef program, like the one built from
EGLIBC's localedef tree.

I'm using the following script to run the tests:

#!/bin/sh

set -x

srcdir='/home/jimb/eglibc/src/glibc-2.5'
objdir='/scratch/jimb/eglibc/obj'

cross_test_ssh="$srcdir/scripts/cross-test-ssh.sh"
localedef="$objdir/glibc_localedef/localedef"

make cross-test-wrapper="$cross_test_ssh morphy" \
     cross-localedef="$localedef --little-endian --uint32-align=4" \
     "$@"


And the patch:

Index: scripts/cross-test-ssh.sh
===================================================================
--- scripts/cross-test-ssh.sh	(revision 0)
+++ scripts/cross-test-ssh.sh	(revision 0)
@@ -0,0 +1,98 @@
+#!/bin/sh
+# usage: cross-test-ssh.sh 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} 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.
+
+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}"
+
+if [ "x$1" = "x--help" ]; then
+    echo "$usage"
+    echo "$help"
+    exit 0
+fi
+
+if [ $# -lt 2 ]; 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: Makeconfig
===================================================================
--- Makeconfig	(revision 161054)
+++ Makeconfig	(working copy)
@@ -553,17 +553,18 @@
 $(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 $(or $(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 = $(run-program-prefix) $(built-program-file)
 
 ifndef LD
 LD := ld -X
Index: Rules
===================================================================
--- Rules	(revision 161054)
+++ 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
+# ifeq ($(cross-compiling),yes)
+# tests: $(addprefix $(objpfx),$(tests) $(test-srcs))
+# xtests: tests
+# 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
+# endif
 
 ifeq ($(build-programs),yes)
 binaries-all = $(others) $(sysdep-others) $(tests) $(xtests) $(test-srcs)
Index: intl/Makefile
===================================================================
--- intl/Makefile	(revision 161054)
+++ intl/Makefile	(working copy)
@@ -61,7 +61,7 @@
 
 include ../Rules
 
-ifeq (no,$(cross-compiling))
+# ifeq (no,$(cross-compiling))
 ifeq (yes,$(build-shared))
 ifneq ($(strip $(MSGFMT)),:)
 tests: $(objpfx)tst-translit.out $(objpfx)tst-gettext2.out \
@@ -91,7 +91,7 @@
 $(objpfx)tst-gettext5.out: tst-gettext5.sh $(objpfx)tst-gettext5
 	$(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/
 endif
-endif
+# endif
 
 $(objpfx)msgs.h: po2test.sed ../po/de.po
 	$(make-target-directory)
Index: iconvdata/run-iconv-test.sh
===================================================================
--- iconvdata/run-iconv-test.sh	(revision 161054)
+++ 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
Index: iconvdata/tst-tables.sh
===================================================================
--- iconvdata/tst-tables.sh	(revision 161054)
+++ 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 161054)
+++ 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 161054)
+++ iconvdata/Makefile	(working copy)
@@ -316,7 +316,7 @@
 	$(do-install-program)
 $(inst_gconvdir)/gconv-modules: gconv-modules $(+force)
 	$(do-install)
-ifeq (no,$(cross-compiling))
+# 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
+# else
+#	@echo '*@*@*@ You should recreate $(inst_gconvdir)/gconv-modules.cache'
+# endif
 
 endif # build-shared = yes
 
 include ../Rules
 
-ifeq (no,$(cross-compiling))
+# 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
+# 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: localedata/Makefile
===================================================================
--- localedata/Makefile	(revision 161054)
+++ localedata/Makefile	(working copy)
@@ -138,7 +138,7 @@
 CFLAGS-tst-trans.c = -Wno-format
 
 
-ifeq (no,$(cross-compiling))
+# 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
+# endif
 
 include SUPPORTED
 
Index: localedata/tst-wctype.sh
===================================================================
--- localedata/tst-wctype.sh	(revision 161054)
+++ 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 161054)
+++ catgets/Makefile	(working copy)
@@ -55,7 +55,7 @@
 
 tst-catgets-ENV = NLSPATH="$(objpfx)%l/%N.cat" LANG=de
 
-ifneq ($(cross-compiling),yes)
+# 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
+# endif
Index: iconv/Makefile
===================================================================
--- iconv/Makefile	(revision 161054)
+++ 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)
+# ifneq ($(cross-compiling),yes)
 xtests: test-iconvconfig
-endif
+# endif
 
 .PHONY: test-iconvconfig
 test-iconvconfig: /dev/null $(objpfx)iconvconfig
Index: grp/tst_fgetgrent.sh
===================================================================
--- grp/tst_fgetgrent.sh	(revision 161054)
+++ 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 161054)
+++ grp/Makefile	(working copy)
@@ -59,13 +59,13 @@
 
 endif
 
-ifeq (no,$(cross-compiling))
+# 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
+# endif
Index: elf/Makefile
===================================================================
--- elf/Makefile	(revision 161054)
+++ elf/Makefile	(working copy)
@@ -399,10 +399,10 @@
 generated += $(addsuffix .so,$(strip $(modules-names)))
 
 ifeq (yes,$(build-shared))
-ifeq ($(cross-compiling),no)
+# ifeq ($(cross-compiling),no)
 tests: $(objpfx)tst-pathopt.out
+# 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
@@ -897,6 +898,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 > $@
Index: elf/tst-pathopt.sh
===================================================================
--- elf/tst-pathopt.sh	(revision 161054)
+++ 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 $?