[v3] Testsuite header changes

Phil Edwards pedwards@disaster.jaj.com
Mon Aug 6 20:38:00 GMT 2001


On Mon, Aug 06, 2001 at 11:39:20AM -0700, Benjamin Kosnik wrote:
> > I went that exact same route.  The design of (and comments inside)
> > debug_assert.h made it seem that adding arbitrary stuff was out of line with
> > some redesign, so I went with a new file.  If they should be generalized
> > and merged (which sounds good), I can rename it to testsuite_hooks.h.
> 
> Sounds good. Please do this. I've done something similar trying to get 
> the location of the build-tree's message catalogs usable for 
> 22_locale/messages_*.cc test files.
> 
> I'll just merge into your changes.

Okay, here's what's going into the trunk.  Tested (many times) on i686-linux
and powerps-sim.  Benjamin, for your stuff the GLIBCPP_CONFIGURE_TESTSUITE
macro in acinclude.m4 may be the starting point, I dunno.

This merges the debug_assert.h VERIFY in with the resource limiting wrapper
I've been working on.  It sets up hooks for the resource limiting calls,
but none of that takes effect.  The memory-limiting stuff is all disabled
right now, and so the pathological-size string tests are unchanged.

Almost every testcase is touched, but the diff for each is only

    @@ -23,7 +23,7 @@
     // { dg-do link }

     #include <ciso646>
    -#include <debug_assert.h>
    +#include <testsuite_hooks.h>

Repeat 107 times.  So, for space reasons, I haven't included that boring
and verbose part of the diff.

Again, the __set_testsuite_memlimit() is disabled everywhere right now.
It's in a very primative state.


