public inbox for java-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
@ 2011-01-05 18:07 Rainer Orth
  2011-01-05 20:19 ` Dave Korn
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-05 18:07 UTC (permalink / raw)
  To: gcc-patches
  Cc: java-patches, Hans Boehm, Paolo Bonzini, Janis Johnson,
	Ben Elliston, Ralf Wildenhues

I've long maintained that it would be very helpful to convert the
boehm-gc testsuite to DejaGnu:

* It enables multilib testing, giving better test coverage.

* Unlike the present situation, failures are not easily overlooked
  because the results immediately show up in mail-report.log instead of
  being hidden in a multi-megabyte make check output.

  I've many times found that e.g. libjava failures were ultimately cause
  by problems in boehm-gc.

* All DejaGnu features (like timeouts to avoid hanging the whole make
  check run when gctest doesn't complete, target-specific xfails etc.)
  suddenly become available.

Apart from that, I'd thought that boehm-gc would make a good case study
for developing a new DejaGnu tool/testsuite, but that proved wrong since
I had to use libtool to do all the compiling and linking ;-)

Anyway, here's the result, with several points worth mentioning:

* Makefile.am used AUTOMAKE_OPTIONS = cygnus, although the current
  Makefile.in was generated with automake --foreign.  Since I could see
  no reason to stay with cygnus here, I've moved to foreign like most
  (all?) other Makefile.am's.

  UNWINDLIBS was present, but never set anywhere, so I removed it.

  One must not include RUNTEST=$(RUNTEST) in the toplevel Makefile's
  AM_MAKEFLAGS: it isn't set anywhere and breaks make check by passing
  down that empty value.

* I set DEJATOOL = boehm-gc in testsuite/Makefile.am.  The default is
  $PACKAGE, which is gc, but it seemed more intuitive to see boehm-gc in
  mail-report.log, matching the toplevel directory.

  As usual, the site.exp target needs to be overridden to pass the
  configure-determined THREADLIBS and EXTRA_TEST_LIBS down to the
  testsuite.  This is quite messy; it would be far better if automake
  provided some facility for that.

* I've moved all the testcases from tests to subdirectories to
  testsuite/boehm-gc.* where DejaGnu expects them.  Unlike the current
  Makefile.am, where the names of the test sources and executables
  sometimes differ, I've kept the source file names as is, with the
  exception of test.c which I've renamed to gctest.c since that test
  name is quite well-known, I think.

  Three tests weren't run before:

  test_cpp.cc		I haven't bothered yet to add the testsuite goo for a
                	single C++ test.  It can certainly be done if need be,
                	but I'd rather to concentrate on my next project, ACATS
                	to DejaGnu conversion, instead.

  thread_leak_test.c    No apparent reason, just works.

  trace_test.c		Uses GC_generate_random_backtrace which is only
                        available when configuring with
                        --enable-gc-debug, so I'm skipping this
                        everywhere.

* The meat of the testsuite (a new tool in DejaGnu parlance) lives in
  testsuite/lib/boehm-gc.exp.  I've started with the libffi equivalent
  since it was the smallest and further tried to strip it down.

  I see lots of opportunities for code reuse here: most DejaGnu tools in
  GCC started off as a copy of some other tool with search-and-replace
  of the tool name and only a few (if any) local changes.  This is a
  total mess to understand and maintain and I hope to do something about
  this in the future.

  I've tried to identify possibly reusable code and liberally scattered
  lots of FIXME comments all over.  The primary problem right now is to
  get a highlevel picture of the control flow in a tool.  Unfortunately,
  the DejaGnu documentation is somewhat lacking here to put it mildly.
  (To be honest, dg.exp documentation in DejaGnu is completely absent.
  Janis added some documentation to sourcebuild.texi, but more needs to
  be done.  Hopefully I'll be able to contribute here.)

* The primary complication of the boehm-gc testsuite is the
  staticroottest testcase, which depends on a shared library.
  Currently, libtool is used to build that and I think that's the right
  decision rather than duplicating all of libtool's knowledge in
  DejaGnu.

  Unfortunately, DejaGnu knows nothing about libtool yet, and I'm still
  struggling with the right way to integrate it.  For the moment (though
  I fear that wrong, over-complicated) I've chosen to add two additional
  keywords (ltassemble and ltlink) to match assemble and link, but for
  .la, .lo files instead.  I'm open for suggestions for better ways to
  handle this, though.

As I said, there are many FIXMEs embbed below, and I'd be grateful for
suggestions.

Anyway, the code below works fine for me, as can be seen in this excerpt
from i386-pc-solaris2.11 mail-report.log:

		=== boehm-gc tests ===


Running target unix
FAIL: boehm-gc.c/gctest.c -O2 execution test

		=== boehm-gc Summary for unix ===

# of expected passes		11
# of unexpected failures	1
# of unsupported tests		1

Running target unix/-m64

		=== boehm-gc Summary for unix/-m64 ===

# of expected passes		12
# of unsupported tests		1

		=== boehm-gc Summary ===

# of expected passes		23
# of unexpected failures	1
# of unsupported tests		2

This nicely shows the 32-bit-only gctest execution failure which I
mentioned earlier: this only happens with GNU ld, Sun ld is fine.
Without DejaGnu, such a failure would only be noticed if one happened to
look at the make check output or were specificially looking for boehm-gc
issues for some reason.

I don't really know what I'm asking for right now: I fear in it's
current state, the code could be too fragile for trunk and it would be
better to wait until 4.6 branches and then flesh out issues on mainline.

However, all sorts of suggestions, encouragements (or discouragements :-)
are more than welcome.

	Rainer


2010-12-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR boehm-gc/11412
	* Makefile.am (AUTOMAKE_OPTIONS): Use foreign instead of cygnus.
	(SUBDIRS): Add testsuite.
	(libgcjgc_la_LIBADD): Remove $(UNWINDLIBS).
	Remove TESTS related variables.
	(AM_MAKEFLAGS): Don't pass RUNTEST.
	* configure.ac: Add testsuite/Makefile to AC_CONFIG_FILES.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.am: New file.
	* testsuite/Makefile.in: New file.
	* testsuite/lib/boehm-gc.exp: New file.
	* testsuite/config/default.exp: New file.
	* testsuite/boehm-gc.c/c.exp: New file.
	* testsuite/boehm-gc.lib/lib.exp: New file.
	* tests/test.c: Move ...
	* testsuite/boehm-gc.c/gctest.c: ... here.
	* tests/leak_test.c, tests/middle.c, tests/thread_leak_test.c,
	tests/trace_test.c: Move ...
	* testsuite/boehm-gc.c: ... here.
	* testsuite/boehm-gc.c/trace_test.c: Skip everywhere.
	* tests/staticrootslib.c, tests/staticrootstest.c: Move ...
	* testsuite/boehm-gc.lib: ... here.
	* tests/test_cpp.cc: Move ...
	* testsuite/boehm-gc.c++: ... here.

diff -r 71cfe7556b69 boehm-gc/Makefile.am
--- a/boehm-gc/Makefile.am	Sat Jan 01 23:04:07 2011 +0100
+++ b/boehm-gc/Makefile.am	Sat Jan 01 23:52:04 2011 +0100
@@ -4,10 +4,10 @@
 ## files that should be in the distribution are not mentioned in this
 ## Makefile.am.
 
-AUTOMAKE_OPTIONS = cygnus subdir-objects
+AUTOMAKE_OPTIONS = foreign subdir-objects
 ACLOCAL_AMFLAGS = -I .. -I ../config
 
-SUBDIRS = include
+SUBDIRS = include testsuite
 
 noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
 
@@ -35,7 +35,7 @@
 
 # Include THREADLIBS here to ensure that the correct versions of
 # linuxthread semaphore functions get linked:
-libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
+libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
 libgcjgc_la_DEPENDENCIES = $(addobjs)
 libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
 libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
@@ -48,43 +48,6 @@
 AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS)
 
-test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
-
-check_PROGRAMS = gctest
-gctest_SOURCES = tests/test.c
-gctest_LDADD = $(test_ldadd)
-gctest_LDFLAGS = -shared-libgcc
-gctest_LINK = $(LINK) $(gctest_LDFLAGS)
-TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
-TESTS = gctest
-
-TESTS += leaktest$(EXEEXT)
-check_PROGRAMS += leaktest
-leaktest_SOURCES = tests/leak_test.c
-leaktest_LDADD = $(test_ldadd)
-leaktest_LDFLAGS = -shared-libgcc
-leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
-
-TESTS += middletest$(EXEEXT)
-check_PROGRAMS += middletest
-middletest_SOURCES = tests/middle.c
-middletest_LDADD = $(test_ldadd)
-middletest_LDFLAGS = -shared-libgcc
-middletest_LINK = $(LINK) $(middletest_LDFLAGS)
-
-TESTS += staticrootstest$(EXEEXT)
-check_PROGRAMS += staticrootstest
-staticrootstest_SOURCES = tests/staticrootstest.c
-staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
-staticrootstest_LDFLAGS = -shared-libgcc
-staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
-check_LTLIBRARIES = libstaticrootslib.la
-libstaticrootslib_la_SOURCES = tests/staticrootslib.c
-libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
-libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
-				-rpath /nowhere -shared-libgcc
-libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
-
 ## FIXME: we shouldn't have to do this, but automake forces us to.
 .s.lo:
 ## We use -Wp,-P to strip #line directives.  Irix `as' chokes on
@@ -116,7 +79,6 @@
 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
 	"SHELL=$(SHELL)" \
 	"EXPECT=$(EXPECT)" \
-	"RUNTEST=$(RUNTEST)" \
 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
 	"exec_prefix=$(exec_prefix)" \
 	"infodir=$(infodir)" \
diff -r 71cfe7556b69 boehm-gc/configure.ac
--- a/boehm-gc/configure.ac	Sat Jan 01 23:04:07 2011 +0100
+++ b/boehm-gc/configure.ac	Sat Jan 01 23:52:04 2011 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010 by Red Hat, Inc.
+# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010, 2011 by Red Hat, Inc.
 # All rights reserved.
 # Copyright 2004 Nathanael Nerode
 # 
@@ -542,5 +542,5 @@
 
 AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
 
-AC_CONFIG_FILES(Makefile include/Makefile threads.mk)
+AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile threads.mk)
 AC_OUTPUT
