diff mbox

[gccgo] Use DejaGNU for libgo tests on RTEMS

Message ID mcrr5iqsd0a.fsf@google.com
State New
Headers show

Commit Message

Ian Lance Taylor July 26, 2010, 11:23 a.m. UTC
This patch from Vinu Rajashekhar uses DejaGNU for the libgo testsuite on
RTEMS.  This permits using the support functions and download functions
provided by DejaGNU.  When not using DejaGNU, the code continues to just
build and run the tests.  This should be changed at some point to only
do the latter when native, and to use DejaGNU when cross.  Committed to
gccgo branch.

Ian
diff mbox

Patch

diff -r 4a339fc1233f libgo/Makefile.am
--- a/libgo/Makefile.am	Mon Jul 26 02:32:00 2010 -0700
+++ b/libgo/Makefile.am	Mon Jul 26 04:20:03 2010 -0700
@@ -9,6 +9,12 @@ 
 # Go support.
 SUFFIXES = .c .go .gox .o .obj .lo .a
 
+if LIBGO_IS_RTEMS
+subdirs = testsuite
+endif
+
+SUBDIRS = ${subdirs}
+
 MAINT_CHARSET = latin1
 
 mkinstalldirs = $(SHELL) $(toplevel_srcdir)/mkinstalldirs
@@ -1167,15 +1173,25 @@ 
 .a.la:
 	$(LINK) $<.lo
 
+if LIBGO_IS_RTEMS
+use_dejagnu = yes
+else
+use_dejagnu = no
+endif
+
 # Check a package.
 CHECK = \
 	@GC="$(GCCGO) -L `${PWD_COMMAND}` -L `${PWD_COMMAND}`/.libs -Wl,-R,`${PWD_COMMAND}`/.libs"; \
 	export GC; \
+	RUNTESTFLAGS="$(RUNTESTFLAGS)"; \
+	export RUNTESTFLAGS; \
+	MAKE="$(MAKE)"; \
+	export MAKE; \
 	rm -f $@-log; \
 	echo -n "$(@D) " >$@-log 2>&1; \
 	prefix=`dirname $(@D)`; \
 	test "$${prefix}" != "." || prefix="$(@D)"; \
-	$(srcdir)/testsuite/gotest --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --prefix="libgo_$${prefix}" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" >>$@-log 2>&1; \
+	$(srcdir)/testsuite/gotest --dejagnu=$(use_dejagnu) --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --prefix="libgo_$${prefix}" --pkgfiles="$(go_$(subst /,_,$(@D))_files)" >>$@-log 2>&1; \
 	x=$$?; \
 	cat $@-log; \
 	exit $$x
@@ -2435,7 +2451,7 @@ 
 	testing/quick/check \
 	testing/script/check
 
-check-am: $(TEST_PACKAGES)
+check-recursive: $(TEST_PACKAGES)
 
 mostlyclean-local:
 	find . -name '*.lo' -print | xargs $(LIBTOOL) --mode=clean rm -f
diff -r 4a339fc1233f libgo/configure.ac
--- a/libgo/configure.ac	Mon Jul 26 02:32:00 2010 -0700
+++ b/libgo/configure.ac	Mon Jul 26 04:20:03 2010 -0700
@@ -208,7 +208,7 @@ 
   multilib_arg=
 fi
 
-AC_CONFIG_FILES(Makefile)
+AC_CONFIG_FILES(Makefile testsuite/Makefile)
 
 AC_CONFIG_COMMANDS([default],
 [if test -n "$CONFIG_FILES"; then
diff -r 4a339fc1233f libgo/testsuite/Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/testsuite/Makefile.am	Mon Jul 26 04:20:03 2010 -0700
@@ -0,0 +1,16 @@ 
+## Process this file with automake to produce Makefile.in.
+
+AUTOMAKE_OPTIONS = foreign dejagnu
+
+# Setup the testing framework, if you have one
+EXPECT = `if [ -f $(top_builddir)/../expect/expect ] ; then \
+            echo $(top_builddir)/../expect/expect ; \
+          else echo expect ; fi`
+
+RUNTEST = `if [ -f $(top_srcdir)/../dejagnu/runtest ] ; then \
+	       echo $(top_srcdir)/../dejagnu/runtest ; \
+	    else echo runtest; fi`
+
+AM_RUNTESTFLAGS =
+
+CLEANFILES = *.log *.sum
diff -r 4a339fc1233f libgo/testsuite/config/default.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/testsuite/config/default.exp	Mon Jul 26 04:20:03 2010 -0700
@@ -0,0 +1,17 @@ 
+#   Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+load_lib "standard.exp"
diff -r 4a339fc1233f libgo/testsuite/gotest
--- a/libgo/testsuite/gotest	Mon Jul 26 02:32:00 2010 -0700
+++ b/libgo/testsuite/gotest	Mon Jul 26 04:20:03 2010 -0700
@@ -3,10 +3,10 @@ 
 # Use of this source code is governed by a BSD-style
 # license that can be found in the LICENSE file.
 
-# Using all the test*.go files in the current directory, write out a file
+# Using all the *_test.go files in the current directory, write out a file
 # _testmain.go that runs all its tests. Compile everything and run the
 # tests.
-# If files are named on the command line, use them instead of test*.go.
+# If files are named on the command line, use them instead of *_test.go.
 
 # Makes egrep,grep work better in general if we put them
 # in ordinary C mode instead of what the current language is.
@@ -29,6 +29,7 @@ 
 loop=true
 keep=false
 prefix=
+dejagnu=no
 while $loop; do
 	case "x$1" in
         x--srcdir)
@@ -71,6 +72,15 @@ 
 		pkgfiles=`echo $1 | sed -e 's/^--pkgfiles=//'`
 		shift
 		;;
+	x--dejagnu)
+		dejagnu=$2
+		shift
+		shift
+		;;
+	x--dejagnu=*)
+		dejagnu=`echo $1 | sed -e 's/^--dejagnu=//'`
+		shift
+		;;
 	x-*)
 		loop=false
 		;;