2001-08-06  Phil Edwards  <pme@sources.redhat.com>

	* acinclude.m4 (GLIBCPP_CONFIGURE_TESTSUITE):  New macro, calls...
	(GLIBCPP_CHECK_SETRLIMIT):  ...this new macro, which also uses...
	(GLIBCPP_CHECK_SETRLIMIT_ancilliary):  ...this new macro.
	* configure.in (AM_CONFIG_HEADER):  Also generate testsuite_hooks.h.
	Call GLIBCPP_CONFIGURE_TESTSUITE.
	* aclocal.m4:  Regenerate.
	* config.h.in:  Regenerate.
	* configure:  Regenerate.

	* testsuite/lib/libstdc++-v3-dg.exp:  Download new header instead
	of old header.

	* testsuite_flags.in:  Add build dir's testsuite to INCLUDES.
	* testsuite/debug_assert.h:  Removed; contents merged into...
	* testsuite/testsuite_hooks.h.in:  ...here.  New file.
	* testsuite/17_intro/header_ciso646.cc:  No longer include
	debug_assert.h, include testsuite_hooks.h instead.
	* testsuite/17_intro/header_fstream.cc:  Likewise.
	* testsuite/17_intro/header_iomanip.cc:  Likewise.
	* testsuite/17_intro/header_ios.cc:  Likewise.
	* testsuite/17_intro/header_iosfwd.cc:  Likewise.
	* testsuite/17_intro/header_iostream.cc:  Likewise.
	* testsuite/17_intro/header_istream.cc:  Likewise.
	* testsuite/17_intro/header_ostream.cc:  Likewise.
	* testsuite/17_intro/header_sstream.cc:  Likewise.
	* testsuite/17_intro/header_streambuf.cc:  Likewise.
	* testsuite/18_support/numeric_limits.cc:  Likewise.
	* testsuite/19_diagnostics/stdexceptions.cc:  Likewise.
	* testsuite/20_util/allocator_members.cc:  Likewise.
	* testsuite/20_util/auto_ptr.cc:  Likewise.
	* testsuite/20_util/pairs.cc:  Likewise.
	* testsuite/21_strings/append.cc:  Likewise.
	* testsuite/21_strings/capacity.cc:  Likewise.
	* testsuite/21_strings/char_traits_requirements.cc:  Likewise.
	* testsuite/21_strings/compare.cc:  Likewise.
	* testsuite/21_strings/ctor_copy_dtor.cc:  Likewise.  Also set up
	call to (disabled) __set_testsuite_memlimit() wrapper.
	* testsuite/21_strings/element_access.cc:  Likewise.
	* testsuite/21_strings/find.cc:  Likewise.
	* testsuite/21_strings/insert.cc:  Likewise.  Also set up call to
	(disabled) __set_testsuite_memlimit() wrapper.
	* testsuite/21_strings/inserters_extractors.cc:  Likewise.
	* testsuite/21_strings/invariants.cc:  Likewise.
	* testsuite/21_strings/nonmember.cc:  Likewise.
	* testsuite/21_strings/operations.cc:  Likewise.
	* testsuite/21_strings/replace.cc:  Likewise.
	* testsuite/21_strings/rfind.cc:  Likewise.
	* testsuite/21_strings/substr.cc:  Likewise.
	* testsuite/22_locale/codecvt_char_char.cc:  Likewise.
	* testsuite/22_locale/codecvt_unicode_char.cc:  Likewise.
	* testsuite/22_locale/codecvt_unicode_wchar_t.cc:  Likewise.
	* testsuite/22_locale/codecvt_wchar_t_char.cc:  Likewise.
	* testsuite/22_locale/ctor_copy_dtor.cc:  Likewise.
	* testsuite/22_locale/ctype_char_members.cc:  Likewise.
	* testsuite/22_locale/ctype_wchar_t_members.cc:  Likewise.
	* testsuite/22_locale/facet.cc:  Likewise.
	* testsuite/22_locale/global_templates.cc:  Likewise.
	* testsuite/22_locale/members.cc:  Likewise.
	* testsuite/22_locale/numpunct_byname.cc:  Likewise.
	* testsuite/22_locale/numpunct_char_members.cc:  Likewise.
	* testsuite/22_locale/operators.cc:  Likewise.
	* testsuite/22_locale/static_members.cc:  Likewise.
	* testsuite/23_containers/bitset_ctor.cc:  Likewise.
	* testsuite/23_containers/bitset_members.cc:  Likewise.
	* testsuite/23_containers/bitset_shift.cc:  Likewise.
	* testsuite/23_containers/vector_capacity.cc:  Likewise.
	* testsuite/23_containers/vector_ctor.cc:  Likewise.
	* testsuite/23_containers/vector_element_access.cc:  Likewise.
	* testsuite/23_containers/vector_modifiers.cc:  Likewise.
	* testsuite/24_iterators/istreambuf_iterator.cc:  Likewise.
	* testsuite/24_iterators/iterator.cc:  Likewise.
	* testsuite/24_iterators/ostreambuf_iterator.cc:  Likewise.
	* testsuite/25_algorithms/binary_search.cc:  Likewise.
	* testsuite/25_algorithms/copy.cc:  Likewise.
	* testsuite/25_algorithms/heap.cc:  Likewise.
	* testsuite/25_algorithms/lower_bound.cc:  Likewise.
	* testsuite/25_algorithms/min_max.cc:  Likewise.
	* testsuite/25_algorithms/partition.cc:  Likewise.
	* testsuite/25_algorithms/rotate.cc:  Likewise.
	* testsuite/25_algorithms/sort.cc:  Likewise.
	* testsuite/26_numerics/c_math.cc:  Likewise.
	* testsuite/26_numerics/complex_inserters_extractors.cc:  Likewise.
	* testsuite/26_numerics/complex_value.cc:  Likewise.
	* testsuite/27_io/filebuf.cc:  Likewise.
	* testsuite/27_io/filebuf_members.cc:  Likewise.
	* testsuite/27_io/filebuf_virtuals.cc:  Likewise.
	* testsuite/27_io/fpos.cc:  Likewise.
	* testsuite/27_io/fstream_members.cc:  Likewise.
	* testsuite/27_io/ifstream_members.cc:  Likewise.
	* testsuite/27_io/ios_base_callbacks.cc:  Likewise.
	* testsuite/27_io/ios_base_members_static.cc:  Likewise.
	* testsuite/27_io/ios_base_storage.cc:  Likewise.
	* testsuite/27_io/ios_ctor.cc:  Likewise.
	* testsuite/27_io/ios_init.cc:  Likewise.
	* testsuite/27_io/ios_manip_basefield.cc:  Likewise.
	* testsuite/27_io/ios_manip_fmtflags.cc:  Likewise.
	* testsuite/27_io/ios_members.cc:  Likewise.
	* testsuite/27_io/istream_extractor_arith.cc:  Likewise.
	* testsuite/27_io/istream_extractor_char.cc:  Likewise.
	* testsuite/27_io/istream_extractor_other.cc:  Likewise.
	* testsuite/27_io/istream_manip.cc:  Likewise.
	* testsuite/27_io/istream_seeks.cc:  Likewise.
	* testsuite/27_io/istream_sentry.cc:  Likewise.
	* testsuite/27_io/istream_unformatted.cc:  Likewise.
	* testsuite/27_io/istringstream_members.cc:  Likewise.
	* testsuite/27_io/narrow_stream_objects.cc:  Likewise.
	* testsuite/27_io/ofstream_members.cc:  Likewise.
	* testsuite/27_io/ostream_inserter_arith.cc:  Likewise.
	* testsuite/27_io/ostream_inserter_char.cc:  Likewise.
	* testsuite/27_io/ostream_inserter_other.cc:  Likewise.
	* testsuite/27_io/ostream_manip.cc:  Likewise.
	* testsuite/27_io/ostream_seeks.cc:  Likewise.
	* testsuite/27_io/ostream_unformatted.cc:  Likewise.
	* testsuite/27_io/ostringstream_members.cc:  Likewise.
	* testsuite/27_io/streambuf.cc:  Likewise.
	* testsuite/27_io/stringbuf.cc:  Likewise.
	* testsuite/27_io/stringbuf_virtuals.cc:  Likewise.
	* testsuite/27_io/stringstream.cc:  Likewise.
	* testsuite/27_io/stringstream_members.cc:  Likewise.
	* testsuite/27_io/wide_stream_objects.cc:  Likewise.


Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.168
diff -u -3 -p -r1.168 acinclude.m4
--- acinclude.m4	2001/07/25 08:06:42	1.168
+++ acinclude.m4	2001/08/07 03:25:35
@@ -1761,6 +1761,44 @@ dnl string, '#' otherwise
   AC_SUBST(ifGNUmake)
 ])
 