diff -r 71cfe7556b69 boehm-gc/testsuite/Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/Makefile.am	Sat Jan 01 23:52:04 2011 +0100
@@ -0,0 +1,43 @@
+## 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`
+
+# Override default.
+DEJATOOL = boehm-gc
+
+CLEANFILES = *.exe core* *.log *.sum
+
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains.  So we overrule automake.  This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo 'set build_alias "$(build_alias)"' >>site.tmp
+	@echo 'set build_triplet $(build_triplet)' >>site.tmp
+	@echo 'set host_alias "$(host_alias)"' >>site.tmp
+	@echo 'set host_triplet $(host_triplet)' >>site.tmp
+	@echo 'set target_alias "$(target_alias)"' >>site.tmp
+	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
+	@echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+	@test ! -f site.exp || \
+	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
diff -r 71cfe7556b69 boehm-gc/testsuite/boehm-gc.c/c.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.c/c.exp	Sat Jan 01 23:52:04 2011 +0100
@@ -0,0 +1,27 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+boehm-gc-init
+
+global srcdir subdir
+
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "-O2" ""
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff -r 71cfe7556b69 boehm-gc/testsuite/boehm-gc.c/trace_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.c/trace_test.c	Sat Jan 01 23:52:04 2011 +0100
@@ -0,0 +1,32 @@
+/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */
+
+#include <stdio.h>
+#define GC_DEBUG
+#include "gc.h"
+
+struct treenode {
+    struct treenode *x;
+    struct treenode *y;
+} * root[10];
+
+struct treenode * mktree(int i) {
+  struct treenode * r = GC_MALLOC(sizeof(struct treenode));
+  if (0 == i) return 0;
+  if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+  r -> x = mktree(i-1);
+  r -> y = mktree(i-1);
+  return r;
+}
+
+int main()
+{
+  int i;
+  for (i = 0; i < 10; ++i) {
+    root[i] = mktree(12);
+  }
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  return 0;
+}
diff -r 71cfe7556b69 boehm-gc/testsuite/boehm-gc.lib/lib.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Sat Jan 01 23:52:04 2011 +0100
@@ -0,0 +1,115 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# FIXME: Comment.
+# Better name?  boehm-gc-build-shlib?
+proc boehm-gc-shlib { lib flags extra-flags } {
+    global subdir
+    global dg-do-what-default
+    global gc_lib_conv
+
+    # Determine basename.
+    # FIXME: Use dg-trim-dirname $srcdir $lib?
+    set nshort "$subdir/[file tail $lib]"
+    set bname "[file rootname [file tail $nshort]]"
+    verbose "bname: $bname"
+
+    set saved-dg-do-what ${dg-do-what-default}
+
+    # FIXME: Maybe do this in one step?
+    # Doesn't work right now?  libtool issue, it seems.
+    set dg-do-what-default ltassemble
+    dg-test -keep-output $lib $flags ${extra-flags}
+
+    # FIXME: Explain.  Turn into parameter?
+    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere -shared-libgcc"
+    set shopt "$shopt $gc_lib_conv"
+
+    # FIXME: Message seems strange: e.g.
+    # PASS: staticrootslib.lo -O2 (test for excess errors)
+    # FIXME: How to avoid knowledge on output filenames?
+    set dg-do-what-default ltlink
+    dg-test -keep-output $bname.lo $flags "${extra-flags} $shopt"
+
+    set dg-do-what-default ${saved-dg-do-what}
+
+    # Remove $bname.*o and .libs/$bname.*o.
+    # FIXME: Might use libtool --mode=clean $bname.lo, but is this right in
+    # cross-compilation scenarios?
+    # What is it?  build, host?
+    set to_delete [glob -nocomplain $bname.*o]
+    set to_delete "$to_delete [glob -nocomplain .libs/$bname.*o]"
+    eval remote_file build delete $to_delete
+
+    return lib$bname.la
+}
+
+# FIXME: Comment.
+proc boehm-gc-lib-dg-runtest { testcases flags extra-flags } {
+    global runtests
+
+    foreach testcase $testcases {
+	# If we're only testing specific files and this isn't one of them, skip it.
+	if ![runtest_file_p $runtests $testcase] {
+	    return
+	}
+
+	# Library source corresponding to test file.
+	regsub "test\.c$" $testcase "lib.c" lib
+	verbose "lib: $lib"
+
+	# Build support library.
+	# FIXME: Handle via dg-add-shlib keyword?
+	# If so, boehm-gc.lib becomes unnecessary.
+	set shlib [boehm-gc-shlib $lib $flags ${extra-flags}]
+
+	# Run testcase, linking with support library.
+	dg-test $testcase $flags "${extra-flags} $shlib"
+
+	# Remove $shlib, .libs/$shlib.*.
+	# FIXME: Could the removal be done in a more general place?
+	# Where is the rest of the removal done?
+	set to_delete $shlib
+	set to_delete "$to_delete [glob -nocomplain .libs/[file rootname $shlib].*]"
+
+	# FIXME: Doesn't delete .libs/libstaticrootslib.la and
+	# .libs/libstaticrootslib.so.1, why?
+	# Bug in remote.exp (standard_file): checks file exists and file
+	# isfile first!?
+	eval remote_file build delete $to_delete
+
+	# Remove .libs/$execname.
+	# FIXME: Should go into the framework somewhere, but dg-final
+	# cannot be used since that is reset every time dg-test runs.
+	remote_file build delete .libs/[file rootname [file tail $testcase]]
+    }
+}
+
+dg-init
+boehm-gc-init
+
+global srcdir subdir
+
+# Gather list of tests, skipping library source files.
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
+set tests [prune $tests $srcdir/$subdir/*lib.c]
+
+boehm-gc-lib-dg-runtest $tests "-O2" ""
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff -r 71cfe7556b69 boehm-gc/testsuite/config/default.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/config/default.exp	Sat Jan 01 23:52:04 2011 +0100
@@ -0,0 +1,1 @@
+load_lib "standard.exp"
diff -r 71cfe7556b69 boehm-gc/testsuite/lib/boehm-gc.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/lib/boehm-gc.exp	Sat Jan 01 23:52:04 2011 +0100
@@ -0,0 +1,235 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+proc load_gcc_lib { filename } {
+    global srcdir
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+}
+
+load_lib dg.exp
+load_lib libgloss.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+# Required by target-supports-dg.exp.
+load_gcc_lib target-supports.exp
+# For dg-skip-if.
+load_gcc_lib target-supports-dg.exp
+
+set dg-do-what-default run
+
+# Define boehm-gc callbacks for dg.exp.
+
+# FIXME: The next two are Independent of boehm-gc; move to some library.
+proc ${tool}-dg-test-1 { target_compile prog do_what extra_tool_flags } {
+
+    # Set up the compiler flags, based on what we're going to do.
+
+    set options [list]
+    switch $do_what {
+	"compile" {
+	    set compile_type "assembly"
+	    set output_file "[file rootname [file tail $prog]].s"
+	}
+        "assemble" {
+            set compile_type "object"
+            set output_file "[file rootname [file tail $prog]].o"
+        }
+	# FIXME: Really need different do_what's for libtool?
+        "ltassemble" {
+            set compile_type "object"
+            set output_file "[file rootname [file tail $prog]].lo"
+        }
+	"link" {
+	    set compile_type "executable"
+	    set output_file "[file rootname [file tail $prog]]"
+	}
+	# FIXME: See above.
+	"ltlink" {
+	    set compile_type "executable"
+	    set output_file "lib[file rootname [file tail $prog]].la"
+	}
+	"run" {
+	    set compile_type "executable"
+	    # FIXME: "./" is to cope with "." not being in $PATH.
+	    # Should this be handled elsewhere?
+	    # YES.
+	    set output_file "./[file rootname [file tail $prog]]"
+	    # This is the only place where we care if an executable was
+	    # created or not.  If it was, dg.exp will try to run it.
+	    remote_file build delete $output_file
+	}
+	default {
+	    perror "$do_what: not a valid dg-do keyword"
+	    return ""
+	}
+    }
+
+    if { $extra_tool_flags != "" } {
+	lappend options "additional_flags=$extra_tool_flags"
+    }
+
+    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options];
+
+    return [list $comp_output $output_file]
+}
+
+proc ${tool}-dg-test { prog do_what extra_tool_flags } {
+    global tool
+
+    return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what $extra_tool_flags]
+}
+
+proc ${tool}-init { args } {
+    global gluefile wrap_flags
+    global srcdir
+    global blddirgc
+    global TOOL_EXECUTABLE
+    global GCC_UNDER_TEST
+    global objdir
+    global gc_include
+    global gc_lib
+    global gc_lib_conv
+    global tool
+    global tool_root_dir
+    global ld_library_path
+
+    set blddirgc [lookfor_file [get_multilibs] ${tool}]
+    verbose "blddirgc: $blddirgc"
+
+    if ![info exists GCC_UNDER_TEST] then {
+	if [info exists TOOL_EXECUTABLE] {
+	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
+	} else {
+	    set GCC_UNDER_TEST "[find_gcc]"
+	}
+    }
+
+    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+    if {$gccdir != ""} {
+	set gccdir [file dirname $gccdir]
+    }
+    verbose "gccdir: $gccdir"
+
+    set ld_library_path "."
+    append ld_library_path ":${gccdir}"
+
+    set compiler "${gccdir}/xgcc"
+    if { [is_remote host] == 0 && [which $compiler] != 0 } {
+	foreach i "[exec $compiler --print-multi-lib]" {
+	    set mldir ""
+	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+	    set mldir [string trimright $mldir "\;@"]
+	    if { "$mldir" == "." } {
+		continue
+	    }
+	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+		append ld_library_path ":${gccdir}/${mldir}"
+	    }
+	}
+    }
+    # Add the library path for boehm-gc.
+    append ld_library_path ":${blddirgc}/.libs"
+
+    # Add the library path for boehm-gc.lib libtool libraries.
+    # FIXME: Do this here instead of in driver?
+    append ld_library_path ":.libs"
+
+    # FIXME: ld_library_path is doubled!?
+    # Starts at 'Setting LD_LIBRARY_PATH to ...'; from config/unix.exp
+    # (unix_load).
+    # Seems that lib/target-libpath.exp (set_ld_library_path_env_vars sets
+    # it first and unix_load doubles it.
+    verbose "ld_library_path: $ld_library_path"
+
+    # Point to the headers in boehm-gc.
+    set gc_include "${blddirgc}/include"
+    verbose "gc_include: $gc_include"
+
+    set gc_lib "${blddirgc}/libgcjgc.la"
+    verbose "gc_lib: $gc_lib"
+
+    set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la"
+    verbose "gc_lib_conv: $gc_lib_conv"
+
+    set_ld_library_path_env_vars
+    ${tool}_maybe_build_wrapper "${objdir}/testglue.o"
+}
+
+proc ${tool}_finish { } {
+    # FIXME: Remove .libs?
+}
+
+proc ${tool}_exit { } {
+    global gluefile;
+
+    if [info exists gluefile] {
+	file_on_build delete $gluefile;
+	unset gluefile;
+    }
+}
+
+proc ${tool}_target_compile { source dest type options } {
+    global gluefile wrap_flags;
+    global srcdir
+    global TOOL_OPTIONS
+    global GCC_UNDER_TEST
+    global gc_include
+    global gc_lib
+    global gc_lib_conv
+    global threadlibs
+    global extra_test_libs
+
+    if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
+	lappend options "libs=${gluefile}"
+	lappend options "ldflags=$wrap_flags"
+    }
+
+    # TOOL_OPTIONS must come first, so that it doesn't override testcase
+    # specific options.
+    if [info exists TOOL_OPTIONS] {
+	lappend  options [concat "additional_flags=$TOOL_OPTIONS" $options];
+    }
+
+    # Map type to libtool mode.
+    switch $type {
+	"object" {
+	    set mode "compile"
+	}
+	"executable" {
+	    set mode "link"
+	}
+	default {
+	    perror "$type: unhandled mode"
+	    return ""
+	}
+    }
+
+    # We have to run silently to avoid DejaGnu lossage.
+    lappend options "compiler=../libtool --silent --tag=CC --mode=$mode \
+	$GCC_UNDER_TEST"
+
+    lappend options "additional_flags=-I${gc_include} -I${srcdir}/../include"
+
+    lappend options "libs= -shared-libgcc"
+    lappend options "libs= ${gc_lib} ${threadlibs} ${extra_test_libs}"
+
+    verbose "options: $options"
+    return [target_compile $source $dest $type $options]
+}
+
+# Local Variables:
+# tcl-indent-level:4
+# End:

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 18:07 [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412) Rainer Orth
@ 2011-01-05 20:19 ` Dave Korn
  2011-01-05 20:25   ` Joseph S. Myers
  2011-02-18  7:51   ` Mike Stump
  2011-01-05 20:22 ` Dave Korn
  2011-01-06 21:17 ` Ralf Wildenhues
  2 siblings, 2 replies; 21+ messages in thread
From: Dave Korn @ 2011-01-05 20:19 UTC (permalink / raw)
  To: Rainer Orth
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston, Ralf Wildenhues

On 05/01/2011 18:06, Rainer Orth wrote:

    Hi Rainer,

> * The primary complication of the boehm-gc testsuite is the
>   staticroottest testcase, which depends on a shared library.
>   Currently, libtool is used to build that and I think that's the right
>   decision rather than duplicating all of libtool's knowledge in
>   DejaGnu.
> 
>   Unfortunately, DejaGnu knows nothing about libtool yet, and I'm still
>   struggling with the right way to integrate it.  For the moment (though
>   I fear that wrong, over-complicated) I've chosen to add two additional
>   keywords (ltassemble and ltlink) to match assemble and link, but for
>   .la, .lo files instead.  I'm open for suggestions for better ways to
>   handle this, though.

  Perhaps just build it in the makefile, as at present, and make the .la file
a dependency of the check target, so that it gets built before starting the
testrun?  (Or conceivably if worried about it failing to build on some target
and that stopping the tests from running, build it using a recursive $(MAKE)
invocation, using the "-" prefix to ignore errors?)

    cheers,
      DaveK


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 18:07 [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412) Rainer Orth
  2011-01-05 20:19 ` Dave Korn
@ 2011-01-05 20:22 ` Dave Korn
  2011-01-10 10:44   ` Rainer Orth
  2011-02-18  7:55   ` Mike Stump
  2011-01-06 21:17 ` Ralf Wildenhues
  2 siblings, 2 replies; 21+ messages in thread
From: Dave Korn @ 2011-01-05 20:22 UTC (permalink / raw)
  To: Rainer Orth
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston, Ralf Wildenhues


  I should probably have read further before hitting send... here's a couple
more comments:

On 05/01/2011 18:06, Rainer Orth wrote:

> I don't really know what I'm asking for right now: I fear in it's
> current state, the code could be too fragile for trunk and it would be
> better to wait until 4.6 branches and then flesh out issues on mainline.

  I think this is unambiguously stage1 material.  But that doesn't mean you
can't post it now and get a deferred "OK once trunk is back in stage1".

> However, all sorts of suggestions, encouragements (or discouragements :-)
> are more than welcome.

  I do think it's an definite good idea, for all the reasons you suggested.

    cheers,
      DaveK



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 20:19 ` Dave Korn
@ 2011-01-05 20:25   ` Joseph S. Myers
  2011-01-05 20:29     ` Dave Korn
  2011-02-18  7:51   ` Mike Stump
  1 sibling, 1 reply; 21+ messages in thread
From: Joseph S. Myers @ 2011-01-05 20:25 UTC (permalink / raw)
  To: Dave Korn
  Cc: Rainer Orth, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston, Ralf Wildenhues

On Wed, 5 Jan 2011, Dave Korn wrote:

>   Perhaps just build it in the makefile, as at present, and make the .la file
> a dependency of the check target, so that it gets built before starting the
> testrun?  (Or conceivably if worried about it failing to build on some target

Please no building of any files required by testsuites (other than 
site.exp) from makefiles; that breaks installed toolchain testing (where 
you should only need to create site.exp and run runtest with appropriate 
options).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 20:25   ` Joseph S. Myers
@ 2011-01-05 20:29     ` Dave Korn
  2011-01-10 10:42       ` Rainer Orth
  0 siblings, 1 reply; 21+ messages in thread
From: Dave Korn @ 2011-01-05 20:29 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: Rainer Orth, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston, Ralf Wildenhues

On 05/01/2011 20:25, Joseph S. Myers wrote:
> On Wed, 5 Jan 2011, Dave Korn wrote:
> 
>>   Perhaps just build it in the makefile, as at present, and make the .la file
>> a dependency of the check target, so that it gets built before starting the
>> testrun?  (Or conceivably if worried about it failing to build on some target
> 
> Please no building of any files required by testsuites (other than 
> site.exp) from makefiles; that breaks installed toolchain testing (where 
> you should only need to create site.exp and run runtest with appropriate 
> options).

  Argh.  But then again, boehm-gc doesn't get installed, so there is no
possibility of testing the installed one anyway.  So how about saying it's ok
in those circumstances?

    cheers,
      DaveK



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 18:07 [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412) Rainer Orth
  2011-01-05 20:19 ` Dave Korn
  2011-01-05 20:22 ` Dave Korn
@ 2011-01-06 21:17 ` Ralf Wildenhues
  2011-01-10 10:41   ` Rainer Orth
  2011-01-17 12:12   ` Rainer Orth
  2 siblings, 2 replies; 21+ messages in thread
From: Ralf Wildenhues @ 2011-01-06 21:17 UTC (permalink / raw)
  To: Rainer Orth
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston

Hello Rainer,

* Rainer Orth wrote on Wed, Jan 05, 2011 at 07:06:56PM CET:
> I've long maintained that it would be very helpful to convert the
> boehm-gc testsuite to DejaGnu:
> 
> * It enables multilib testing, giving better test coverage.

I don't understand.  Why should the current tests not be run in multilib
setting?  Does toplevel not enter $target/$MULTIDIR/boehm-gc for check?

> * I set DEJATOOL = boehm-gc in testsuite/Makefile.am.  The default is
>   $PACKAGE, which is gc, but it seemed more intuitive to see boehm-gc in
>   mail-report.log, matching the toplevel directory.
> 
>   As usual, the site.exp target needs to be overridden to pass the
>   configure-determined THREADLIBS and EXTRA_TEST_LIBS down to the
>   testsuite.  This is quite messy; it would be far better if automake
>   provided some facility for that.

Can you open an Automake bug (send mail to bug-automake) with the
features a better support from Automake should have?  Thanks.
I'm still very much a DejaGNU newbie.

> * The primary complication of the boehm-gc testsuite is the
>   staticroottest testcase, which depends on a shared library.
>   Currently, libtool is used to build that and I think that's the right
>   decision rather than duplicating all of libtool's knowledge in
>   DejaGnu.
> 
>   Unfortunately, DejaGnu knows nothing about libtool yet, and I'm still
>   struggling with the right way to integrate it.  For the moment (though
>   I fear that wrong, over-complicated) I've chosen to add two additional
>   keywords (ltassemble and ltlink) to match assemble and link, but for
>   .la, .lo files instead.  I'm open for suggestions for better ways to
>   handle this, though.

I'd be happy to try to help if there are libtool questions, but AFAICS
the issue is mostly how to teach dejagnu how to use it?

> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Sat Jan 01 23:52:04 2011 +0100

> +    # FIXME: Explain.  Turn into parameter?
> +    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere -shared-libgcc"

You need to prefix -shared-libgcc with -Wc, to get it past libtool.
When creating shared libraries, libtool drops most flags that it does
not know about (and that it could do the wrong thing with if passed),
so with -Wc, you're telling it that you know what you're doing.
(And -shared-libgcc actually might not work correctly in all cases,
which is what I mean with "it does not know about a flag").

> +    set shopt "$shopt $gc_lib_conv"

> +    # Remove $bname.*o and .libs/$bname.*o.
> +    # FIXME: Might use libtool --mode=clean $bname.lo, but is this right in

Missing 'rm -f' after --mode=clean.

> +    # cross-compilation scenarios?

Why should it not be?

> +    # What is it?  build, host?
> +    set to_delete [glob -nocomplain $bname.*o]
> +    set to_delete "$to_delete [glob -nocomplain .libs/$bname.*o]"
> +    eval remote_file build delete $to_delete
> +
> +    return lib$bname.la
> +}
> +
> +# FIXME: Comment.
> +proc boehm-gc-lib-dg-runtest { testcases flags extra-flags } {
> +    global runtests
> +
> +    foreach testcase $testcases {
> +	# If we're only testing specific files and this isn't one of them, skip it.
> +	if ![runtest_file_p $runtests $testcase] {
> +	    return
> +	}
> +
> +	# Library source corresponding to test file.
> +	regsub "test\.c$" $testcase "lib.c" lib
> +	verbose "lib: $lib"
> +
> +	# Build support library.
> +	# FIXME: Handle via dg-add-shlib keyword?
> +	# If so, boehm-gc.lib becomes unnecessary.
> +	set shlib [boehm-gc-shlib $lib $flags ${extra-flags}]
> +
> +	# Run testcase, linking with support library.
> +	dg-test $testcase $flags "${extra-flags} $shlib"
> +
> +	# Remove $shlib, .libs/$shlib.*.
> +	# FIXME: Could the removal be done in a more general place?
> +	# Where is the rest of the removal done?

Can't you use 'libtool --mode=clean' here as well?

> +	set to_delete $shlib
> +	set to_delete "$to_delete [glob -nocomplain .libs/[file rootname $shlib].*]"
> +
> +	# FIXME: Doesn't delete .libs/libstaticrootslib.la and
> +	# .libs/libstaticrootslib.so.1, why?
> +	# Bug in remote.exp (standard_file): checks file exists and file
> +	# isfile first!?
> +	eval remote_file build delete $to_delete
> +
> +	# Remove .libs/$execname.
> +	# FIXME: Should go into the framework somewhere, but dg-final
> +	# cannot be used since that is reset every time dg-test runs.
> +	remote_file build delete .libs/[file rootname [file tail $testcase]]
> +    }
> +}
> +
> +dg-init
> +boehm-gc-init
> +
> +global srcdir subdir
> +
> +# Gather list of tests, skipping library source files.
> +set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
> +set tests [prune $tests $srcdir/$subdir/*lib.c]
> +
> +boehm-gc-lib-dg-runtest $tests "-O2" ""
> +dg-finish

Cheers,
Ralf

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-06 21:17 ` Ralf Wildenhues
@ 2011-01-10 10:41   ` Rainer Orth
  2011-02-18  8:02     ` Mike Stump
  2011-01-17 12:12   ` Rainer Orth
  1 sibling, 1 reply; 21+ messages in thread
From: Rainer Orth @ 2011-01-10 10:41 UTC (permalink / raw)
  To: Ralf Wildenhues
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston

Hello Ralf,

> * Rainer Orth wrote on Wed, Jan 05, 2011 at 07:06:56PM CET:
>> I've long maintained that it would be very helpful to convert the
>> boehm-gc testsuite to DejaGnu:
>> 
>> * It enables multilib testing, giving better test coverage.
>
> I don't understand.  Why should the current tests not be run in multilib
> setting?  Does toplevel not enter $target/$MULTIDIR/boehm-gc for check?

while make check in a non-default multilib directory works (well, sort
of: it doesn't look for the right libgcc_s.so.1), the check-TESTS
target, which ultimately does this testing, isn't multilib-aware.  Seems
like an automake problem to me (unless there is some flag to change
that; haven't looked).

>> * I set DEJATOOL = boehm-gc in testsuite/Makefile.am.  The default is
>>   $PACKAGE, which is gc, but it seemed more intuitive to see boehm-gc in
>>   mail-report.log, matching the toplevel directory.
>> 
>>   As usual, the site.exp target needs to be overridden to pass the
>>   configure-determined THREADLIBS and EXTRA_TEST_LIBS down to the
>>   testsuite.  This is quite messy; it would be far better if automake
>>   provided some facility for that.
>
> Can you open an Automake bug (send mail to bug-automake) with the
> features a better support from Automake should have?  Thanks.
> I'm still very much a DejaGNU newbie.

Sure, will do.

>> * The primary complication of the boehm-gc testsuite is the
>>   staticroottest testcase, which depends on a shared library.
>>   Currently, libtool is used to build that and I think that's the right
>>   decision rather than duplicating all of libtool's knowledge in
>>   DejaGnu.
>> 
>>   Unfortunately, DejaGnu knows nothing about libtool yet, and I'm still
>>   struggling with the right way to integrate it.  For the moment (though
>>   I fear that wrong, over-complicated) I've chosen to add two additional
>>   keywords (ltassemble and ltlink) to match assemble and link, but for
>>   .la, .lo files instead.  I'm open for suggestions for better ways to
>>   handle this, though.
>
> I'd be happy to try to help if there are libtool questions, but AFAICS
> the issue is mostly how to teach dejagnu how to use it?

I've now thought a bit more about that: the relevant DejaGnu procedures
only have the input filename available to them, so cannot distinguish
between compiling an input file into a regular or a libtool object.  So
I will need the ltassemble (compile .c etc. into .lo) type to go with
assemble (.c -> .o).  On the other hand, for --mode=link, I can see if
the input file is a .lo or a .o and select the output filename
accordingly, so my former ltlink can go.

>> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
>> +++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Sat Jan 01 23:52:04 2011 +0100
>
>> +    # FIXME: Explain.  Turn into parameter?
>> +    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere -shared-libgcc"
>
> You need to prefix -shared-libgcc with -Wc, to get it past libtool.
> When creating shared libraries, libtool drops most flags that it does
> not know about (and that it could do the wrong thing with if passed),
> so with -Wc, you're telling it that you know what you're doing.
> (And -shared-libgcc actually might not work correctly in all cases,
> which is what I mean with "it does not know about a flag").

Fixed, thanks.

>> +    set shopt "$shopt $gc_lib_conv"
>
>> +    # Remove $bname.*o and .libs/$bname.*o.
>> +    # FIXME: Might use libtool --mode=clean $bname.lo, but is this right in
>
> Missing 'rm -f' after --mode=clean.

Right, fixed.

>> +    # cross-compilation scenarios?
>
> Why should it not be?

This may be just me not fully understanding the possible scenarios here:
while a basic cross should work, what about a canadian cross (build !=
host != target)?  The rm would have to be run on the host, but with
libtool would run on the build machine.  I have no idea if boehm-gc (or
any other of the libtool libraries in GCC) work properly in such cases,
though: the most I've tried so far is a basic cross to speed up
reghunting for slow targets where possible.

Maybe Joseph can shed some light here?

>> +	# Run testcase, linking with support library.
>> +	dg-test $testcase $flags "${extra-flags} $shlib"
>> +
>> +	# Remove $shlib, .libs/$shlib.*.
>> +	# FIXME: Could the removal be done in a more general place?
>> +	# Where is the rest of the removal done?
>
> Can't you use 'libtool --mode=clean' here as well?

Sure: if it works about, it will here, too.  However, I think this would
better be handled inside ${tool}-dg-test-1 than individually in each
testsuite: that's what I meant by `more general place'.

I've just done some cleanup work on the gnat.dg testsuite that gave me
some ideas for this.

In fact, I'm mostly done with a cleaned-up version of my patch that I'm
almost happy with.  I'll just have to work around a DejaGnu issue
(cannot invoke dg-test inside a running dg-test call, which I have fixed
in dg.exp itself for testing), then I'll post the result for review.

Thanks for your feedback.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 20:29     ` Dave Korn
@ 2011-01-10 10:42       ` Rainer Orth
  0 siblings, 0 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-10 10:42 UTC (permalink / raw)
  To: Dave Korn
  Cc: Joseph S. Myers, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston, Ralf Wildenhues

Dave Korn <dave.korn.cygwin@gmail.com> writes:

> On 05/01/2011 20:25, Joseph S. Myers wrote:
>> On Wed, 5 Jan 2011, Dave Korn wrote:
>> 
>>>   Perhaps just build it in the makefile, as at present, and make the .la file
>>> a dependency of the check target, so that it gets built before starting the
>>> testrun?  (Or conceivably if worried about it failing to build on some target
>> 
>> Please no building of any files required by testsuites (other than 
>> site.exp) from makefiles; that breaks installed toolchain testing (where 
>> you should only need to create site.exp and run runtest with appropriate 
>> options).
>
>   Argh.  But then again, boehm-gc doesn't get installed, so there is no
> possibility of testing the installed one anyway.  So how about saying it's ok
> in those circumstances?

I'm still with Joseph here: performing testsuite runs with a mixture of
DejaGnu board facilities and external stuff is hard to understand and
debug, so stay with one.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 20:22 ` Dave Korn
@ 2011-01-10 10:44   ` Rainer Orth
  2011-02-18  7:55   ` Mike Stump
  1 sibling, 0 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-10 10:44 UTC (permalink / raw)
  To: Dave Korn
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston, Ralf Wildenhues

Dave Korn <dave.korn.cygwin@gmail.com> writes:

> On 05/01/2011 18:06, Rainer Orth wrote:
>
>> I don't really know what I'm asking for right now: I fear in it's
>> current state, the code could be too fragile for trunk and it would be
>> better to wait until 4.6 branches and then flesh out issues on mainline.
>
>   I think this is unambiguously stage1 material.  But that doesn't mean you
> can't post it now and get a deferred "OK once trunk is back in stage1".

Ok.  The trouble will probably be finding someone to review and approve
that stuff, stage 1 or not.

>> However, all sorts of suggestions, encouragements (or discouragements :-)
>> are more than welcome.
>
>   I do think it's an definite good idea, for all the reasons you suggested.

Thanks.  Looking at the current libgo testsuite makes me think so as
well :-)

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-06 21:17 ` Ralf Wildenhues
  2011-01-10 10:41   ` Rainer Orth
@ 2011-01-17 12:12   ` Rainer Orth
  2011-01-17 13:32     ` IainS
  2011-01-18 20:21     ` Ralf Wildenhues
  1 sibling, 2 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-17 12:12 UTC (permalink / raw)
  To: Ralf Wildenhues
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston

Hi Ralf,

I've now got a patch I'm reasonably happy with.  It incorporates all the
review comments.  Tested on i386-pc-solaris2.10, i386-pc-solaris2.10 and
sparc-sun-solaris2.11.

Since I'm performing a call to dg-test from within another dg-test
invocation (dg-test -> dg-add-shlib -> dg-test), I have to work around
the fact that this doesn't work in DejaGnu 1.4.4.  I'll submit a DejaGnu
patch shortly, but ${tool}-build-shlib works without and with this patch.

The patch below omits all but two of the renamed files (the exceptions
being trace_test.c, which aquired a dg-skip-if, and staticsroottest.c,
which got a dg-add-shlib).

Ok for mainline (either now, or, more likely, after 4.6 branches?

	Rainer

2010-12-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>

	PR boehm-gc/11412
	* Makefile.am (AUTOMAKE_OPTIONS): Use foreign instead of cygnus.
	(SUBDIRS): Add testsuite.
	(libgcjgc_la_LIBADD): Remove $(UNWINDLIBS).
	Remove TESTS related variables.
	(AM_MAKEFLAGS): Don't pass RUNTEST.
	* configure.ac: Add testsuite/Makefile to AC_CONFIG_FILES.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* testsuite/Makefile.am: New file.
	* testsuite/Makefile.in: New file.
	* testsuite/lib/boehm-gc.exp: New file.
	* testsuite/config/default.exp: New file.
	* testsuite/boehm-gc.c/c.exp: New file.
	* testsuite/boehm-gc.lib/lib.exp: New file.
	* tests/test.c: Move ...
	* testsuite/boehm-gc.c/gctest.c: ... here.
	* tests/leak_test.c, tests/middle.c, tests/thread_leak_test.c,
	tests/trace_test.c: Move ...
	* testsuite/boehm-gc.c: ... here.
	* testsuite/boehm-gc.c/trace_test.c: Skip everywhere.
	* tests/staticrootslib.c, tests/staticrootstest.c: Move ...
	* testsuite/boehm-gc.lib: ... here.
	* testsuite/boehm-gc.lib/staticrootstest.c: Use dg-add-shlib
	staticrootslib.c.
	* tests/test_cpp.cc: Move ...
	* testsuite/boehm-gc.c++: ... here.

diff -r b725b6092024 boehm-gc/Makefile.am
--- a/boehm-gc/Makefile.am	Fri Jan 14 21:53:19 2011 +0100
+++ b/boehm-gc/Makefile.am	Sat Jan 15 16:53:57 2011 +0100
@@ -4,10 +4,10 @@
 ## files that should be in the distribution are not mentioned in this
 ## Makefile.am.
 
-AUTOMAKE_OPTIONS = cygnus subdir-objects
+AUTOMAKE_OPTIONS = foreign subdir-objects
 ACLOCAL_AMFLAGS = -I .. -I ../config
 
-SUBDIRS = include
+SUBDIRS = include testsuite
 
 noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
 
@@ -35,7 +35,7 @@
 
 # Include THREADLIBS here to ensure that the correct versions of
 # linuxthread semaphore functions get linked:
-libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
+libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
 libgcjgc_la_DEPENDENCIES = $(addobjs)
 libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
 libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
@@ -48,43 +48,6 @@
 AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS)
 
-test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
-
-check_PROGRAMS = gctest
-gctest_SOURCES = tests/test.c
-gctest_LDADD = $(test_ldadd)
-gctest_LDFLAGS = -shared-libgcc
-gctest_LINK = $(LINK) $(gctest_LDFLAGS)
-TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
-TESTS = gctest
-
-TESTS += leaktest$(EXEEXT)
-check_PROGRAMS += leaktest
-leaktest_SOURCES = tests/leak_test.c
-leaktest_LDADD = $(test_ldadd)
-leaktest_LDFLAGS = -shared-libgcc
-leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
-
-TESTS += middletest$(EXEEXT)
-check_PROGRAMS += middletest
-middletest_SOURCES = tests/middle.c
-middletest_LDADD = $(test_ldadd)
-middletest_LDFLAGS = -shared-libgcc
-middletest_LINK = $(LINK) $(middletest_LDFLAGS)
-
-TESTS += staticrootstest$(EXEEXT)
-check_PROGRAMS += staticrootstest
-staticrootstest_SOURCES = tests/staticrootstest.c
-staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
-staticrootstest_LDFLAGS = -shared-libgcc
-staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
-check_LTLIBRARIES = libstaticrootslib.la
-libstaticrootslib_la_SOURCES = tests/staticrootslib.c
-libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
-libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
-				-rpath /nowhere -shared-libgcc
-libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
-
 ## FIXME: we shouldn't have to do this, but automake forces us to.
 .s.lo:
 ## We use -Wp,-P to strip #line directives.  Irix `as' chokes on
@@ -116,7 +79,6 @@
 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
 	"SHELL=$(SHELL)" \
 	"EXPECT=$(EXPECT)" \
-	"RUNTEST=$(RUNTEST)" \
 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
 	"exec_prefix=$(exec_prefix)" \
 	"infodir=$(infodir)" \
diff -r b725b6092024 boehm-gc/configure.ac
--- a/boehm-gc/configure.ac	Fri Jan 14 21:53:19 2011 +0100
+++ b/boehm-gc/configure.ac	Sat Jan 15 16:53:57 2011 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010 by Red Hat, Inc.
+# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010, 2011 by Red Hat, Inc.
 # All rights reserved.
 # Copyright 2004 Nathanael Nerode
 # 
@@ -544,5 +544,5 @@
 
 AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
 
-AC_CONFIG_FILES(Makefile include/Makefile threads.mk)
+AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile threads.mk)
 AC_OUTPUT
diff -r b725b6092024 boehm-gc/testsuite/Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/Makefile.am	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,43 @@
+## 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`
+
+# Override default.
+DEJATOOL = boehm-gc
+
+CLEANFILES = *.exe core* *.log *.sum
+
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains.  So we overrule automake.  This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo 'set build_alias "$(build_alias)"' >>site.tmp
+	@echo 'set build_triplet $(build_triplet)' >>site.tmp
+	@echo 'set host_alias "$(host_alias)"' >>site.tmp
+	@echo 'set host_triplet $(host_triplet)' >>site.tmp
+	@echo 'set target_alias "$(target_alias)"' >>site.tmp
+	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
+	@echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+	@test ! -f site.exp || \
+	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
diff -r b725b6092024 boehm-gc/testsuite/boehm-gc.c/c.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.c/c.exp	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,25 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+${tool}-init
+
+${tool}-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "-O2" ""
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff -r b725b6092024 boehm-gc/testsuite/boehm-gc.c/trace_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.c/trace_test.c	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,32 @@
+/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */
+
+#include <stdio.h>
+#define GC_DEBUG
+#include "gc.h"
+
+struct treenode {
+    struct treenode *x;
+    struct treenode *y;
+} * root[10];
+
+struct treenode * mktree(int i) {
+  struct treenode * r = GC_MALLOC(sizeof(struct treenode));
+  if (0 == i) return 0;
+  if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+  r -> x = mktree(i-1);
+  r -> y = mktree(i-1);
+  return r;
+}
+
+int main()
+{
+  int i;
+  for (i = 0; i < 10; ++i) {
+    root[i] = mktree(12);
+  }
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  return 0;
+}
diff -r b725b6092024 boehm-gc/testsuite/boehm-gc.lib/lib.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,30 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+${tool}-init
+
+# Gather list of tests, skipping library source files.
+# FIXME: How does this happen for dg-additional-sources?
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
+set tests [prune $tests $srcdir/$subdir/*lib.c]
+
+${tool}-dg-runtest $tests "-O2" ""
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,48 @@
+/* { dg-add-shlib "staticrootslib.c" } */
+
+#include <stdio.h>
+
+#ifndef GC_DEBUG
+# define GC_DEBUG
+#endif
+
+#include "gc.h"
+#include "gc_backptr.h"
+
+struct treenode {
+    struct treenode *x;
+    struct treenode *y;
+} * root[10];
+
+static char *staticroot = 0;
+
+extern struct treenode * libsrl_mktree(int i);
+extern void * libsrl_init(void);
+extern void * libsrl_collect (void);
+
+int main(void)
+{
+  int i;
+  staticroot = libsrl_init();
+  for (i = 0; i < sizeof(struct treenode); ++i) {
+    staticroot[i] = 0x42;
+  }
+  libsrl_collect();
+  for (i = 0; i < 10; ++i) {
+    root[i] = libsrl_mktree(12);
+    libsrl_collect();
+  }
+  for (i = 0; i < sizeof(struct treenode); ++i) {
+    if (staticroot[i] != 0x42)
+      return -1;
+  }
+  for (i = 0; i < 10; ++i) {
+    root[i] = libsrl_mktree(12);
+    libsrl_collect();
+  }
+  for (i = 0; i < sizeof(struct treenode); ++i) {
+    if (staticroot[i] != 0x42)
+      return -1;
+  }
+  return 0;
+}
diff -r b725b6092024 boehm-gc/testsuite/config/default.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/config/default.exp	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,1 @@
+load_lib "standard.exp"
diff -r b725b6092024 boehm-gc/testsuite/lib/boehm-gc.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/lib/boehm-gc.exp	Sat Jan 15 16:53:57 2011 +0100
@@ -0,0 +1,322 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+proc load_gcc_lib { filename } {
+    global srcdir loaded_libs
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+    set loaded_libs($filename) ""
+}
+
+load_lib dg.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+# Required by target-supports-dg.exp.
+load_gcc_lib target-supports.exp
+# For dg-skip-if.
+load_gcc_lib target-supports-dg.exp
+# For ${tool}_exit.
+load_gcc_lib gcc-defs.exp
+
+set dg-do-what-default run
+
+# Define boehm-gc callbacks for dg.exp.
+
+# FIXME: The next two are independent of boehm-gc; move to some library.
+proc ${tool}-dg-test-1 { target_compile prog do_what extra_tool_flags } {
+
+    # Set up the compiler flags, based on what we're going to do.
+
+    set options [list]
+    switch $do_what {
+	"compile" {
+	    set compile_type "assembly"
+	    set output_file "[file rootname [file tail $prog]].s"
+	}
+        "assemble" {
+            set compile_type "object"
+            set output_file "[file rootname [file tail $prog]].o"
+        }
+        "ltassemble" {
+	    # Needs to be different from assemble since we cannot determine
+	    # from $prog whether to produce a regular or a libtool object.
+            set compile_type "object"
+            set output_file "[file rootname [file tail $prog]].lo"
+        }
+	"link" {
+	    set compile_type "executable"
+	    set output_file "[file rootname [file tail $prog]]"
+	    # If we're linking a libtool object, produce a libtool library.
+	    if { [file extension $prog] == ".lo" } {
+		set output_file "lib$output_file.la"
+	    }
+	}
+	"run" {
+	    set compile_type "executable"
+	    # FIXME: "./" is to cope with "." not being in $PATH.
+	    # Should this be handled elsewhere?
+	    # YES.
+	    set output_file "./[file rootname [file tail $prog]]"
+	    # This is the only place where we care if an executable was
+	    # created or not.  If it was, dg.exp will try to run it.
+	    remote_file build delete $output_file
+	}
+	default {
+	    perror "$do_what: not a valid dg-do keyword"
+	    return ""
+	}
+    }
+
+    if { $extra_tool_flags != "" } {
+	lappend options "additional_flags=$extra_tool_flags"
+    }
+
+    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options];
+
+    return [list $comp_output $output_file]
+}
+
+proc ${tool}-dg-test { prog do_what extra_tool_flags } {
+    global tool
+
+    return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what $extra_tool_flags]
+}
+
+proc ${tool}-init { args } {
+    global gluefile wrap_flags
+    global srcdir
+    global blddirgc
+    global TOOL_EXECUTABLE
+    global GCC_UNDER_TEST
+    global objdir
+    global gc_include
+    global gc_lib
+    global gc_lib_conv
+    global tool
+    global tool_root_dir
+    global ld_library_path
+
+    set blddirgc [lookfor_file [get_multilibs] ${tool}]
+    verbose "blddirgc: $blddirgc"
+
+    if ![info exists GCC_UNDER_TEST] then {
+	if [info exists TOOL_EXECUTABLE] {
+	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
+	} else {
+	    set GCC_UNDER_TEST "[find_gcc]"
+	}
+    }
+
+    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+    if {$gccdir != ""} {
+	set gccdir [file dirname $gccdir]
+    }
+    verbose "gccdir: $gccdir"
+
+    set ld_library_path "."
+    append ld_library_path ":${gccdir}"
+
+    set compiler "${gccdir}/xgcc"
+    if { [is_remote host] == 0 && [which $compiler] != 0 } {
+	foreach i "[exec $compiler --print-multi-lib]" {
+	    set mldir ""
+	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+	    set mldir [string trimright $mldir "\;@"]
+	    if { "$mldir" == "." } {
+		continue
+	    }
+	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+		append ld_library_path ":${gccdir}/${mldir}"
+	    }
+	}
+    }
+    # Add the library path for boehm-gc.
+    append ld_library_path ":${blddirgc}/.libs"
+
+    # Add the library path for boehm-gc.lib libtool libraries.
+    append ld_library_path ":.libs"
+
+    verbose "ld_library_path: $ld_library_path"
+
+    # Point to the headers in boehm-gc.
+    set gc_include "${blddirgc}/include"
+    verbose "gc_include: $gc_include"
+
+    set gc_lib "${blddirgc}/libgcjgc.la"
+    verbose "gc_lib: $gc_lib"
+
+    set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la"
+    verbose "gc_lib_conv: $gc_lib_conv"
+
+    set_ld_library_path_env_vars
+    ${tool}_maybe_build_wrapper "${objdir}/testglue.o"
+}
+
+proc ${tool}_target_compile { source dest type options } {
+    global gluefile wrap_flags;
+    global srcdir
+    global TOOL_OPTIONS
+    global GCC_UNDER_TEST
+    global libtool
+    global gc_include
+    global gc_lib
+    global gc_lib_conv
+    global threadlibs
+    global extra_test_libs
+
+    if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
+	lappend options "libs=${gluefile}"
+	lappend options "ldflags=$wrap_flags"
+    }
+
+    # TOOL_OPTIONS must come first, so that it doesn't override testcase
+    # specific options.
+    if [info exists TOOL_OPTIONS] {
+	lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
+    }
+
+    # Map type to libtool mode.
+    switch $type {
+	"object" {
+	    set mode "compile"
+	}
+	"executable" {
+	    set mode "link"
+	}
+	default {
+	    perror "$type: unhandled type"
+	    return ""
+	}
+    }
+
+    # Set this once for reuse in boehm-gc.lib/lib.exp.
+    set libtool "../libtool"
+    # We have to run silently to avoid DejaGnu lossage.
+    lappend options "compiler=$libtool --silent --tag=CC --mode=$mode \
+	$GCC_UNDER_TEST"
+
+    lappend options "additional_flags=-I${gc_include} -I${srcdir}/../include"
+
+    lappend options "libs= -Wc,-shared-libgcc"
+    lappend options "libs= ${gc_lib} ${threadlibs} ${extra_test_libs}"
+
+    verbose "options: $options"
+    return [target_compile $source $dest $type $options]
+}
+
+# Build shared library from LIB.
+proc ${tool}-build-shlib { lib flags extra-flags } {
+    global subdir
+    global dg-do-what-default
+    global libtool
+    global gc_lib_conv
+
+    # Determine basename.
+    set basename "[file rootname [file tail $lib]]"
+    verbose "basename: $basename"
+
+    # DejaGnu 1.4.4 doesn't support nested calls to dg-test.  Restore
+    # original state before calling it again.
+    if { [info procs dg-save-unknown] != [list] } {
+	rename unknown ""
+	rename dg-save-unknown unknown
+    }
+
+    set saved-dg-do-what ${dg-do-what-default}
+
+    # Compile $lib into libtool object.
+    set dg-do-what-default ltassemble
+    dg-test -keep-output $lib $flags ${extra-flags}
+
+    # FIXME: Explain options.
+    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere"
+    # Prefix -shared-libgcc with -Wc, to get it through libtool.
+    lappend shopt -Wc,-shared-libgcc
+    # Link with libgcjgc convenience library.
+    lappend shopt $gc_lib_conv
+
+    # There's no way to get output_file out of dg-test, only
+    # ${tool}-dg-test returns it, so hardcode that here.
+    set dg-do-what-default link
+    dg-test -keep-output $basename.lo $flags "${extra-flags} $shopt"
+
+    set dg-do-what-default ${saved-dg-do-what}
+
+    # Restore unknown, dg-save-unknown as DejaGnu 1.4.4 dg-test expects them.
+    if { [info procs dg-save-unknown] == [list] } {
+    	rename unknown dg-save-unknown
+	proc unknown {} {
+	}
+    }
+
+    catch { exec $libtool --mode=clean rm -f $basename.lo }
+
+    return lib$basename.la
+}
+
+# Handle dg-add-shlib.
+proc dg-add-shlib { args } {
+    global tool
+    global srcdir subdir
+    global shlib
+
+    if { [llength $args] > 2 } {
+	error "[lindex $args 0]: too many arguments"
+	return
+    }
+
+    set lib [lindex $args 1]
+    set lib "$srcdir/$subdir/$lib"
+    verbose -log "dg-add-shlib $lib"
+
+    upvar tool_flags flags
+    upvar default_extra_tool_flags extra-flags
+    # Build support library.
+    set shlib [${tool}-build-shlib $lib $flags ${extra-flags}]
+
+    uplevel lappend tool_flags $shlib
+}
+
+# Run boehm-gc testcases.
+proc ${tool}-dg-runtest { testcases flags extra-flags } {
+    global runtests
+    global libtool
+    global shlib
+
+    set shlib ""
+
+    foreach testcase $testcases {
+	# If we're only testing specific files and this isn't one of them,
+	# skip it.
+	if ![runtest_file_p $runtests $testcase] {
+	    return
+	}
+
+	# Run testcase.
+	# Keep output, otherwise libtool below won't remove the corresponding
+	# file in .libs.
+	dg-test -keep-output $testcase $flags ${extra-flags}
+
+	# Remove $execname and eventually $shlib.
+	# FIXME: Is $execname right e.g. on Windows?
+	# FIXME: Better way to get at $shlib?
+	verbose -log "$libtool --mode=clean rm -f [file rootname [file tail $testcase]] $shlib"
+	catch { exec $libtool --mode=clean rm -f [file rootname [file tail $testcase]] $shlib }
+    }
+}
+
+# Local Variables:
+# tcl-indent-level:4
+# End:


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-17 12:12   ` Rainer Orth
@ 2011-01-17 13:32     ` IainS
  2011-01-17 14:04       ` Rainer Orth
  2011-01-24 14:02       ` Rainer Orth
  2011-01-18 20:21     ` Ralf Wildenhues
  1 sibling, 2 replies; 21+ messages in thread
From: IainS @ 2011-01-17 13:32 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Ralf Wildenhues, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston

Hi Rainer,

great stuff!
One issue on powerpc-darwin9****
(which I would expect to manifest on *-*-darwin*)

On 17 Jan 2011, at 12:11, Rainer Orth wrote:
> I've now got a patch I'm reasonably happy with.  It incorporates all  
> the
> review comments.  Tested on i386-pc-solaris2.10, i386-pc-solaris2.10  
> and
> sparc-sun-solaris2.11.

+
Native configuration is powerpc-apple-darwin9

                 === boehm-gc tests ===

Schedule of variations:
     unix/-m32
     unix/-m64

Running target unix/-m32
Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as  
board description file for target.
Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as  
generic interface file for target.
Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as  
tool-and-target-specific interface file.
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...
FAIL: staticrootslib.lo -O2 (test for excess errors)

[[[ **** this is failing because of ranlib output:

Executing on host: ../libtool --silent --tag=CC --mode=link  /GCC/ 
gcc-4-6-trunk-build/gcc/xgcc -B/GCC/gcc-4-6-trunk-build/gcc/  
staticrootslib.lo /GCC/gcc-4-6-tr
unk-build/powerpc-apple-darwin9/./boehm-gc/libgcjgc.la  -O2  -version- 
info 1:2:0 -no-undefined -rpath /nowhere -Wc,-shared-libgcc /GCC/ 
gcc-4-6-trunk-build/power
pc-apple-darwin9/./boehm-gc/libgcjgc_convenience.la -I/GCC/gcc-4-6- 
trunk-build/powerpc-apple-darwin9/./boehm-gc/include -I/GCC/gcc-live- 
trunk/boehm-gc/testsuite
/../include  -Wc,-shared-libgcc -lpthread -lm   -m32 -o  
libstaticrootslib.la    (timeout = 300)
ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
<snip>
ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols
output is:
ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
<snip>
ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols

I would imagine that a similar situation must have been handled  
somewhere else in the test-suite - but not sure where... ]]]

                 === boehm-gc Summary for unix/-m32 ===

# of expected passes            11
# of unexpected failures        1
# of unsupported tests          1
Running target unix/-m64
Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as  
board description file for target.
Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as  
generic interface file for target.
Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as  
tool-and-target-specific interface file.
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...
FAIL: staticrootslib.lo -O2 (test for excess errors)

**** as per m32.

                 === boehm-gc Summary for unix/-m64 ===

# of expected passes            11
# of unexpected failures        1
# of unsupported tests          1

                 === boehm-gc Summary ===

# of expected passes            22
# of unexpected failures        2
# of unsupported tests          2

:-)


> Since I'm performing a call to dg-test from within another dg-test
> invocation (dg-test -> dg-add-shlib -> dg-test), I have to work around
> the fact that this doesn't work in DejaGnu 1.4.4.  I'll submit a  
> DejaGnu
> patch shortly, but ${tool}-build-shlib works without and with this  
> patch.
>
> The patch below omits all but two of the renamed files (the exceptions
> being trace_test.c, which aquired a dg-skip-if, and staticsroottest.c,
> which got a dg-add-shlib).
>
> Ok for mainline (either now, or, more likely, after 4.6 branches?

my 0.02 euro...
since AFAIK these tests are
(a) currently unreported by the regression testers, and ...
(b) only applied for the native lib unless one does it by hand ...
- ISTM that we would only be improving test coverage by applying this  
for 4.6.

(but not my call, of course).

cheers
Iain

>
> 	Rainer
>
> 2010-12-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
>
> 	PR boehm-gc/11412
> 	* Makefile.am (AUTOMAKE_OPTIONS): Use foreign instead of cygnus.
> 	(SUBDIRS): Add testsuite.
> 	(libgcjgc_la_LIBADD): Remove $(UNWINDLIBS).
> 	Remove TESTS related variables.
> 	(AM_MAKEFLAGS): Don't pass RUNTEST.
> 	* configure.ac: Add testsuite/Makefile to AC_CONFIG_FILES.
> 	* Makefile.in: Regenerate.
> 	* configure: Regenerate.
> 	* testsuite/Makefile.am: New file.
> 	* testsuite/Makefile.in: New file.
> 	* testsuite/lib/boehm-gc.exp: New file.
> 	* testsuite/config/default.exp: New file.
> 	* testsuite/boehm-gc.c/c.exp: New file.
> 	* testsuite/boehm-gc.lib/lib.exp: New file.
> 	* tests/test.c: Move ...
> 	* testsuite/boehm-gc.c/gctest.c: ... here.
> 	* tests/leak_test.c, tests/middle.c, tests/thread_leak_test.c,
> 	tests/trace_test.c: Move ...
> 	* testsuite/boehm-gc.c: ... here.
> 	* testsuite/boehm-gc.c/trace_test.c: Skip everywhere.
> 	* tests/staticrootslib.c, tests/staticrootstest.c: Move ...
> 	* testsuite/boehm-gc.lib: ... here.
> 	* testsuite/boehm-gc.lib/staticrootstest.c: Use dg-add-shlib
> 	staticrootslib.c.
> 	* tests/test_cpp.cc: Move ...
> 	* testsuite/boehm-gc.c++: ... here.
>
> diff -r b725b6092024 boehm-gc/Makefile.am
> --- a/boehm-gc/Makefile.am	Fri Jan 14 21:53:19 2011 +0100
> +++ b/boehm-gc/Makefile.am	Sat Jan 15 16:53:57 2011 +0100
> @@ -4,10 +4,10 @@
> ## files that should be in the distribution are not mentioned in this
> ## Makefile.am.
>
> -AUTOMAKE_OPTIONS = cygnus subdir-objects
> +AUTOMAKE_OPTIONS = foreign subdir-objects
> ACLOCAL_AMFLAGS = -I .. -I ../config
>
> -SUBDIRS = include
> +SUBDIRS = include testsuite
>
> noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
>
> @@ -35,7 +35,7 @@
>
> # Include THREADLIBS here to ensure that the correct versions of
> # linuxthread semaphore functions get linked:
> -libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
> +libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
> libgcjgc_la_DEPENDENCIES = $(addobjs)
> libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 - 
> rpath $(toolexeclibdir)
> libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
> @@ -48,43 +48,6 @@
> AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
> override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS)
>
> -test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $ 
> (EXTRA_TEST_LIBS)
> -
> -check_PROGRAMS = gctest
> -gctest_SOURCES = tests/test.c
> -gctest_LDADD = $(test_ldadd)
> -gctest_LDFLAGS = -shared-libgcc
> -gctest_LINK = $(LINK) $(gctest_LDFLAGS)
> -TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
> -TESTS = gctest
> -
> -TESTS += leaktest$(EXEEXT)
> -check_PROGRAMS += leaktest
> -leaktest_SOURCES = tests/leak_test.c
> -leaktest_LDADD = $(test_ldadd)
> -leaktest_LDFLAGS = -shared-libgcc
> -leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
> -
> -TESTS += middletest$(EXEEXT)
> -check_PROGRAMS += middletest
> -middletest_SOURCES = tests/middle.c
> -middletest_LDADD = $(test_ldadd)
> -middletest_LDFLAGS = -shared-libgcc
> -middletest_LINK = $(LINK) $(middletest_LDFLAGS)
> -
> -TESTS += staticrootstest$(EXEEXT)
> -check_PROGRAMS += staticrootstest
> -staticrootstest_SOURCES = tests/staticrootstest.c
> -staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
> -staticrootstest_LDFLAGS = -shared-libgcc
> -staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
> -check_LTLIBRARIES = libstaticrootslib.la
> -libstaticrootslib_la_SOURCES = tests/staticrootslib.c
> -libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
> -libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
> -				-rpath /nowhere -shared-libgcc
> -libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
> -
> ## FIXME: we shouldn't have to do this, but automake forces us to.
> .s.lo:
> ## We use -Wp,-P to strip #line directives.  Irix `as' chokes on
> @@ -116,7 +79,6 @@
> 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
> 	"SHELL=$(SHELL)" \
> 	"EXPECT=$(EXPECT)" \
> -	"RUNTEST=$(RUNTEST)" \
> 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
> 	"exec_prefix=$(exec_prefix)" \
> 	"infodir=$(infodir)" \
> diff -r b725b6092024 boehm-gc/configure.ac
> --- a/boehm-gc/configure.ac	Fri Jan 14 21:53:19 2011 +0100
> +++ b/boehm-gc/configure.ac	Sat Jan 15 16:53:57 2011 +0100
> @@ -1,4 +1,4 @@
> -# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010 by Red  
> Hat, Inc.
> +# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010, 2011 by  
> Red Hat, Inc.
> # All rights reserved.
> # Copyright 2004 Nathanael Nerode
> #
> @@ -544,5 +544,5 @@
>
> AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
>
> -AC_CONFIG_FILES(Makefile include/Makefile threads.mk)
> +AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile  
> threads.mk)
> AC_OUTPUT
> diff -r b725b6092024 boehm-gc/testsuite/Makefile.am
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/Makefile.am	Sat Jan 15 16:53:57 2011 +0100
> @@ -0,0 +1,43 @@
> +## 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`
> +
> +# Override default.
> +DEJATOOL = boehm-gc
> +
> +CLEANFILES = *.exe core* *.log *.sum
> +
> +# We need more things in site.exp, but automake completely controls  
> the
> +# creation of that file; there's no way to append to it without  
> messing up
> +# the dependancy chains.  So we overrule automake.  This rule is  
> exactly
> +# what it would have generated, plus our own additions.
> +site.exp: Makefile
> +	@echo 'Making a new site.exp file...'
> +	@echo '## these variables are automatically generated by make ##'  
> >site.tmp
> +	@echo '# Do not edit here.  If you wish to override these values'  
> >>site.tmp
> +	@echo '# edit the last section' >>site.tmp
> +	@echo 'set srcdir $(srcdir)' >>site.tmp
> +	@echo "set objdir `pwd`" >>site.tmp
> +	@echo 'set build_alias "$(build_alias)"' >>site.tmp
> +	@echo 'set build_triplet $(build_triplet)' >>site.tmp
> +	@echo 'set host_alias "$(host_alias)"' >>site.tmp
> +	@echo 'set host_triplet $(host_triplet)' >>site.tmp
> +	@echo 'set target_alias "$(target_alias)"' >>site.tmp
> +	@echo 'set target_triplet $(target_triplet)' >>site.tmp
> +	@echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
> +	@echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
> +	@echo '## All variables above are generated by configure. Do Not  
> Edit ##' >>site.tmp
> +	@test ! -f site.exp || \
> +	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
> +	@-rm -f site.bak
> +	@test ! -f site.exp || mv site.exp site.bak
> +	@mv site.tmp site.exp
> diff -r b725b6092024 boehm-gc/testsuite/boehm-gc.c/c.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.c/c.exp	Sat Jan 15 16:53:57 2011  
> +0100
> @@ -0,0 +1,25 @@
> +# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +dg-init
> +${tool}-init
> +
> +${tool}-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "- 
> O2" ""
> +dg-finish
> +
> +# Local Variables:
> +# tcl-indent-level:4
> +# End:
> diff -r b725b6092024 boehm-gc/testsuite/boehm-gc.c/trace_test.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.c/trace_test.c	Sat Jan 15 16:53:57  
> 2011 +0100
> @@ -0,0 +1,32 @@
> +/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */
> +
> +#include <stdio.h>
> +#define GC_DEBUG
> +#include "gc.h"
> +
> +struct treenode {
> +    struct treenode *x;
> +    struct treenode *y;
> +} * root[10];
> +
> +struct treenode * mktree(int i) {
> +  struct treenode * r = GC_MALLOC(sizeof(struct treenode));
> +  if (0 == i) return 0;
> +  if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
> +  r -> x = mktree(i-1);
> +  r -> y = mktree(i-1);
> +  return r;
> +}
> +
> +int main()
> +{
> +  int i;
> +  for (i = 0; i < 10; ++i) {
> +    root[i] = mktree(12);
> +  }
> +  GC_generate_random_backtrace();
> +  GC_generate_random_backtrace();
> +  GC_generate_random_backtrace();
> +  GC_generate_random_backtrace();
> +  return 0;
> +}
> diff -r b725b6092024 boehm-gc/testsuite/boehm-gc.lib/lib.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Sat Jan 15 16:53:57  
> 2011 +0100
> @@ -0,0 +1,30 @@
> +# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +dg-init
> +${tool}-init
> +
> +# Gather list of tests, skipping library source files.
> +# FIXME: How does this happen for dg-additional-sources?
> +set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
> +set tests [prune $tests $srcdir/$subdir/*lib.c]
> +
> +${tool}-dg-runtest $tests "-O2" ""
> +dg-finish
> +
> +# Local Variables:
> +# tcl-indent-level:4
> +# End:
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c	Sat Jan 15  
> 16:53:57 2011 +0100
> @@ -0,0 +1,48 @@
> +/* { dg-add-shlib "staticrootslib.c" } */
> +
> +#include <stdio.h>
> +
> +#ifndef GC_DEBUG
> +# define GC_DEBUG
> +#endif
> +
> +#include "gc.h"
> +#include "gc_backptr.h"
> +
> +struct treenode {
> +    struct treenode *x;
> +    struct treenode *y;
> +} * root[10];
> +
> +static char *staticroot = 0;
> +
> +extern struct treenode * libsrl_mktree(int i);
> +extern void * libsrl_init(void);
> +extern void * libsrl_collect (void);
> +
> +int main(void)
> +{
> +  int i;
> +  staticroot = libsrl_init();
> +  for (i = 0; i < sizeof(struct treenode); ++i) {
> +    staticroot[i] = 0x42;
> +  }
> +  libsrl_collect();
> +  for (i = 0; i < 10; ++i) {
> +    root[i] = libsrl_mktree(12);
> +    libsrl_collect();
> +  }
> +  for (i = 0; i < sizeof(struct treenode); ++i) {
> +    if (staticroot[i] != 0x42)
> +      return -1;
> +  }
> +  for (i = 0; i < 10; ++i) {
> +    root[i] = libsrl_mktree(12);
> +    libsrl_collect();
> +  }
> +  for (i = 0; i < sizeof(struct treenode); ++i) {
> +    if (staticroot[i] != 0x42)
> +      return -1;
> +  }
> +  return 0;
> +}
> diff -r b725b6092024 boehm-gc/testsuite/config/default.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/config/default.exp	Sat Jan 15 16:53:57 2011  
> +0100
> @@ -0,0 +1,1 @@
> +load_lib "standard.exp"
> diff -r b725b6092024 boehm-gc/testsuite/lib/boehm-gc.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/lib/boehm-gc.exp	Sat Jan 15 16:53:57 2011  
> +0100
> @@ -0,0 +1,322 @@
> +# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +proc load_gcc_lib { filename } {
> +    global srcdir loaded_libs
> +    load_file $srcdir/../../gcc/testsuite/lib/$filename
> +    set loaded_libs($filename) ""
> +}
> +
> +load_lib dg.exp
> +load_gcc_lib target-libpath.exp
> +load_gcc_lib wrapper.exp
> +# Required by target-supports-dg.exp.
> +load_gcc_lib target-supports.exp
> +# For dg-skip-if.
> +load_gcc_lib target-supports-dg.exp
> +# For ${tool}_exit.
> +load_gcc_lib gcc-defs.exp
> +
> +set dg-do-what-default run
> +
> +# Define boehm-gc callbacks for dg.exp.
> +
> +# FIXME: The next two are independent of boehm-gc; move to some  
> library.
> +proc ${tool}-dg-test-1 { target_compile prog do_what  
> extra_tool_flags } {
> +
> +    # Set up the compiler flags, based on what we're going to do.
> +
> +    set options [list]
> +    switch $do_what {
> +	"compile" {
> +	    set compile_type "assembly"
> +	    set output_file "[file rootname [file tail $prog]].s"
> +	}
> +        "assemble" {
> +            set compile_type "object"
> +            set output_file "[file rootname [file tail $prog]].o"
> +        }
> +        "ltassemble" {
> +	    # Needs to be different from assemble since we cannot determine
> +	    # from $prog whether to produce a regular or a libtool object.
> +            set compile_type "object"
> +            set output_file "[file rootname [file tail $prog]].lo"
> +        }
> +	"link" {
> +	    set compile_type "executable"
> +	    set output_file "[file rootname [file tail $prog]]"
> +	    # If we're linking a libtool object, produce a libtool library.
> +	    if { [file extension $prog] == ".lo" } {
> +		set output_file "lib$output_file.la"
> +	    }
> +	}
> +	"run" {
> +	    set compile_type "executable"
> +	    # FIXME: "./" is to cope with "." not being in $PATH.
> +	    # Should this be handled elsewhere?
> +	    # YES.
> +	    set output_file "./[file rootname [file tail $prog]]"
> +	    # This is the only place where we care if an executable was
> +	    # created or not.  If it was, dg.exp will try to run it.
> +	    remote_file build delete $output_file
> +	}
> +	default {
> +	    perror "$do_what: not a valid dg-do keyword"
> +	    return ""
> +	}
> +    }
> +
> +    if { $extra_tool_flags != "" } {
> +	lappend options "additional_flags=$extra_tool_flags"
> +    }
> +
> +    set comp_output [$target_compile "$prog" "$output_file"  
> "$compile_type" $options];
> +
> +    return [list $comp_output $output_file]
> +}
> +
> +proc ${tool}-dg-test { prog do_what extra_tool_flags } {
> +    global tool
> +
> +    return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what  
> $extra_tool_flags]
> +}
> +
> +proc ${tool}-init { args } {
> +    global gluefile wrap_flags
> +    global srcdir
> +    global blddirgc
> +    global TOOL_EXECUTABLE
> +    global GCC_UNDER_TEST
> +    global objdir
> +    global gc_include
> +    global gc_lib
> +    global gc_lib_conv
> +    global tool
> +    global tool_root_dir
> +    global ld_library_path
> +
> +    set blddirgc [lookfor_file [get_multilibs] ${tool}]
> +    verbose "blddirgc: $blddirgc"
> +
> +    if ![info exists GCC_UNDER_TEST] then {
> +	if [info exists TOOL_EXECUTABLE] {
> +	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
> +	} else {
> +	    set GCC_UNDER_TEST "[find_gcc]"
> +	}
> +    }
> +
> +    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
> +    if {$gccdir != ""} {
> +	set gccdir [file dirname $gccdir]
> +    }
> +    verbose "gccdir: $gccdir"
> +
> +    set ld_library_path "."
> +    append ld_library_path ":${gccdir}"
> +
> +    set compiler "${gccdir}/xgcc"
> +    if { [is_remote host] == 0 && [which $compiler] != 0 } {
> +	foreach i "[exec $compiler --print-multi-lib]" {
> +	    set mldir ""
> +	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
> +	    set mldir [string trimright $mldir "\;@"]
> +	    if { "$mldir" == "." } {
> +		continue
> +	    }
> +	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/ 
> libgcc_s*.so.*]] >= 1 } {
> +		append ld_library_path ":${gccdir}/${mldir}"
> +	    }
> +	}
> +    }
> +    # Add the library path for boehm-gc.
> +    append ld_library_path ":${blddirgc}/.libs"
> +
> +    # Add the library path for boehm-gc.lib libtool libraries.
> +    append ld_library_path ":.libs"
> +
> +    verbose "ld_library_path: $ld_library_path"
> +
> +    # Point to the headers in boehm-gc.
> +    set gc_include "${blddirgc}/include"
> +    verbose "gc_include: $gc_include"
> +
> +    set gc_lib "${blddirgc}/libgcjgc.la"
> +    verbose "gc_lib: $gc_lib"
> +
> +    set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la"
> +    verbose "gc_lib_conv: $gc_lib_conv"
> +
> +    set_ld_library_path_env_vars
> +    ${tool}_maybe_build_wrapper "${objdir}/testglue.o"
> +}
> +
> +proc ${tool}_target_compile { source dest type options } {
> +    global gluefile wrap_flags;
> +    global srcdir
> +    global TOOL_OPTIONS
> +    global GCC_UNDER_TEST
> +    global libtool
> +    global gc_include
> +    global gc_lib
> +    global gc_lib_conv
> +    global threadlibs
> +    global extra_test_libs
> +
> +    if { [target_info needs_status_wrapper]!="" && [info exists  
> gluefile] } {
> +	lappend options "libs=${gluefile}"
> +	lappend options "ldflags=$wrap_flags"
> +    }
> +
> +    # TOOL_OPTIONS must come first, so that it doesn't override  
> testcase
> +    # specific options.
> +    if [info exists TOOL_OPTIONS] {
> +	lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
> +    }
> +
> +    # Map type to libtool mode.
> +    switch $type {
> +	"object" {
> +	    set mode "compile"
> +	}
> +	"executable" {
> +	    set mode "link"
> +	}
> +	default {
> +	    perror "$type: unhandled type"
> +	    return ""
> +	}
> +    }
> +
> +    # Set this once for reuse in boehm-gc.lib/lib.exp.
> +    set libtool "../libtool"
> +    # We have to run silently to avoid DejaGnu lossage.
> +    lappend options "compiler=$libtool --silent --tag=CC --mode= 
> $mode \
> +	$GCC_UNDER_TEST"
> +
> +    lappend options "additional_flags=-I${gc_include} -I$ 
> {srcdir}/../include"
> +
> +    lappend options "libs= -Wc,-shared-libgcc"
> +    lappend options "libs= ${gc_lib} ${threadlibs} $ 
> {extra_test_libs}"
> +
> +    verbose "options: $options"
> +    return [target_compile $source $dest $type $options]
> +}
> +
> +# Build shared library from LIB.
> +proc ${tool}-build-shlib { lib flags extra-flags } {
> +    global subdir
> +    global dg-do-what-default
> +    global libtool
> +    global gc_lib_conv
> +
> +    # Determine basename.
> +    set basename "[file rootname [file tail $lib]]"
> +    verbose "basename: $basename"
> +
> +    # DejaGnu 1.4.4 doesn't support nested calls to dg-test.  Restore
> +    # original state before calling it again.
> +    if { [info procs dg-save-unknown] != [list] } {
> +	rename unknown ""
> +	rename dg-save-unknown unknown
> +    }
> +
> +    set saved-dg-do-what ${dg-do-what-default}
> +
> +    # Compile $lib into libtool object.
> +    set dg-do-what-default ltassemble
> +    dg-test -keep-output $lib $flags ${extra-flags}
> +
> +    # FIXME: Explain options.
> +    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere"
> +    # Prefix -shared-libgcc with -Wc, to get it through libtool.
> +    lappend shopt -Wc,-shared-libgcc
> +    # Link with libgcjgc convenience library.
> +    lappend shopt $gc_lib_conv
> +
> +    # There's no way to get output_file out of dg-test, only
> +    # ${tool}-dg-test returns it, so hardcode that here.
> +    set dg-do-what-default link
> +    dg-test -keep-output $basename.lo $flags "${extra-flags} $shopt"
> +
> +    set dg-do-what-default ${saved-dg-do-what}
> +
> +    # Restore unknown, dg-save-unknown as DejaGnu 1.4.4 dg-test  
> expects them.
> +    if { [info procs dg-save-unknown] == [list] } {
> +    	rename unknown dg-save-unknown
> +	proc unknown {} {
> +	}
> +    }
> +
> +    catch { exec $libtool --mode=clean rm -f $basename.lo }
> +
> +    return lib$basename.la
> +}
> +
> +# Handle dg-add-shlib.
> +proc dg-add-shlib { args } {
> +    global tool
> +    global srcdir subdir
> +    global shlib
> +
> +    if { [llength $args] > 2 } {
> +	error "[lindex $args 0]: too many arguments"
> +	return
> +    }
> +
> +    set lib [lindex $args 1]
> +    set lib "$srcdir/$subdir/$lib"
> +    verbose -log "dg-add-shlib $lib"
> +
> +    upvar tool_flags flags
> +    upvar default_extra_tool_flags extra-flags
> +    # Build support library.
> +    set shlib [${tool}-build-shlib $lib $flags ${extra-flags}]
> +
> +    uplevel lappend tool_flags $shlib
> +}
> +
> +# Run boehm-gc testcases.
> +proc ${tool}-dg-runtest { testcases flags extra-flags } {
> +    global runtests
> +    global libtool
> +    global shlib
> +
> +    set shlib ""
> +
> +    foreach testcase $testcases {
> +	# If we're only testing specific files and this isn't one of them,
> +	# skip it.
> +	if ![runtest_file_p $runtests $testcase] {
> +	    return
> +	}
> +
> +	# Run testcase.
> +	# Keep output, otherwise libtool below won't remove the  
> corresponding
> +	# file in .libs.
> +	dg-test -keep-output $testcase $flags ${extra-flags}
> +
> +	# Remove $execname and eventually $shlib.
> +	# FIXME: Is $execname right e.g. on Windows?
> +	# FIXME: Better way to get at $shlib?
> +	verbose -log "$libtool --mode=clean rm -f [file rootname [file  
> tail $testcase]] $shlib"
> +	catch { exec $libtool --mode=clean rm -f [file rootname [file tail  
> $testcase]] $shlib }
> +    }
> +}
> +
> +# Local Variables:
> +# tcl-indent-level:4
> +# End:
>
>
> -- 
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-17 13:32     ` IainS
@ 2011-01-17 14:04       ` Rainer Orth
  2011-01-24 14:02       ` Rainer Orth
  1 sibling, 0 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-17 14:04 UTC (permalink / raw)
  To: IainS
  Cc: Ralf Wildenhues, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston

Hi Iain,

> One issue on powerpc-darwin9****
> (which I would expect to manifest on *-*-darwin*)
[...]
> [[[ **** this is failing because of ranlib output:
>
> Executing on host: ../libtool --silent --tag=CC --mode=link  /GCC/
> gcc-4-6-trunk-build/gcc/xgcc -B/GCC/gcc-4-6-trunk-build/gcc/
> staticrootslib.lo /GCC/gcc-4-6-tr
> unk-build/powerpc-apple-darwin9/./boehm-gc/libgcjgc.la  -O2  -version-
> info 1:2:0 -no-undefined -rpath /nowhere -Wc,-shared-libgcc /GCC/
> gcc-4-6-trunk-build/power
> pc-apple-darwin9/./boehm-gc/libgcjgc_convenience.la -I/GCC/gcc-4-6-
> trunk-build/powerpc-apple-darwin9/./boehm-gc/include -I/GCC/gcc-live-
> trunk/boehm-gc/testsuite
> /../include  -Wc,-shared-libgcc -lpthread -lm   -m32 -o 
> libstaticrootslib.la    (timeout = 300)
> ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
> <snip>
> ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols
> output is:
> ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
> <snip>
> ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols
>
> I would imagine that a similar situation must have been handled somewhere
> else in the test-suite - but not sure where... ]]]

the only other place in the GCC testsuite where ranlib is called is in
libstdc++-v3/testsuite/lib/libstdc++.exp, but there it's called via
remote_exec and the output ignored.

While one might consider handling this in upstream libtool when --silent
is passed, the other solution would be to defined a boehm-gc-prune proc
that handles this.  I'll give it a try, but that may take until the next
weekend.

>> Ok for mainline (either now, or, more likely, after 4.6 branches?
>
> my 0.02 euro...
> since AFAIK these tests are
> (a) currently unreported by the regression testers, and ...
> (b) only applied for the native lib unless one does it by hand ...
> - ISTM that we would only be improving test coverage by applying this for
> 4.6.

While I agree with that reasoning (and I've already found a boehm-gc bug
due to the new testsuite), my caveat was that this may add testsuite
noise so short before the 4.6.0 release that there might not be enough
time to fix that.  But I could certainly be persuaded to apply the patch
now :-)

Thanks.
	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-17 12:12   ` Rainer Orth
  2011-01-17 13:32     ` IainS
@ 2011-01-18 20:21     ` Ralf Wildenhues
  2011-01-20 17:19       ` Rainer Orth
  1 sibling, 1 reply; 21+ messages in thread
From: Ralf Wildenhues @ 2011-01-18 20:21 UTC (permalink / raw)
  To: Rainer Orth
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston

* Rainer Orth wrote on Mon, Jan 17, 2011 at 01:11:45PM CET:
> I've now got a patch I'm reasonably happy with.  It incorporates all the
> review comments.  Tested on i386-pc-solaris2.10, i386-pc-solaris2.10 and
> sparc-sun-solaris2.11.
> 
> Since I'm performing a call to dg-test from within another dg-test
> invocation (dg-test -> dg-add-shlib -> dg-test), I have to work around
> the fact that this doesn't work in DejaGnu 1.4.4.  I'll submit a DejaGnu
> patch shortly, but ${tool}-build-shlib works without and with this patch.
> 
> The patch below omits all but two of the renamed files (the exceptions
> being trace_test.c, which aquired a dg-skip-if, and staticsroottest.c,
> which got a dg-add-shlib).
> 
> Ok for mainline (either now, or, more likely, after 4.6 branches?

I'm not the right person to decide this; the build system specific
parts look ok to me.  In site.exp, you set srcdir to $(srcdir) and not
an absolute value; there's an Automake bug open about this issue
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7833 pending feedback from
http://thread.gmane.org/gmane.comp.sysutils.dejagnu.bugs/345
and since there is precedent also for using $(srcdir) (in v3 and
libjava), I guess that is ok too.

Cheers, and thanks,
Ralf

> 2010-12-31  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
> 
> 	PR boehm-gc/11412
> 	* Makefile.am (AUTOMAKE_OPTIONS): Use foreign instead of cygnus.
> 	(SUBDIRS): Add testsuite.
> 	(libgcjgc_la_LIBADD): Remove $(UNWINDLIBS).
> 	Remove TESTS related variables.
> 	(AM_MAKEFLAGS): Don't pass RUNTEST.
> 	* configure.ac: Add testsuite/Makefile to AC_CONFIG_FILES.
> 	* Makefile.in: Regenerate.
> 	* configure: Regenerate.
> 	* testsuite/Makefile.am: New file.
> 	* testsuite/Makefile.in: New file.
> 	* testsuite/lib/boehm-gc.exp: New file.
> 	* testsuite/config/default.exp: New file.
> 	* testsuite/boehm-gc.c/c.exp: New file.
> 	* testsuite/boehm-gc.lib/lib.exp: New file.
> 	* tests/test.c: Move ...
> 	* testsuite/boehm-gc.c/gctest.c: ... here.
> 	* tests/leak_test.c, tests/middle.c, tests/thread_leak_test.c,
> 	tests/trace_test.c: Move ...
> 	* testsuite/boehm-gc.c: ... here.
> 	* testsuite/boehm-gc.c/trace_test.c: Skip everywhere.
> 	* tests/staticrootslib.c, tests/staticrootstest.c: Move ...
> 	* testsuite/boehm-gc.lib: ... here.
> 	* testsuite/boehm-gc.lib/staticrootstest.c: Use dg-add-shlib
> 	staticrootslib.c.
> 	* tests/test_cpp.cc: Move ...
> 	* testsuite/boehm-gc.c++: ... here.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-18 20:21     ` Ralf Wildenhues
@ 2011-01-20 17:19       ` Rainer Orth
  0 siblings, 0 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-20 17:19 UTC (permalink / raw)
  To: Ralf Wildenhues
  Cc: gcc-patches, java-patches, Hans Boehm, Paolo Bonzini,
	Janis Johnson, Ben Elliston

Ralf Wildenhues <Ralf.Wildenhues@gmx.de> writes:

>> Ok for mainline (either now, or, more likely, after 4.6 branches?
>
> I'm not the right person to decide this; the build system specific
> parts look ok to me.  In site.exp, you set srcdir to $(srcdir) and not

Fine, thanks.

> an absolute value; there's an Automake bug open about this issue
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7833 pending feedback from
> http://thread.gmane.org/gmane.comp.sysutils.dejagnu.bugs/345
> and since there is precedent also for using $(srcdir) (in v3 and
> libjava), I guess that is ok too.

That's where I copied that snippet from :-)  I've just filed an Automake
RFE to allow adding to the automatically generated site.exp.  Once that
gets implemented, those contortions can go away and everything will be
consistent.

Given the lack of further comments/approval, I'll probably ping
this patch (and the gnat.dg cleanup) early next week, seeking a global
reviewer for comments.  By that time, I'll have something in place to
prune the ranlib warnings Iain reported.  I doubt doing so in libtool
with --silent would be appropriate.

It's a pity we have to live without a testsuite maintainer for so long.

Thanks.
	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-17 13:32     ` IainS
  2011-01-17 14:04       ` Rainer Orth
@ 2011-01-24 14:02       ` Rainer Orth
  2011-01-24 15:54         ` IainS
  1 sibling, 1 reply; 21+ messages in thread
From: Rainer Orth @ 2011-01-24 14:02 UTC (permalink / raw)
  To: IainS
  Cc: Ralf Wildenhues, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston

Hi Iain,

> One issue on powerpc-darwin9****
> (which I would expect to manifest on *-*-darwin*)
>
> On 17 Jan 2011, at 12:11, Rainer Orth wrote:
>> I've now got a patch I'm reasonably happy with.  It incorporates all the
>> review comments.  Tested on i386-pc-solaris2.10, i386-pc-solaris2.10 and
>> sparc-sun-solaris2.11.
>
> +
> Native configuration is powerpc-apple-darwin9
>
>                 === boehm-gc tests ===
>
> Schedule of variations:
>     unix/-m32
>     unix/-m64
>
> Running target unix/-m32
> Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as board
> description file for target.
> Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as generic
> interface file for target.
> Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as
> tool-and-target-specific interface file.
> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...
> FAIL: staticrootslib.lo -O2 (test for excess errors)
>
> [[[ **** this is failing because of ranlib output:
>
> Executing on host: ../libtool --silent --tag=CC --mode=link  /GCC/
> gcc-4-6-trunk-build/gcc/xgcc -B/GCC/gcc-4-6-trunk-build/gcc/
> staticrootslib.lo /GCC/gcc-4-6-tr
> unk-build/powerpc-apple-darwin9/./boehm-gc/libgcjgc.la  -O2  -version-
> info 1:2:0 -no-undefined -rpath /nowhere -Wc,-shared-libgcc /GCC/
> gcc-4-6-trunk-build/power
> pc-apple-darwin9/./boehm-gc/libgcjgc_convenience.la -I/GCC/gcc-4-6-
> trunk-build/powerpc-apple-darwin9/./boehm-gc/include -I/GCC/gcc-live-
> trunk/boehm-gc/testsuite
> /../include  -Wc,-shared-libgcc -lpthread -lm   -m32 -o 
> libstaticrootslib.la    (timeout = 300)
> ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
> <snip>
> ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols
> output is:
> ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
> <snip>
> ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no symbols
>
> I would imagine that a similar situation must have been handled somewhere
> else in the test-suite - but not sure where... ]]]

Could you give this version a try?  I've introduced boehm-gc-dg-prune,
but couldn't test on Darwin.  What I've done instead is remove --silent
from the libtool invocations and prune the resulting libtool message in
the -dg-prune function to make sure the basics are ok.

Unfortunately, I've just discovered another issue: on IRIX 6.5, site.exp
can differ between different multilibs: for the N32 multilib, we have

set extra_test_libs "-ldl"

while for N64, libdl doesn't exist.  I'll have to investigate how to
avoid this.

Thanks.
	Rainer


diff -r ea50a33cef8f boehm-gc/Makefile.am
--- a/boehm-gc/Makefile.am	Fri Jan 21 22:12:30 2011 +0100
+++ b/boehm-gc/Makefile.am	Fri Jan 21 23:12:22 2011 +0100
@@ -4,10 +4,10 @@
 ## files that should be in the distribution are not mentioned in this
 ## Makefile.am.
 
-AUTOMAKE_OPTIONS = cygnus subdir-objects
+AUTOMAKE_OPTIONS = foreign subdir-objects
 ACLOCAL_AMFLAGS = -I .. -I ../config
 
-SUBDIRS = include
+SUBDIRS = include testsuite
 
 noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
 
@@ -35,7 +35,7 @@
 
 # Include THREADLIBS here to ensure that the correct versions of
 # linuxthread semaphore functions get linked:
-libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
+libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
 libgcjgc_la_DEPENDENCIES = $(addobjs)
 libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 -rpath $(toolexeclibdir)
 libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
@@ -48,43 +48,6 @@
 AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
 override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS)
 
-test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
-
-check_PROGRAMS = gctest
-gctest_SOURCES = tests/test.c
-gctest_LDADD = $(test_ldadd)
-gctest_LDFLAGS = -shared-libgcc
-gctest_LINK = $(LINK) $(gctest_LDFLAGS)
-TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
-TESTS = gctest
-
-TESTS += leaktest$(EXEEXT)
-check_PROGRAMS += leaktest
-leaktest_SOURCES = tests/leak_test.c
-leaktest_LDADD = $(test_ldadd)
-leaktest_LDFLAGS = -shared-libgcc
-leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
-
-TESTS += middletest$(EXEEXT)
-check_PROGRAMS += middletest
-middletest_SOURCES = tests/middle.c
-middletest_LDADD = $(test_ldadd)
-middletest_LDFLAGS = -shared-libgcc
-middletest_LINK = $(LINK) $(middletest_LDFLAGS)
-
-TESTS += staticrootstest$(EXEEXT)
-check_PROGRAMS += staticrootstest
-staticrootstest_SOURCES = tests/staticrootstest.c
-staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
-staticrootstest_LDFLAGS = -shared-libgcc
-staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
-check_LTLIBRARIES = libstaticrootslib.la
-libstaticrootslib_la_SOURCES = tests/staticrootslib.c
-libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
-libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
-				-rpath /nowhere -shared-libgcc
-libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
-
 ## FIXME: we shouldn't have to do this, but automake forces us to.
 .s.lo:
 ## We use -Wp,-P to strip #line directives.  Irix `as' chokes on
