From patchwork Mon Jul 26 11:23:17 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 59910 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 17BDCB70A7 for ; Mon, 26 Jul 2010 21:23:49 +1000 (EST) Received: (qmail 20824 invoked by alias); 26 Jul 2010 11:23:47 -0000 Received: (qmail 20804 invoked by uid 22791); 26 Jul 2010 11:23:44 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, TW_CC, T_RP_MATCHES_RCVD, T_TVD_MIME_NO_HEADERS X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (74.125.121.35) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Jul 2010 11:23:29 +0000 Received: from hpaq13.eem.corp.google.com (hpaq13.eem.corp.google.com [172.25.149.13]) by smtp-out.google.com with ESMTP id o6QBNRT8028715 for ; Mon, 26 Jul 2010 04:23:27 -0700 Received: from ewy24 (ewy24.prod.google.com [10.241.103.24]) by hpaq13.eem.corp.google.com with ESMTP id o6QBM5At026413 for ; Mon, 26 Jul 2010 04:23:24 -0700 Received: by ewy24 with SMTP id 24so1081156ewy.37 for ; Mon, 26 Jul 2010 04:23:21 -0700 (PDT) Received: by 10.14.29.71 with SMTP id h47mr62331eea.96.1280143401564; Mon, 26 Jul 2010 04:23:21 -0700 (PDT) Received: from coign.google.com (dhcp-172-28-249-136.lul.corp.google.com [172.28.249.136]) by mx.google.com with ESMTPS id v8sm5527248eeh.14.2010.07.26.04.23.19 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Jul 2010 04:23:20 -0700 (PDT) From: Ian Lance Taylor To: gcc-patches@gcc.gnu.org Subject: [gccgo] Use DejaGNU for libgo tests on RTEMS Date: Mon, 26 Jul 2010 04:23:17 -0700 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 -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 +# . + +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 +# . + +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 +# . + +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" "" ""