+
+dnl Check for headers for, and arguments to, the setrlimit() function.
+dnl Used only in testsuite_hooks.h.
+AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilliary, [
+  AC_TRY_COMPILE([#include <sys/resource.h>
+                  #include <unistd.h>
+                 ], [ int f = RLIMIT_$1 ; ],
+                 [glibcpp_mresult=1], [glibcpp_mresult=0])
+  AC_DEFINE_UNQUOTED(HAVE_MEMLIMIT_$1, $glibcpp_mresult,
+                     [Only used in build directory testsuite_hooks.h.])
+])
+AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
+  setrlimit_have_needed_headers=yes
+  AC_CHECK_HEADERS(sys/resource.h unistd.h,
+                   [],
+                   setrlimit_have_needed_headers=no)
+  # If don't have the headers, then we can't run the tests now, and we
+  # won't be seeing any of these during testsuite compilation.
+  if test $setrlimit_have_needed_headers = yes; then
+    # Can't do these in a loop, else the resulting syntax is wrong.
+    GLIBCPP_CHECK_SETRLIMIT_ancilliary(DATA)
+    GLIBCPP_CHECK_SETRLIMIT_ancilliary(RSS)
+    GLIBCPP_CHECK_SETRLIMIT_ancilliary(VMEM)
+    GLIBCPP_CHECK_SETRLIMIT_ancilliary(AS)
+  fi
+])
+
+
+dnl
+dnl Does any necessary configuration of the testsuite directory.  Generates
+dnl the testsuite_hooks.h header.
+dnl
+dnl GLIBCPP_CONFIGURE_TESTSUITE  [no args]
+AC_DEFUN(GLIBCPP_CONFIGURE_TESTSUITE, [
+  GLIBCPP_CHECK_SETRLIMIT
+])
+
+
 sinclude(../libtool.m4)
 dnl The lines below arrange for aclocal not to bring an installed
 dnl libtool.m4 into aclocal.m4, while still arranging for automake to
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.in,v
retrieving revision 1.69
diff -u -3 -p -r1.69 configure.in
--- configure.in	2001/07/16 17:43:54	1.69
+++ configure.in	2001/08/07 03:25:35
@@ -58,7 +58,7 @@ AC_SUBST(enable_shared)
 AC_SUBST(enable_static)
 GLIBCPP_CHECK_GNU_MAKE
 