@@ -116,7 +79,6 @@
 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
 	"SHELL=$(SHELL)" \
 	"EXPECT=$(EXPECT)" \
-	"RUNTEST=$(RUNTEST)" \
 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
 	"exec_prefix=$(exec_prefix)" \
 	"infodir=$(infodir)" \
diff -r ea50a33cef8f boehm-gc/configure.ac
--- a/boehm-gc/configure.ac	Fri Jan 21 22:12:30 2011 +0100
+++ b/boehm-gc/configure.ac	Fri Jan 21 23:12:22 2011 +0100
@@ -1,4 +1,4 @@
-# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010 by Red Hat, Inc.
+# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010, 2011 by Red Hat, Inc.
 # All rights reserved.
 # Copyright 2004 Nathanael Nerode
 # 
@@ -544,5 +544,5 @@
 
 AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
 
-AC_CONFIG_FILES(Makefile include/Makefile threads.mk)
+AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile threads.mk)
 AC_OUTPUT
diff -r ea50a33cef8f boehm-gc/testsuite/Makefile.am
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/Makefile.am	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,43 @@
+## 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`
+
+# Override default.
+DEJATOOL = boehm-gc
+
+CLEANFILES = *.exe core* *.log *.sum
+
+# We need more things in site.exp, but automake completely controls the
+# creation of that file; there's no way to append to it without messing up
+# the dependancy chains.  So we overrule automake.  This rule is exactly
+# what it would have generated, plus our own additions.
+site.exp: Makefile
+	@echo 'Making a new site.exp file...'
+	@echo '## these variables are automatically generated by make ##' >site.tmp
+	@echo '# Do not edit here.  If you wish to override these values' >>site.tmp
+	@echo '# edit the last section' >>site.tmp
+	@echo 'set srcdir $(srcdir)' >>site.tmp
+	@echo "set objdir `pwd`" >>site.tmp
+	@echo 'set build_alias "$(build_alias)"' >>site.tmp
+	@echo 'set build_triplet $(build_triplet)' >>site.tmp
+	@echo 'set host_alias "$(host_alias)"' >>site.tmp
+	@echo 'set host_triplet $(host_triplet)' >>site.tmp
+	@echo 'set target_alias "$(target_alias)"' >>site.tmp
+	@echo 'set target_triplet $(target_triplet)' >>site.tmp
+	@echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
+	@echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
+	@echo '## All variables above are generated by configure. Do Not Edit ##' >>site.tmp
+	@test ! -f site.exp || \
+	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
+	@-rm -f site.bak
+	@test ! -f site.exp || mv site.exp site.bak
+	@mv site.tmp site.exp
diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.c/c.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.c/c.exp	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,25 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+boehm-gc-init
+
+boehm-gc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]] "-O2" ""
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.c/trace_test.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.c/trace_test.c	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,32 @@
+/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */
+
+#include <stdio.h>
+#define GC_DEBUG
+#include "gc.h"
+
+struct treenode {
+    struct treenode *x;
+    struct treenode *y;
+} * root[10];
+
+struct treenode * mktree(int i) {
+  struct treenode * r = GC_MALLOC(sizeof(struct treenode));
+  if (0 == i) return 0;
+  if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
+  r -> x = mktree(i-1);
+  r -> y = mktree(i-1);
+  return r;
+}
+
+int main()
+{
+  int i;
+  for (i = 0; i < 10; ++i) {
+    root[i] = mktree(12);
+  }
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  GC_generate_random_backtrace();
+  return 0;
+}
diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.lib/lib.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,30 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+dg-init
+boehm-gc-init
+
+# Gather list of tests, skipping library source files.
+# FIXME: How does this happen for dg-additional-sources?
+set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
+set tests [prune $tests $srcdir/$subdir/*lib.c]
+
+boehm-gc-dg-runtest $tests "-O2" ""
+dg-finish
+
+# Local Variables:
+# tcl-indent-level:4
+# End:
diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,48 @@
+/* { dg-add-shlib "staticrootslib.c" } */
+
+#include <stdio.h>
+
+#ifndef GC_DEBUG
+# define GC_DEBUG
+#endif
+
+#include "gc.h"
+#include "gc_backptr.h"
+
+struct treenode {
+    struct treenode *x;
+    struct treenode *y;
+} * root[10];
+
+static char *staticroot = 0;
+
+extern struct treenode * libsrl_mktree(int i);
+extern void * libsrl_init(void);
+extern void * libsrl_collect (void);
+
+int main(void)
+{
+  int i;
+  staticroot = libsrl_init();
+  for (i = 0; i < sizeof(struct treenode); ++i) {
+    staticroot[i] = 0x42;
+  }
+  libsrl_collect();
+  for (i = 0; i < 10; ++i) {
+    root[i] = libsrl_mktree(12);
+    libsrl_collect();
+  }
+  for (i = 0; i < sizeof(struct treenode); ++i) {
+    if (staticroot[i] != 0x42)
+      return -1;
+  }
+  for (i = 0; i < 10; ++i) {
+    root[i] = libsrl_mktree(12);
+    libsrl_collect();
+  }
+  for (i = 0; i < sizeof(struct treenode); ++i) {
+    if (staticroot[i] != 0x42)
+      return -1;
+  }
+  return 0;
+}
diff -r ea50a33cef8f boehm-gc/testsuite/config/default.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/config/default.exp	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,1 @@
+load_lib "standard.exp"
diff -r ea50a33cef8f boehm-gc/testsuite/lib/boehm-gc.exp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/boehm-gc/testsuite/lib/boehm-gc.exp	Fri Jan 21 23:12:22 2011 +0100
@@ -0,0 +1,335 @@
+# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+proc load_gcc_lib { filename } {
+    global srcdir loaded_libs
+    load_file $srcdir/../../gcc/testsuite/lib/$filename
+    set loaded_libs($filename) ""
+}
+
+load_lib dg.exp
+load_gcc_lib target-libpath.exp
+load_gcc_lib wrapper.exp
+# Required by target-supports-dg.exp.
+load_gcc_lib target-supports.exp
+# For dg-skip-if.
+load_gcc_lib target-supports-dg.exp
+# For ${tool}_exit.
+load_gcc_lib gcc-defs.exp
+# For prune_gcc_output.
+load_gcc_lib prune.exp
+
+set dg-do-what-default run
+
+# Define boehm-gc callbacks for dg.exp.
+
+# FIXME: The next two are independent of boehm-gc; move to some library.
+proc ${tool}-dg-test-1 { target_compile prog do_what extra_tool_flags } {
+
+    # Set up the compiler flags, based on what we're going to do.
+
+    set options [list]
+    switch $do_what {
+	"compile" {
+	    set compile_type "assembly"
+	    set output_file "[file rootname [file tail $prog]].s"
+	}
+        "assemble" {
+            set compile_type "object"
+            set output_file "[file rootname [file tail $prog]].o"
+        }
+        "ltassemble" {
+	    # Needs to be different from assemble since we cannot determine
+	    # from $prog whether to produce a regular or a libtool object.
+            set compile_type "object"
+            set output_file "[file rootname [file tail $prog]].lo"
+        }
+	"link" {
+	    set compile_type "executable"
+	    set output_file "[file rootname [file tail $prog]]"
+	    # If we're linking a libtool object, produce a libtool library.
+	    if { [file extension $prog] == ".lo" } {
+		set output_file "lib$output_file.la"
+	    }
+	}
+	"run" {
+	    set compile_type "executable"
+	    # FIXME: "./" is to cope with "." not being in $PATH.
+	    # Should this be handled elsewhere?
+	    # YES.
+	    set output_file "./[file rootname [file tail $prog]]"
+	    # This is the only place where we care if an executable was
+	    # created or not.  If it was, dg.exp will try to run it.
+	    remote_file build delete $output_file
+	}
+	default {
+	    perror "$do_what: not a valid dg-do keyword"
+	    return ""
+	}
+    }
+
+    if { $extra_tool_flags != "" } {
+	lappend options "additional_flags=$extra_tool_flags"
+    }
+
+    set comp_output [$target_compile "$prog" "$output_file" "$compile_type" $options];
+
+    return [list $comp_output $output_file]
+}
+
+proc ${tool}-dg-test { prog do_what extra_tool_flags } {
+    global tool
+
+    return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what $extra_tool_flags]
+}
+
+proc boehm-gc-init { args } {
+    global gluefile wrap_flags
+    global srcdir
+    global blddirgc
+    global TOOL_EXECUTABLE
+    global GCC_UNDER_TEST
+    global objdir
+    global gc_include
+    global gc_lib
+    global gc_lib_conv
+    global tool
+    global tool_root_dir
+    global ld_library_path
+
+    set blddirgc [lookfor_file [get_multilibs] ${tool}]
+    verbose "blddirgc: $blddirgc"
+
+    if ![info exists GCC_UNDER_TEST] then {
+	if [info exists TOOL_EXECUTABLE] {
+	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
+	} else {
+	    set GCC_UNDER_TEST "[find_gcc]"
+	}
+    }
+
+    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
+    if {$gccdir != ""} {
+	set gccdir [file dirname $gccdir]
+    }
+    verbose "gccdir: $gccdir"
+
+    set ld_library_path "."
+    append ld_library_path ":${gccdir}"
+
+    set compiler "${gccdir}/xgcc"
+    if { [is_remote host] == 0 && [which $compiler] != 0 } {
+	foreach i "[exec $compiler --print-multi-lib]" {
+	    set mldir ""
+	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
+	    set mldir [string trimright $mldir "\;@"]
+	    if { "$mldir" == "." } {
+		continue
+	    }
+	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] >= 1 } {
+		append ld_library_path ":${gccdir}/${mldir}"
+	    }
+	}
+    }
+    # Add the library path for boehm-gc.
+    append ld_library_path ":${blddirgc}/.libs"
+
+    # Add the library path for boehm-gc.lib libtool libraries.
+    append ld_library_path ":.libs"
+
+    verbose "ld_library_path: $ld_library_path"
+
+    # Point to the headers in boehm-gc.
+    set gc_include "${blddirgc}/include"
+    verbose "gc_include: $gc_include"
+
+    set gc_lib "${blddirgc}/libgcjgc.la"
+    verbose "gc_lib: $gc_lib"
+
+    set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la"
+    verbose "gc_lib_conv: $gc_lib_conv"
+
+    set_ld_library_path_env_vars
+    boehm-gc_maybe_build_wrapper "${objdir}/testglue.o"
+}
+
+proc boehm-gc_target_compile { source dest type options } {
+    global gluefile wrap_flags;
+    global srcdir
+    global TOOL_OPTIONS
+    global GCC_UNDER_TEST
+    global libtool
+    global gc_include
+    global gc_lib
+    global gc_lib_conv
+    global threadlibs
+    global extra_test_libs
+
+    if { [target_info needs_status_wrapper]!="" && [info exists gluefile] } {
+	lappend options "libs=${gluefile}"
+	lappend options "ldflags=$wrap_flags"
+    }
+
+    # TOOL_OPTIONS must come first, so that it doesn't override testcase
+    # specific options.
+    if [info exists TOOL_OPTIONS] {
+	lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
+    }
+
+    # Map type to libtool mode.
+    switch $type {
+	"object" {
+	    set mode "compile"
+	}
+	"executable" {
+	    set mode "link"
+	}
+	default {
+	    perror "$type: unhandled type"
+	    return ""
+	}
+    }
+
+    # Set this once for reuse in boehm-gc.lib/lib.exp.
+    set libtool "../libtool"
+    # We have to run silently to avoid DejaGnu lossage.
+    lappend options "compiler=$libtool --silent --tag=CC --mode=$mode \
+    	$GCC_UNDER_TEST"
+
+    lappend options "additional_flags=-I${gc_include} -I${srcdir}/../include"
+
+    lappend options "libs= -Wc,-shared-libgcc"
+    lappend options "libs= ${gc_lib} ${threadlibs} ${extra_test_libs}"
+
+    verbose "options: $options"
+    return [target_compile $source $dest $type $options]
+}
+
+# Prune harmless messages.
+proc boehm-gc-dg-prune { system text } {
+    # Prune the same messages as the gcc testsuite does.
+    set text [prune_gcc_output $text]
+
+    # Ignore harmless Darwin ranlib warnings.
+    regsub -all "(^|\n)(ranlib: file: \[^\n\]* has no symbols\n?)+" $text "\\1" text
+
+    return $text
+}
+
+# Build shared library from LIB.
+proc boehm-gc-build-shlib { lib flags extra-flags } {
+    global subdir
+    global dg-do-what-default
+    global libtool
+    global gc_lib_conv
+
+    # Determine basename.
+    set basename "[file rootname [file tail $lib]]"
+    verbose "basename: $basename"
+
+    # DejaGnu 1.4.4 doesn't support nested calls to dg-test.  Restore
+    # original state before calling it again.
+    if { [info procs dg-save-unknown] != [list] } {
+	rename unknown ""
+	rename dg-save-unknown unknown
+    }
+
+    set saved-dg-do-what ${dg-do-what-default}
+
+    # Compile $lib into libtool object.
+    set dg-do-what-default ltassemble
+    dg-test -keep-output $lib $flags ${extra-flags}
+
+    # FIXME: Explain options.
+    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere"
+    # Prefix -shared-libgcc with -Wc, to get it through libtool.
+    lappend shopt -Wc,-shared-libgcc
+    # Link with libgcjgc convenience library.
+    lappend shopt $gc_lib_conv
+
+    # There's no way to get output_file out of dg-test, only
+    # ${tool}-dg-test returns it, so hardcode that here.
+    set dg-do-what-default link
+    dg-test -keep-output $basename.lo $flags "${extra-flags} $shopt"
+
+    set dg-do-what-default ${saved-dg-do-what}
+
+    # Restore unknown, dg-save-unknown as DejaGnu 1.4.4 dg-test expects them.
+    if { [info procs dg-save-unknown] == [list] } {
+    	rename unknown dg-save-unknown
+	proc unknown {} {
+	}
+    }
+
+    catch { exec $libtool --mode=clean rm -f $basename.lo }
+
+    return lib$basename.la
+}
+
+# Handle dg-add-shlib.
+proc dg-add-shlib { args } {
+    global tool
+    global srcdir subdir
+    global shlib
+
+    if { [llength $args] > 2 } {
+	error "[lindex $args 0]: too many arguments"
+	return
+    }
+
+    set lib [lindex $args 1]
+    set lib "$srcdir/$subdir/$lib"
+    verbose -log "dg-add-shlib $lib"
+
+    upvar tool_flags flags
+    upvar default_extra_tool_flags extra-flags
+    # Build support library.
+    set shlib [boehm-gc-build-shlib $lib $flags ${extra-flags}]
+
+    uplevel lappend tool_flags $shlib
+}
+
+# Run boehm-gc testcases.
+proc boehm-gc-dg-runtest { testcases flags extra-flags } {
+    global runtests
+    global libtool
+    global shlib
+
+    set shlib ""
+
+    foreach testcase $testcases {
+	# If we're only testing specific files and this isn't one of them,
+	# skip it.
+	if ![runtest_file_p $runtests $testcase] {
+	    return
+	}
+
+	# Run testcase.
+	# Keep output, otherwise libtool below won't remove the corresponding
+	# file in .libs.
+	dg-test -keep-output $testcase $flags ${extra-flags}
+
+	# Remove $execname and eventually $shlib.
+	# FIXME: Is $execname right e.g. on Windows?
+	# FIXME: Better way to get at $shlib?
+	verbose -log "$libtool --mode=clean rm -f [file rootname [file tail $testcase]] $shlib"
+	catch { exec $libtool --mode=clean rm -f [file rootname [file tail $testcase]] $shlib }
+    }
+}
+
+# Local Variables:
+# tcl-indent-level:4
+# End:


-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-24 14:02       ` Rainer Orth
@ 2011-01-24 15:54         ` IainS
  2011-01-24 15:57           ` Rainer Orth
  0 siblings, 1 reply; 21+ messages in thread
From: IainS @ 2011-01-24 15:54 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Ralf Wildenhues, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston

Hi Rainer,

thanks for the (off-list) delta from the previous patch...

On 24 Jan 2011, at 14:01, Rainer Orth wrote:

> Hi Iain,
>
>> One issue on powerpc-darwin9****
>> (which I would expect to manifest on *-*-darwin*)
>>
>> On 17 Jan 2011, at 12:11, Rainer Orth wrote:
>>> I've now got a patch I'm reasonably happy with.  It incorporates  
>>> all the
>>> review comments.  Tested on i386-pc-solaris2.10, i386-pc- 
>>> solaris2.10 and
>>> sparc-sun-solaris2.11.
>>
>> +
>> Native configuration is powerpc-apple-darwin9
>>
>>                === boehm-gc tests ===
>>
>> Schedule of variations:
>>    unix/-m32
>>    unix/-m64
>>
>> Running target unix/-m32
>> Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as  
>> board
>> description file for target.
>> Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as  
>> generic
>> interface file for target.
>> Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as
>> tool-and-target-specific interface file.
>> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
>> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/ 
>> lib.exp ...
>> FAIL: staticrootslib.lo -O2 (test for excess errors)
>>
>> [[[ **** this is failing because of ranlib output:
>>
>> Executing on host: ../libtool --silent --tag=CC --mode=link  /GCC/
>> gcc-4-6-trunk-build/gcc/xgcc -B/GCC/gcc-4-6-trunk-build/gcc/
>> staticrootslib.lo /GCC/gcc-4-6-tr
>> unk-build/powerpc-apple-darwin9/./boehm-gc/libgcjgc.la  -O2  - 
>> version-
>> info 1:2:0 -no-undefined -rpath /nowhere -Wc,-shared-libgcc /GCC/
>> gcc-4-6-trunk-build/power
>> pc-apple-darwin9/./boehm-gc/libgcjgc_convenience.la -I/GCC/gcc-4-6-
>> trunk-build/powerpc-apple-darwin9/./boehm-gc/include -I/GCC/gcc-live-
>> trunk/boehm-gc/testsuite
>> /../include  -Wc,-shared-libgcc -lpthread -lm   -m32 -o
>> libstaticrootslib.la    (timeout = 300)
>> ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
>> <snip>
>> ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no  
>> symbols
>> output is:
>> ranlib: file: .libs/libstaticrootslib.a(backgraph.o) has no symbols
>> <snip>
>> ranlib: file: .libs/libstaticrootslib.a(win32_threads.o) has no  
>> symbols
>>
>> I would imagine that a similar situation must have been handled  
>> somewhere
>> else in the test-suite - but not sure where... ]]]
>
> Could you give this version a try?

Works for me :-)

Native configuration is powerpc-apple-darwin9

                 === boehm-gc tests ===

Schedule of variations:
     unix/-m32
     unix/-m64

Running target unix/-m32
Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as  
board description file for target.
Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as  
generic interface file for target.
Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as  
tool-and-target-specific interface file.
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...

                 === boehm-gc Summary for unix/-m32 ===

# of expected passes            12
# of unsupported tests          1
Running target unix/-m64
Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as  
board description file for target.
Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as  
generic interface file for target.
Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as  
tool-and-target-specific interface file.
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...

                 === boehm-gc Summary for unix/-m64 ===

# of expected passes            12
# of unsupported tests          1

                 === boehm-gc Summary ===

# of expected passes            24
# of unsupported tests          2


cheers
Iain


>  I've introduced boehm-gc-dg-prune,
> but couldn't test on Darwin.  What I've done instead is remove -- 
> silent
> from the libtool invocations and prune the resulting libtool message  
> in
> the -dg-prune function to make sure the basics are ok.
>
> Unfortunately, I've just discovered another issue: on IRIX 6.5,  
> site.exp
> can differ between different multilibs: for the N32 multilib, we have
>
> set extra_test_libs "-ldl"
>
> while for N64, libdl doesn't exist.  I'll have to investigate how to
> avoid this.
>
> Thanks.
> 	Rainer
>
>
> diff -r ea50a33cef8f boehm-gc/Makefile.am
> --- a/boehm-gc/Makefile.am	Fri Jan 21 22:12:30 2011 +0100
> +++ b/boehm-gc/Makefile.am	Fri Jan 21 23:12:22 2011 +0100
> @@ -4,10 +4,10 @@
> ## files that should be in the distribution are not mentioned in this
> ## Makefile.am.
>
> -AUTOMAKE_OPTIONS = cygnus subdir-objects
> +AUTOMAKE_OPTIONS = foreign subdir-objects
> ACLOCAL_AMFLAGS = -I .. -I ../config
>
> -SUBDIRS = include
> +SUBDIRS = include testsuite
>
> noinst_LTLIBRARIES = libgcjgc.la libgcjgc_convenience.la
>
> @@ -35,7 +35,7 @@
>
> # Include THREADLIBS here to ensure that the correct versions of
> # linuxthread semaphore functions get linked:
> -libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS) $(UNWINDLIBS)
> +libgcjgc_la_LIBADD = $(addobjs) $(THREADLIBS)
> libgcjgc_la_DEPENDENCIES = $(addobjs)
> libgcjgc_la_LDFLAGS = $(extra_ldflags_libgc) -version-info 1:2:0 - 
> rpath $(toolexeclibdir)
> libgcjgc_la_LINK = $(LINK) $(libgcjgc_la_LDFLAGS)
> @@ -48,43 +48,6 @@
> AM_LDFLAGS = $(shell $(top_srcdir)/../libtool-ldflags $(LDFLAGS))
> override CFLAGS := $(filter-out $(O0_CFLAGS), $(CFLAGS)) $(O0_CFLAGS)
>
> -test_ldadd = libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $ 
> (EXTRA_TEST_LIBS)
> -
> -check_PROGRAMS = gctest
> -gctest_SOURCES = tests/test.c
> -gctest_LDADD = $(test_ldadd)
> -gctest_LDFLAGS = -shared-libgcc
> -gctest_LINK = $(LINK) $(gctest_LDFLAGS)
> -TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
> -TESTS = gctest
> -
> -TESTS += leaktest$(EXEEXT)
> -check_PROGRAMS += leaktest
> -leaktest_SOURCES = tests/leak_test.c
> -leaktest_LDADD = $(test_ldadd)
> -leaktest_LDFLAGS = -shared-libgcc
> -leaktest_LINK = $(LINK) $(leaktest_LDFLAGS)
> -
> -TESTS += middletest$(EXEEXT)
> -check_PROGRAMS += middletest
> -middletest_SOURCES = tests/middle.c
> -middletest_LDADD = $(test_ldadd)
> -middletest_LDFLAGS = -shared-libgcc
> -middletest_LINK = $(LINK) $(middletest_LDFLAGS)
> -
> -TESTS += staticrootstest$(EXEEXT)
> -check_PROGRAMS += staticrootstest
> -staticrootstest_SOURCES = tests/staticrootstest.c
> -staticrootstest_LDADD = $(test_ldadd) libstaticrootslib.la
> -staticrootstest_LDFLAGS = -shared-libgcc
> -staticrootstest_LINK = $(LINK) $(staticrootstest_LDFLAGS)
> -check_LTLIBRARIES = libstaticrootslib.la
> -libstaticrootslib_la_SOURCES = tests/staticrootslib.c
> -libstaticrootslib_la_LIBADD = libgcjgc_convenience.la
> -libstaticrootslib_la_LDFLAGS = -version-info 1:2:0 -no-undefined \
> -				-rpath /nowhere -shared-libgcc
> -libstaticrootslib_la_DEPENDENCIES = libgcjgc_convenience.la
> -
> ## FIXME: we shouldn't have to do this, but automake forces us to.
> .s.lo:
> ## We use -Wp,-P to strip #line directives.  Irix `as' chokes on
> @@ -116,7 +79,6 @@
> 	"PICFLAG_FOR_TARGET=$(PICFLAG_FOR_TARGET)" \
> 	"SHELL=$(SHELL)" \
> 	"EXPECT=$(EXPECT)" \
> -	"RUNTEST=$(RUNTEST)" \
> 	"RUNTESTFLAGS=$(RUNTESTFLAGS)" \
> 	"exec_prefix=$(exec_prefix)" \
> 	"infodir=$(infodir)" \
> diff -r ea50a33cef8f boehm-gc/configure.ac
> --- a/boehm-gc/configure.ac	Fri Jan 21 22:12:30 2011 +0100
> +++ b/boehm-gc/configure.ac	Fri Jan 21 23:12:22 2011 +0100
> @@ -1,4 +1,4 @@
> -# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010 by Red  
> Hat, Inc.
> +# Copyright (c) 1999, 2000, 2001, 2002, 2003, 2006, 2010, 2011 by  
> Red Hat, Inc.
> # All rights reserved.
> # Copyright 2004 Nathanael Nerode
> #
> @@ -544,5 +544,5 @@
>
> AC_CONFIG_HEADERS([include/gc_config.h include/gc_ext_config.h])
>
> -AC_CONFIG_FILES(Makefile include/Makefile threads.mk)
> +AC_CONFIG_FILES(Makefile include/Makefile testsuite/Makefile  
> threads.mk)
> AC_OUTPUT
> diff -r ea50a33cef8f boehm-gc/testsuite/Makefile.am
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/Makefile.am	Fri Jan 21 23:12:22 2011 +0100
> @@ -0,0 +1,43 @@
> +## 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`
> +
> +# Override default.
> +DEJATOOL = boehm-gc
> +
> +CLEANFILES = *.exe core* *.log *.sum
> +
> +# We need more things in site.exp, but automake completely controls  
> the
> +# creation of that file; there's no way to append to it without  
> messing up
> +# the dependancy chains.  So we overrule automake.  This rule is  
> exactly
> +# what it would have generated, plus our own additions.
> +site.exp: Makefile
> +	@echo 'Making a new site.exp file...'
> +	@echo '## these variables are automatically generated by make ##'  
> >site.tmp
> +	@echo '# Do not edit here.  If you wish to override these values'  
> >>site.tmp
> +	@echo '# edit the last section' >>site.tmp
> +	@echo 'set srcdir $(srcdir)' >>site.tmp
> +	@echo "set objdir `pwd`" >>site.tmp
> +	@echo 'set build_alias "$(build_alias)"' >>site.tmp
> +	@echo 'set build_triplet $(build_triplet)' >>site.tmp
> +	@echo 'set host_alias "$(host_alias)"' >>site.tmp
> +	@echo 'set host_triplet $(host_triplet)' >>site.tmp
> +	@echo 'set target_alias "$(target_alias)"' >>site.tmp
> +	@echo 'set target_triplet $(target_triplet)' >>site.tmp
> +	@echo 'set threadlibs "$(THREADLIBS)"' >>site.tmp
> +	@echo 'set extra_test_libs "$(EXTRA_TEST_LIBS)"' >>site.tmp
> +	@echo '## All variables above are generated by configure. Do Not  
> Edit ##' >>site.tmp
> +	@test ! -f site.exp || \
> +	  sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp
> +	@-rm -f site.bak
> +	@test ! -f site.exp || mv site.exp site.bak
> +	@mv site.tmp site.exp
> diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.c/c.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.c/c.exp	Fri Jan 21 23:12:22 2011  
> +0100
> @@ -0,0 +1,25 @@
> +# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +dg-init
> +boehm-gc-init
> +
> +boehm-gc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.c]]  
> "-O2" ""
> +dg-finish
> +
> +# Local Variables:
> +# tcl-indent-level:4
> +# End:
> diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.c/trace_test.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.c/trace_test.c	Fri Jan 21 23:12:22  
> 2011 +0100
> @@ -0,0 +1,32 @@
> +/* { dg-skip-if "requires --enable-gc-debug" *-*-* } */
> +
> +#include <stdio.h>
> +#define GC_DEBUG
> +#include "gc.h"
> +
> +struct treenode {
> +    struct treenode *x;
> +    struct treenode *y;
> +} * root[10];
> +
> +struct treenode * mktree(int i) {
> +  struct treenode * r = GC_MALLOC(sizeof(struct treenode));
> +  if (0 == i) return 0;
> +  if (1 == i) r = GC_MALLOC_ATOMIC(sizeof(struct treenode));
> +  r -> x = mktree(i-1);
> +  r -> y = mktree(i-1);
> +  return r;
> +}
> +
> +int main()
> +{
> +  int i;
> +  for (i = 0; i < 10; ++i) {
> +    root[i] = mktree(12);
> +  }
> +  GC_generate_random_backtrace();
> +  GC_generate_random_backtrace();
> +  GC_generate_random_backtrace();
> +  GC_generate_random_backtrace();
> +  return 0;
> +}
> diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.lib/lib.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.lib/lib.exp	Fri Jan 21 23:12:22  
> 2011 +0100
> @@ -0,0 +1,30 @@
> +# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +dg-init
> +boehm-gc-init
> +
> +# Gather list of tests, skipping library source files.
> +# FIXME: How does this happen for dg-additional-sources?
> +set tests [lsort [glob -nocomplain $srcdir/$subdir/*.c]]
> +set tests [prune $tests $srcdir/$subdir/*lib.c]
> +
> +boehm-gc-dg-runtest $tests "-O2" ""
> +dg-finish
> +
> +# Local Variables:
> +# tcl-indent-level:4
> +# End:
> diff -r ea50a33cef8f boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/boehm-gc.lib/staticrootstest.c	Fri Jan 21  
> 23:12:22 2011 +0100
> @@ -0,0 +1,48 @@
> +/* { dg-add-shlib "staticrootslib.c" } */
> +
> +#include <stdio.h>
> +
> +#ifndef GC_DEBUG
> +# define GC_DEBUG
> +#endif
> +
> +#include "gc.h"
> +#include "gc_backptr.h"
> +
> +struct treenode {
> +    struct treenode *x;
> +    struct treenode *y;
> +} * root[10];
> +
> +static char *staticroot = 0;
> +
> +extern struct treenode * libsrl_mktree(int i);
> +extern void * libsrl_init(void);
> +extern void * libsrl_collect (void);
> +
> +int main(void)
> +{
> +  int i;
> +  staticroot = libsrl_init();
> +  for (i = 0; i < sizeof(struct treenode); ++i) {
> +    staticroot[i] = 0x42;
> +  }
> +  libsrl_collect();
> +  for (i = 0; i < 10; ++i) {
> +    root[i] = libsrl_mktree(12);
> +    libsrl_collect();
> +  }
> +  for (i = 0; i < sizeof(struct treenode); ++i) {
> +    if (staticroot[i] != 0x42)
> +      return -1;
> +  }
> +  for (i = 0; i < 10; ++i) {
> +    root[i] = libsrl_mktree(12);
> +    libsrl_collect();
> +  }
> +  for (i = 0; i < sizeof(struct treenode); ++i) {
> +    if (staticroot[i] != 0x42)
> +      return -1;
> +  }
> +  return 0;
> +}
> diff -r ea50a33cef8f boehm-gc/testsuite/config/default.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/config/default.exp	Fri Jan 21 23:12:22 2011  
> +0100
> @@ -0,0 +1,1 @@
> +load_lib "standard.exp"
> diff -r ea50a33cef8f boehm-gc/testsuite/lib/boehm-gc.exp
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/boehm-gc/testsuite/lib/boehm-gc.exp	Fri Jan 21 23:12:22 2011  
> +0100
> @@ -0,0 +1,335 @@
> +# Copyright (C) 2011 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 this program; see the file COPYING3.  If not see
> +# <http://www.gnu.org/licenses/>.
> +
> +proc load_gcc_lib { filename } {
> +    global srcdir loaded_libs
> +    load_file $srcdir/../../gcc/testsuite/lib/$filename
> +    set loaded_libs($filename) ""
> +}
> +
> +load_lib dg.exp
> +load_gcc_lib target-libpath.exp
> +load_gcc_lib wrapper.exp
> +# Required by target-supports-dg.exp.
> +load_gcc_lib target-supports.exp
> +# For dg-skip-if.
> +load_gcc_lib target-supports-dg.exp
> +# For ${tool}_exit.
> +load_gcc_lib gcc-defs.exp
> +# For prune_gcc_output.
> +load_gcc_lib prune.exp
> +
> +set dg-do-what-default run
> +
> +# Define boehm-gc callbacks for dg.exp.
> +
> +# FIXME: The next two are independent of boehm-gc; move to some  
> library.
> +proc ${tool}-dg-test-1 { target_compile prog do_what  
> extra_tool_flags } {
> +
> +    # Set up the compiler flags, based on what we're going to do.
> +
> +    set options [list]
> +    switch $do_what {
> +	"compile" {
> +	    set compile_type "assembly"
> +	    set output_file "[file rootname [file tail $prog]].s"
> +	}
> +        "assemble" {
> +            set compile_type "object"
> +            set output_file "[file rootname [file tail $prog]].o"
> +        }
> +        "ltassemble" {
> +	    # Needs to be different from assemble since we cannot determine
> +	    # from $prog whether to produce a regular or a libtool object.
> +            set compile_type "object"
> +            set output_file "[file rootname [file tail $prog]].lo"
> +        }
> +	"link" {
> +	    set compile_type "executable"
> +	    set output_file "[file rootname [file tail $prog]]"
> +	    # If we're linking a libtool object, produce a libtool library.
> +	    if { [file extension $prog] == ".lo" } {
> +		set output_file "lib$output_file.la"
> +	    }
> +	}
> +	"run" {
> +	    set compile_type "executable"
> +	    # FIXME: "./" is to cope with "." not being in $PATH.
> +	    # Should this be handled elsewhere?
> +	    # YES.
> +	    set output_file "./[file rootname [file tail $prog]]"
> +	    # This is the only place where we care if an executable was
> +	    # created or not.  If it was, dg.exp will try to run it.
> +	    remote_file build delete $output_file
> +	}
> +	default {
> +	    perror "$do_what: not a valid dg-do keyword"
> +	    return ""
> +	}
> +    }
> +
> +    if { $extra_tool_flags != "" } {
> +	lappend options "additional_flags=$extra_tool_flags"
> +    }
> +
> +    set comp_output [$target_compile "$prog" "$output_file"  
> "$compile_type" $options];
> +
> +    return [list $comp_output $output_file]
> +}
> +
> +proc ${tool}-dg-test { prog do_what extra_tool_flags } {
> +    global tool
> +
> +    return [${tool}-dg-test-1 ${tool}_target_compile $prog $do_what  
> $extra_tool_flags]
> +}
> +
> +proc boehm-gc-init { args } {
> +    global gluefile wrap_flags
> +    global srcdir
> +    global blddirgc
> +    global TOOL_EXECUTABLE
> +    global GCC_UNDER_TEST
> +    global objdir
> +    global gc_include
> +    global gc_lib
> +    global gc_lib_conv
> +    global tool
> +    global tool_root_dir
> +    global ld_library_path
> +
> +    set blddirgc [lookfor_file [get_multilibs] ${tool}]
> +    verbose "blddirgc: $blddirgc"
> +
> +    if ![info exists GCC_UNDER_TEST] then {
> +	if [info exists TOOL_EXECUTABLE] {
> +	    set GCC_UNDER_TEST $TOOL_EXECUTABLE
> +	} else {
> +	    set GCC_UNDER_TEST "[find_gcc]"
> +	}
> +    }
> +
> +    set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
> +    if {$gccdir != ""} {
> +	set gccdir [file dirname $gccdir]
> +    }
> +    verbose "gccdir: $gccdir"
> +
> +    set ld_library_path "."
> +    append ld_library_path ":${gccdir}"
> +
> +    set compiler "${gccdir}/xgcc"
> +    if { [is_remote host] == 0 && [which $compiler] != 0 } {
> +	foreach i "[exec $compiler --print-multi-lib]" {
> +	    set mldir ""
> +	    regexp -- "\[a-z0-9=_/\.-\]*;" $i mldir
> +	    set mldir [string trimright $mldir "\;@"]
> +	    if { "$mldir" == "." } {
> +		continue
> +	    }
> +	    if { [llength [glob -nocomplain ${gccdir}/${mldir}/ 
> libgcc_s*.so.*]] >= 1 } {
> +		append ld_library_path ":${gccdir}/${mldir}"
> +	    }
> +	}
> +    }
> +    # Add the library path for boehm-gc.
> +    append ld_library_path ":${blddirgc}/.libs"
> +
> +    # Add the library path for boehm-gc.lib libtool libraries.
> +    append ld_library_path ":.libs"
> +
> +    verbose "ld_library_path: $ld_library_path"
> +
> +    # Point to the headers in boehm-gc.
> +    set gc_include "${blddirgc}/include"
> +    verbose "gc_include: $gc_include"
> +
> +    set gc_lib "${blddirgc}/libgcjgc.la"
> +    verbose "gc_lib: $gc_lib"
> +
> +    set gc_lib_conv "${blddirgc}/libgcjgc_convenience.la"
> +    verbose "gc_lib_conv: $gc_lib_conv"
> +
> +    set_ld_library_path_env_vars
> +    boehm-gc_maybe_build_wrapper "${objdir}/testglue.o"
> +}
> +
> +proc boehm-gc_target_compile { source dest type options } {
> +    global gluefile wrap_flags;
> +    global srcdir
> +    global TOOL_OPTIONS
> +    global GCC_UNDER_TEST
> +    global libtool
> +    global gc_include
> +    global gc_lib
> +    global gc_lib_conv
> +    global threadlibs
> +    global extra_test_libs
> +
> +    if { [target_info needs_status_wrapper]!="" && [info exists  
> gluefile] } {
> +	lappend options "libs=${gluefile}"
> +	lappend options "ldflags=$wrap_flags"
> +    }
> +
> +    # TOOL_OPTIONS must come first, so that it doesn't override  
> testcase
> +    # specific options.
> +    if [info exists TOOL_OPTIONS] {
> +	lappend options [concat "additional_flags=$TOOL_OPTIONS" $options];
> +    }
> +
> +    # Map type to libtool mode.
> +    switch $type {
> +	"object" {
> +	    set mode "compile"
> +	}
> +	"executable" {
> +	    set mode "link"
> +	}
> +	default {
> +	    perror "$type: unhandled type"
> +	    return ""
> +	}
> +    }
> +
> +    # Set this once for reuse in boehm-gc.lib/lib.exp.
> +    set libtool "../libtool"
> +    # We have to run silently to avoid DejaGnu lossage.
> +    lappend options "compiler=$libtool --silent --tag=CC --mode= 
> $mode \
> +    	$GCC_UNDER_TEST"
> +
> +    lappend options "additional_flags=-I${gc_include} -I$ 
> {srcdir}/../include"
> +
> +    lappend options "libs= -Wc,-shared-libgcc"
> +    lappend options "libs= ${gc_lib} ${threadlibs} $ 
> {extra_test_libs}"
> +
> +    verbose "options: $options"
> +    return [target_compile $source $dest $type $options]
> +}
> +
> +# Prune harmless messages.
> +proc boehm-gc-dg-prune { system text } {
> +    # Prune the same messages as the gcc testsuite does.
> +    set text [prune_gcc_output $text]
> +
> +    # Ignore harmless Darwin ranlib warnings.
> +    regsub -all "(^|\n)(ranlib: file: \[^\n\]* has no symbols\n?)+"  
> $text "\\1" text
> +
> +    return $text
> +}
> +
> +# Build shared library from LIB.
> +proc boehm-gc-build-shlib { lib flags extra-flags } {
> +    global subdir
> +    global dg-do-what-default
> +    global libtool
> +    global gc_lib_conv
> +
> +    # Determine basename.
> +    set basename "[file rootname [file tail $lib]]"
> +    verbose "basename: $basename"
> +
> +    # DejaGnu 1.4.4 doesn't support nested calls to dg-test.  Restore
> +    # original state before calling it again.
> +    if { [info procs dg-save-unknown] != [list] } {
> +	rename unknown ""
> +	rename dg-save-unknown unknown
> +    }
> +
> +    set saved-dg-do-what ${dg-do-what-default}
> +
> +    # Compile $lib into libtool object.
> +    set dg-do-what-default ltassemble
> +    dg-test -keep-output $lib $flags ${extra-flags}
> +
> +    # FIXME: Explain options.
> +    set shopt "-version-info 1:2:0 -no-undefined -rpath /nowhere"
> +    # Prefix -shared-libgcc with -Wc, to get it through libtool.
> +    lappend shopt -Wc,-shared-libgcc
> +    # Link with libgcjgc convenience library.
> +    lappend shopt $gc_lib_conv
> +
> +    # There's no way to get output_file out of dg-test, only
> +    # ${tool}-dg-test returns it, so hardcode that here.
> +    set dg-do-what-default link
> +    dg-test -keep-output $basename.lo $flags "${extra-flags} $shopt"
> +
> +    set dg-do-what-default ${saved-dg-do-what}
> +
> +    # Restore unknown, dg-save-unknown as DejaGnu 1.4.4 dg-test  
> expects them.
> +    if { [info procs dg-save-unknown] == [list] } {
> +    	rename unknown dg-save-unknown
> +	proc unknown {} {
> +	}
> +    }
> +
> +    catch { exec $libtool --mode=clean rm -f $basename.lo }
> +
> +    return lib$basename.la
> +}
> +
> +# Handle dg-add-shlib.
> +proc dg-add-shlib { args } {
> +    global tool
> +    global srcdir subdir
> +    global shlib
> +
> +    if { [llength $args] > 2 } {
> +	error "[lindex $args 0]: too many arguments"
> +	return
> +    }
> +
> +    set lib [lindex $args 1]
> +    set lib "$srcdir/$subdir/$lib"
> +    verbose -log "dg-add-shlib $lib"
> +
> +    upvar tool_flags flags
> +    upvar default_extra_tool_flags extra-flags
> +    # Build support library.
> +    set shlib [boehm-gc-build-shlib $lib $flags ${extra-flags}]
> +
> +    uplevel lappend tool_flags $shlib
> +}
> +
> +# Run boehm-gc testcases.
> +proc boehm-gc-dg-runtest { testcases flags extra-flags } {
> +    global runtests
> +    global libtool
> +    global shlib
> +
> +    set shlib ""
> +
> +    foreach testcase $testcases {
> +	# If we're only testing specific files and this isn't one of them,
> +	# skip it.
> +	if ![runtest_file_p $runtests $testcase] {
> +	    return
> +	}
> +
> +	# Run testcase.
> +	# Keep output, otherwise libtool below won't remove the  
> corresponding
> +	# file in .libs.
> +	dg-test -keep-output $testcase $flags ${extra-flags}
> +
> +	# Remove $execname and eventually $shlib.
> +	# FIXME: Is $execname right e.g. on Windows?
> +	# FIXME: Better way to get at $shlib?
> +	verbose -log "$libtool --mode=clean rm -f [file rootname [file  
> tail $testcase]] $shlib"
> +	catch { exec $libtool --mode=clean rm -f [file rootname [file tail  
> $testcase]] $shlib }
> +    }
> +}
> +
> +# Local Variables:
> +# tcl-indent-level:4
> +# End:
>
>
> -- 
> -----------------------------------------------------------------------------
> Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-24 15:54         ` IainS
@ 2011-01-24 15:57           ` Rainer Orth
  0 siblings, 0 replies; 21+ messages in thread