@@ -296,6 +306,23 @@ 
 	echo '}'
 }>_testmain.go
 
-${GC} -g -c _testmain.go
-${GL} *.o ${GOLIBS}
-./a.out "$@"
+case "x$dejagnu" in
+xno)
+	${GC} -g -c _testmain.go
+	${GL} *.o ${GOLIBS}
+	./a.out "$@"
+	;;
+xyes)
+	# This is the only file which is optionally made.
+	# All others are overwritten on copying/building,
+	# but this may remain and cause conflicts if not
+	# deleted.
+	rm -rf ../testsuite/_xtest_.o
+	cp *.o _testmain.go ../testsuite
+	cd ../testsuite
+	$MAKE check RUNTESTFLAGS="$RUNTESTFLAGS GOTEST_TMPDIR=$DIR"
+	# Useful when using make check-target-libgo
+	cat libgo.log >> libgo-all.log
+	cat libgo.sum >> libgo-all.sum
+	;;
+esac
diff -r 4a339fc1233f libgo/testsuite/lib/libgo.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/testsuite/lib/libgo.exp	Mon Jul 26 04:20:03 2010 -0700
@@ -0,0 +1,41 @@ 
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+proc go_maybe_build_wrapper { args } {
+    libgo_maybe_build_wrapper $args
+}
+
+# DejaGnu does not have proper library search paths for load_lib.
+# We have to explicitly load everything that go.exp wants to load.
+
+proc load_gcc_lib { filename } {
+    global srcdir loaded_libs
+
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+    set loaded_libs($filename) ""
+}
+
+load_gcc_lib prune.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+load_gcc_lib gcc-defs.exp
+load_gcc_lib go.exp
+
+set TESTING_IN_BUILD_TREE 1
+
+proc libgo_init { args } {
+    go_init $args
+}
diff -r 4a339fc1233f libgo/testsuite/libgo.testmain/testmain.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libgo/testsuite/libgo.testmain/testmain.exp	Mon Jul 26 04:20:03 2010 -0700
@@ -0,0 +1,54 @@ 
+# Copyright (C) 2010 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+load_lib libgo.exp
+
+lappend options "additional_flags=-I. -w -g"
+lappend ld_options "ldflags=-lgotesting"
+
+if [istarget "*-*-rtems*"] {
+    global options
+
+    if [catch "exec tar cf FilesystemImage -h -C \
+			 $tool_root_dir/$tool/${GOTEST_TMPDIR} ." error] {
+	perror "Error during tar of local filesystem: $error"
+	exit 1
+    }
+    if [catch "exec ${RTEMS_BIN2C} FilesystemImage FilesystemImage" error] {
+	perror "Error when creating FilesystemImage source file: $error"
+	exit 1
+    }
+    set comp_output [target_compile "${RTEMS_LIBGO_INIT}" \
+			 "./rtems_libgo_init.o" "object" $options]
+    if ![ string match "" $comp_output ] {
+	verbose -log $comp_output
+	exit 1
+    }
+}
+
+set object_files [glob -nocomplain "*.o"]
+regsub $gluefile $object_files "" object_files
+
+lappend options $ld_options
+
+set comp_output [go_target_compile "$object_files _testmain.go" \
+			 "./a.exe" "executable" $options]
+if ![ string match "" $comp_output ] {
+    verbose -log $comp_output
+    exit 1
+}
+verbose -log $comp_output
+libgo_load "./a.exe" "" ""