-AM_CONFIG_HEADER(config.h)
+AM_CONFIG_HEADER(config.h testsuite/testsuite_hooks.h)
 
 # Check for c++ or library specific bits that don't require linking.
 GLIBCPP_CHECK_COMPILER_VERSION
@@ -221,6 +221,10 @@ else
 
   AC_FUNC_MMAP
 fi
+
+# Enable/configure some pieces which may require knowledge about the
+# compiler situation (native/cross), which we just finished discovering.
+GLIBCPP_CONFIGURE_TESTSUITE
 
 # Propagate the target-specific source directories through the build chain.
 OS_INC_SRCDIR=$os_include_dir/bits
Index: testsuite_flags.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite_flags.in,v
retrieving revision 1.5
diff -u -3 -p -r1.5 testsuite_flags.in
--- testsuite_flags.in	2001/07/13 16:47:55	1.5
+++ testsuite_flags.in	2001/08/07 03:25:35
@@ -28,13 +28,13 @@ query=$1
 
 case ${query} in
     --install-includes)
-      INCLUDES="-I${SRC_DIR}/testsuite"
+      INCLUDES="-I${SRC_DIR}/testsuite -I${BUILD_DIR}/testsuite"
       echo ${INCLUDES}
       ;;
     --build-includes)
       INCLUDES="-nostdinc++ @GLIBCPP_INCLUDES@
 	        -I${SRC_DIR}/libsupc++ -I${SRC_DIR}/libio 
-		-I${SRC_DIR}/testsuite"
+		-I${SRC_DIR}/testsuite -I${BUILD_DIR}/testsuite"
       echo ${INCLUDES}
       ;;
     --install-cxx)
Index: testsuite/testsuite_hooks.h.in
===================================================================
RCS file: testsuite_hooks.h.in
diff -N testsuite_hooks.h.in
--- /dev/null	Tue May  5 13:32:27 1998
+++ testsuite_hooks.h.in	Mon Aug  6 20:25:35 2001
@@ -0,0 +1,133 @@
+// Utility subroutines for the C++ library testsuite.
+//
+// Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library.  This library 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 2, or (at your option)
+// any later version.
+//
+// This library 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 library; see the file COPYING.  If not, write to the Free
+// Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+// USA.
+//
+// As a special exception, you may use this file as part of a free software
+// library without restriction.  Specifically, if other files instantiate
+// templates or use macros or inline functions from this file, or you compile
+// this file and link it with other files to produce an executable, this
+// file does not by itself cause the resulting executable to be covered by
+// the GNU General Public License.  This exception does not however
+// invalidate any other reasons why the executable file might be covered by
+// the GNU General Public License.
+
+// This file provides the following:
+//
+// 1)  VERIFY(), via DEBUG_ASSERT, from Brent Verner <brent@rcfile.org>.
+//   This file is included in the various testsuite programs to provide
+//   #define(able) assert() behavior for debugging/testing. It may be
+//   a suitable location for other furry woodland creatures as well.
+//
+// 2)  __set_testsuite_memlimit()
+//   __set_testsuite_memlimit() uses setrlimit() to restrict dynamic memory
+//   allocation.  We provide a default memory limit if none is passed by the
+//   calling application.  The argument to __set_testsuite_memlimit() is the
+//   limit in megabytes (a floating-point number).  If NO_MEM_LIMITS is
+//   #defined before including this header, then no limiting is attempted.
+
+#ifndef _GLIBCPP_TESTSUITE_HOOKS_H
+#define _GLIBCPP_TESTSUITE_HOOKS_H
+
+
+/*******
+ * VERIFY(), via DEBUG_ASSERT, from Brent Verner <brent@rcfile.org>.
+*/
+#ifdef DEBUG_ASSERT
+# include <cassert>
+# define VERIFY(fn) assert(fn)
+
+#else
+
+# define VERIFY(fn) test &= (fn)
+// should we define this here to make sure no 'unexpected' failures
+// happen, or do we require that it be defined in any scope where
+// the VERIFY macro is used???
+//
+// static bool test = true;
+#endif
+
+
+/*******
+ * __set_testsuite_memlimit()
+*/
+// The RLIMIT_* macros used will be as many of the following as we can find,
+// and they will be used in this order, for whatever difference it makes:
+//   RLIMIT_DATA
+//   RLIMIT_RSS
+//   RLIMIT_VMEM
+//   RLIMIT_AS
+
+#define NO_MEM_LIMITS
+
+// The following lines will be changed by configure...
+#undef HAVE_SYS_RESOURCE_H
+#undef HAVE_UNISTD_H
+#undef HAVE_MEMLIMIT_DATA
+#undef HAVE_MEMLIMIT_RSS
+#undef HAVE_MEMLIMIT_VMEM
+#undef HAVE_MEMLIMIT_AS
+
+// ...and the results used here.
+#if defined(HAVE_SYS_RESOURCE_H) && defined(HAVE_UNISTD_H) && !defined(NO_MEM_LIMITS)
+
+#include <sys/resource.h>
+#include <unistd.h>
+
+#ifndef MEMLIMIT_MB
+#define MEMLIMIT_MB 16.0
+#endif
+
+void
+__set_testsuite_memlimit(float megs = MEMLIMIT_MB)
+{
+    struct rlimit r;
+    r.rlim_cur = (rlim_t)(megs * 1048576);
+
+    // heap size, seems to be common
+#if HAVE_MEMLIMIT_DATA
+    setrlimit (RLIMIT_DATA, &r);
+#endif
+
+    // resident set size -- Linux?
+#if HAVE_MEMLIMIT_RSS
+    setrlimit (RLIMIT_RSS, &r);
+#endif
+
+    // mapped memory (brk+mmap) -- Solaris?
+#if HAVE_MEMLIMIT_VMEM
+    setrlimit (RLIMIT_VMEM, &r);
+#endif
+
+    // virtual memory, seems to be common
+#if HAVE_MEMLIMIT_AS
+    setrlimit (RLIMIT_AS, &r);
+#endif
+}
+
+#else
+// The headers needed for resource limiting are not available.  This is
+// safe, but means that no memory limits will be applied... ouch.
+#define __set_testsuite_memlimit(__junk)
+#endif
+
+
+
+
+#endif // _GLIBCPP_TESTSUITE_HOOKS_H
+
Index: testsuite/21_strings/ctor_copy_dtor.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/21_strings/ctor_copy_dtor.cc,v
retrieving revision 1.7
diff -u -3 -p -r1.7 ctor_copy_dtor.cc
--- ctor_copy_dtor.cc	2001/07/13 20:50:02	1.7
+++ ctor_copy_dtor.cc	2001/08/07 03:25:35
@@ -23,7 +23,7 @@
 #include <new>
 #include <string>
 #include <stdexcept>