From: Rainer Orth @ 2011-01-24 15:57 UTC (permalink / raw)
  To: IainS
  Cc: Ralf Wildenhues, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston

Hi Iain,

>> Could you give this version a try?
>
> Works for me :-)
>
> Native configuration is powerpc-apple-darwin9
>
>                 === boehm-gc tests ===
>
> Schedule of variations:
>     unix/-m32
>     unix/-m64
>
> Running target unix/-m32
> Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as board
> description file for target.
> Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as generic
> interface file for target.
> Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as
> tool-and-target-specific interface file.
> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...
>
>                 === boehm-gc Summary for unix/-m32 ===
>
> # of expected passes            12
> # of unsupported tests          1
> Running target unix/-m64
> Using /usr/local/dejagnu-1-4-4/share/dejagnu/baseboards/unix.exp as board
> description file for target.
> Using /usr/local/dejagnu-1-4-4/share/dejagnu/config/unix.exp as generic
> interface file for target.
> Using /GCC/gcc-live-trunk/boehm-gc/testsuite/config/default.exp as
> tool-and-target-specific interface file.
> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.c/c.exp ...
> Running /GCC/gcc-live-trunk/boehm-gc/testsuite/boehm-gc.lib/lib.exp ...
>
>                 === boehm-gc Summary for unix/-m64 ===
>
> # of expected passes            12
> # of unsupported tests          1
>
>                 === boehm-gc Summary ===
>
> # of expected passes            24
> # of unsupported tests          2

