This patch to libgo uses DejaGNU when testing a cross-compiler. The shell script is simpler but only works for a native configuration. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. This should fix PR 56017.
Ian
diff -r 27e1a46c9cc2 libgo/Makefile.am --- a/libgo/Makefile.am Mon Feb 04 17:10:28 2013 -0800 +++ b/libgo/Makefile.am Tue Feb 05 14:13:17 2013 -0800 @@ -1991,12 +1991,6 @@ files=`echo $^ | sed -e 's/[^ ]*\.gox//g'`; \ $(LTGOCOMPILE) -I . -c -fgo-pkgpath=`echo $@ | sed -e 's/.lo$$//' -e 's/-go$$//'` -o $@ $$files -if LIBGO_IS_RTEMS -use_dejagnu = yes -else -use_dejagnu = no -endif - GOTESTFLAGS = # Check a package. @@ -2015,7 +2009,7 @@ export LD_LIBRARY_PATH; \ $(MKDIR_P) $(@D); \ rm -f $@-testsum $@-testlog; \ - if test "$(use_dejagnu)" = "yes"; then \ + if test "$(USE_DEJAGNU)" = "yes"; then \ $(SHELL) $(srcdir)/testsuite/gotest --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --testname="$(@D)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files); \ else \ if $(SHELL) $(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" --goarch="$(GOARCH)" $(GOTESTFLAGS) $(go_$(subst /,_,$(@D))_test_files) >>$@-testlog 2>&1; then \ diff -r 27e1a46c9cc2 libgo/configure.ac --- a/libgo/configure.ac Mon Feb 04 17:10:28 2013 -0800 +++ b/libgo/configure.ac Tue Feb 05 14:13:17 2013 -0800 @@ -156,6 +156,17 @@ AM_CONDITIONAL(LIBGO_IS_SOLARIS, test $is_solaris = yes) AC_SUBST(GOOS) +dnl Test whether we need to use DejaGNU or whether we can use the +dnl simpler gotest approach. We can only use gotest for a native +dnl build. +USE_DEJAGNU=no +case ${host} in + *-*-rtems*) USE_DEJAGNU=yes ;; + ${target}) ;; + *) USE_DEJAGNU=yes ;; +esac +AC_SUBST(USE_DEJAGNU) + dnl N.B. Keep in sync with gcc/testsuite/go.test/go-test.exp (go-set-goarch). is_386=no is_alpha=no