-#include <debug_assert.h>
+#include <testsuite_hooks.h>
 
 int test01(void)
 {
@@ -196,6 +196,7 @@ void test03()
 
 int main()
 { 
+  __set_testsuite_memlimit();
   test01();
   test02();
   test03();
Index: testsuite/21_strings/insert.cc
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/21_strings/insert.cc,v
retrieving revision 1.3
diff -u -3 -p -r1.3 insert.cc
--- insert.cc	2001/05/12 16:51:41	1.3
+++ insert.cc	2001/08/07 03:25:35
@@ -22,7 +22,7 @@
 
 #include <string>
 #include <stdexcept>
-#include <debug_assert.h>
+#include <testsuite_hooks.h>
 
 int test01(void)
 {
@@ -189,6 +189,7 @@ int test01(void)
 
 int main()
 { 
+  __set_testsuite_memlimit();
   test01();
   return 0;
 }
Index: testsuite/lib/libstdc++-v3-dg.exp
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp,v
retrieving revision 1.6
diff -u -3 -p -r1.6 libstdc++-v3-dg.exp
--- libstdc++-v3-dg.exp	2001/05/30 20:25:51	1.6
+++ libstdc++-v3-dg.exp	2001/08/07 03:25:36
@@ -53,9 +53,9 @@ proc libstdc++-v3-init { args } {
     # Do a bunch of handstands and backflips for cross compiling and
     # finding simulators...
     if [is_remote host] {
-        set header [remote_download host ${srcdir}/debug_assert.h]
+        set header [remote_download host ${blddir}/testsuite/testsuite_hooks.h]
         if { $header == "" } {
-            verbose -log "Unable to download ${srcdir}/debug_assert.h to host."
+            verbose -log "Unable to download ${blddir}/testsuite/testsuite_hooks.h to host."
             return "untested"
         }
       set cxx [transform "g++"]



More information about the Gcc-patches mailing list