excellent, thanks for the confirmation.  I'll try to find a solution for
the problem of varying site.exp contents.

In the meantime, I've pinged this patch (and the gnat.dg cleanup one) in
the hope to finally get some response/decision what to do about this
patch.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 20:19 ` Dave Korn
  2011-01-05 20:25   ` Joseph S. Myers
@ 2011-02-18  7:51   ` Mike Stump
  1 sibling, 0 replies; 21+ messages in thread
From: Mike Stump @ 2011-02-18  7:51 UTC (permalink / raw)
  To: Dave Korn
  Cc: Rainer Orth, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston, Ralf Wildenhues

On Jan 5, 2011, at 12:44 PM, Dave Korn wrote:
>  Perhaps just build it in the makefile,

Please, no.  Pretend there is a configure flag to have the library installed, or a language is added that uses it, and installs it, installed testing should just work.  `should just work' is an important property.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-05 20:22 ` Dave Korn
  2011-01-10 10:44   ` Rainer Orth
@ 2011-02-18  7:55   ` Mike Stump
  2011-02-22 17:04     ` Rainer Orth
  1 sibling, 1 reply; 21+ messages in thread
From: Mike Stump @ 2011-02-18  7:55 UTC (permalink / raw)
  To: Dave Korn
  Cc: Rainer Orth, GCC Patches, Java Patches, Hans Boehm,
	Paolo Bonzini, Ben Elliston, Ralf Wildenhues

On Jan 5, 2011, at 12:46 PM, Dave Korn wrote:
> I think this is unambiguously stage1 material.

I think I'd tend to say stage1 as well.  I'd like more bake time on it...

> I do think it's an definite good idea

As do I.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-01-10 10:41   ` Rainer Orth
@ 2011-02-18  8:02     ` Mike Stump
  0 siblings, 0 replies; 21+ messages in thread
From: Mike Stump @ 2011-02-18  8:02 UTC (permalink / raw)
  To: Rainer Orth
  Cc: Ralf Wildenhues, gcc-patches, java-patches, Hans Boehm,
	Paolo Bonzini, Janis Johnson, Ben Elliston

On Jan 10, 2011, at 2:40 AM, Rainer Orth wrote:
> This may be just me not fully understanding the possible scenarios here:
> while a basic cross should work, what about a canadian cross (build !=
> host != target)?  The rm would have to be run on the host, but with
> libtool would run on the build machine.  I have no idea if boehm-gc (or
> any other of the libtool libraries in GCC) work properly in such cases,

Yes, historically they do.  It is actually a nice feature of gcc.  At times people blow things, but generally they are easy to fix, once you're in that environment and mindset.

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412)
  2011-02-18  7:55   ` Mike Stump
@ 2011-02-22 17:04     ` Rainer Orth
  0 siblings, 0 replies; 21+ messages in thread
From: Rainer Orth @ 2011-02-22 17:04 UTC (permalink / raw)
  To: Mike Stump
  Cc: Dave Korn, GCC Patches, Java Patches, Hans Boehm, Paolo Bonzini,
	Ben Elliston, Ralf Wildenhues

Mike Stump <mikestump@comcast.net> writes:

> On Jan 5, 2011, at 12:46 PM, Dave Korn wrote:
>> I think this is unambiguously stage1 material.
>
> I think I'd tend to say stage1 as well.  I'd like more bake time on it...

Absolutely.  I know of two current issues:

* one 64-bit failure on IRIX that I haven't analysed yet, so I cannot
  tell if this was caused by the DejaGnu testsuite (non-default
  multilibs aren't tested at all without DejaGnu, so this wouldn't have
  shown up before), and

* failure to pass all required compilation flags (-pthread on Tru64
  UNIX, which breaks testcase compilation).

I do have a preliminary patch for the latter issue (mostly on the build
side), but since my Tru64 UNIX V5.1 test system broke down recently and
I'm still looking for a replacement.

>> I do think it's an definite good idea
>
> As do I.

Thanks.  There are a few other testsuites that could be converted:
libiberty and libgo immediately come to mind.

	Rainer

-- 
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2011-02-22 17:04 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-05 18:07 [testsuite, build] Convert boehm-gc testsuite to DejaGnu (PR boehm-gc/11412) Rainer Orth
2011-01-05 20:19 ` Dave Korn
2011-01-05 20:25   ` Joseph S. Myers
2011-01-05 20:29     ` Dave Korn
2011-01-10 10:42       ` Rainer Orth
2011-02-18  7:51   ` Mike Stump
2011-01-05 20:22 ` Dave Korn
2011-01-10 10:44   ` Rainer Orth
2011-02-18  7:55   ` Mike Stump
2011-02-22 17:04     ` Rainer Orth
2011-01-06 21:17 ` Ralf Wildenhues
2011-01-10 10:41   ` Rainer Orth
2011-02-18  8:02     ` Mike Stump
2011-01-17 12:12   ` Rainer Orth
2011-01-17 13:32     ` IainS
2011-01-17 14:04       ` Rainer Orth
2011-01-24 14:02       ` Rainer Orth
2011-01-24 15:54         ` IainS
2011-01-24 15:57           ` Rainer Orth
2011-01-18 20:21     ` Ralf Wildenhues
2011-01-20 17:19       ` Rainer Orth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).