[v3] testsuite memory checking
benjamin kosnik
bkoz@waller.constant.com
Thu Aug 9 20:28:00 GMT 2001
Seems to work... pending serious objection, I'll check this in.
2001-08-09 Benjamin Kosnik <bkoz@redhat.com>
* acconfig.h (_GLIBCPP_MEM_LIMITS): Define.
* config.h.in: Regenerate.
* acinclude.m4 (GLIBCPP_CHECK_SETRLIMIT): Check for setrlimit
function.
* aclocal.m4: Regenerate.
* configure.in: Remove duplicate AM_CONFIG_HEADER.
(AM_CONFIG_HEADER): Remove testsuite/testsuite_hooks.h.
Only call GLIBCPP_CHECK_SETRLIMIT for native compiles.
* configure: Regenerate.
* testsuite_hooks.h.in: Move to...
* testsuite_hooks.h: Here, include c++config.h. Use it.
Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/Makefile.am,v
retrieving revision 1.24
diff -c -p -r1.24 Makefile.am
*** Makefile.am 2001/08/08 02:48:51 1.24
--- Makefile.am 2001/08/10 03:22:06
***************
*** 1,6 ****
## Makefile for the toplevel directory of the GNU C++ Standard library.
##
! ## Copyright (C) 1997,1998, 1999, 2000, 2001 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
--- 1,6 ----
## Makefile for the toplevel directory of the GNU C++ Standard library.
##
! ## Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
##
## This file is part of the libstdc++ version 3 distribution.
## Process this file with automake to produce Makefile.in.
Index: acconfig.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acconfig.h,v
retrieving revision 1.20
diff -c -p -r1.20 acconfig.h
*** acconfig.h 2001/08/08 02:48:51 1.20
--- acconfig.h 2001/08/10 03:22:07
***************
*** 31,36 ****
--- 31,39 ----
// Define if code specialized for wchar_t should be used.
#undef _GLIBCPP_USE_WCHAR_T
+ // Define if using setrlimit to limit memory usage during 'make check'.
+ #undef _GLIBCPP_MEM_LIMITS
+
// Define if you have the atan2f function.
#undef _GLIBCPP_HAVE_ATAN2F
Index: acinclude.m4
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/acinclude.m4,v
retrieving revision 1.170
diff -c -p -r1.170 acinclude.m4
*** acinclude.m4 2001/08/08 02:48:51 1.170
--- acinclude.m4 2001/08/10 03:22:12
*************** AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT_ancilli
*** 1819,1837 ****
[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
])
--- 1819,1855 ----
[Only used in build directory testsuite_hooks.h.])
])
AC_DEFUN(GLIBCPP_CHECK_SETRLIMIT, [
! setrlimit_have_headers=yes
AC_CHECK_HEADERS(sys/resource.h unistd.h,
[],
! setrlimit_have_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_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)
+
+ # Check for rlimit, setrlimit.
+ AC_CACHE_VAL(ac_setrlimit, [
+ AC_TRY_COMPILE([#include <sys/resource.h>
+ #include <unistd.h>
+ ],
+ [ struct rlimit r; setrlimit(0, &r);],
+ [ac_setrlimit=yes], [ac_setrlimit=no])
+ ])
fi
+
+ AC_MSG_CHECKING([for testsuite memory limit support])
+ if test $setrlimit_have_headers = yes && test $ac_setrlimit = yes; then
+ ac_mem_limits=yes
+ AC_DEFINE(_GLIBCPP_MEM_LIMITS)
+ else
+ ac_mem_limits=no
+ fi
+ AC_MSG_RESULT($ac_mem_limits)
])
Index: configure.in
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/configure.in,v
retrieving revision 1.71
diff -c -p -r1.71 configure.in
*** configure.in 2001/08/08 02:48:57 1.71
--- configure.in 2001/08/10 03:23:04
*************** VERSION=$MAJOR_VERSION.$MINOR_VERSION.$M
*** 12,18 ****
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
! # Gets and sets build, host, target, *_vendor, *_cpu, *_os, etc.
# AC 2.50 sets target_alias iff the user specified --target, but we use it
# everywhere, so we set it here just to be sure.
AC_CANONICAL_SYSTEM
--- 12,18 ----
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
! # Gets build, host, target, *_vendor, *_cpu, *_os, etc.
# AC 2.50 sets target_alias iff the user specified --target, but we use it
# everywhere, so we set it here just to be sure.
AC_CANONICAL_SYSTEM
*************** AM_PROG_LIBTOOL
*** 32,39 ****
AC_SUBST(enable_shared)
AC_SUBST(enable_static)
- 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
GLIBCPP_CHECK_GNU_MAKE
--- 32,37 ----
*************** else
*** 189,194 ****
--- 187,193 ----
GLIBCPP_CHECK_COMPLEX_MATH_SUPPORT
GLIBCPP_CHECK_WCHAR_T_SUPPORT
GLIBCPP_CHECK_STDLIB_SUPPORT
+ AC_LC_MESSAGES
AC_TRY_COMPILE([
#include <setjmp.h>
*************** else
*** 197,207 ****
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
--- 196,205 ----
AC_FUNC_MMAP
+ # Establish limits on memory usage during 'make check'
+ GLIBCPP_CONFIGURE_TESTSUITE
fi
# Propagate the target-specific source directories through the build chain.
OS_INC_SRCDIR=$os_include_dir/bits
*************** AC_SUBST(GLIBCPP_IS_CROSS_COMPILING)
*** 214,220 ****
AM_CONDITIONAL(CANADIAN, test "$CANADIAN" = yes)
AC_CACHE_SAVE
- AC_LC_MESSAGES
if test "${multilib}" = "yes"; then
multilib_arg="--enable-multilib"
--- 212,217 ----
Index: testsuite/testsuite_hooks.h
===================================================================
RCS file: testsuite_hooks.h
diff -N testsuite_hooks.h
*** /dev/null Tue May 5 13:32:27 1998
--- testsuite_hooks.h Thu Aug 9 20:23:13 2001
***************
*** 0 ****
--- 1,104 ----
+ // 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 _GLIBCPP_MEM_LIMITS is
+ // #defined before including this header, then no limiting is attempted.
+
+ #ifndef _GLIBCPP_TESTSUITE_HOOKS_H
+ #define _GLIBCPP_TESTSUITE_HOOKS_H
+
+ #ifdef DEBUG_ASSERT
+ # include <cassert>
+ # define VERIFY(fn) assert(fn)
+ #else
+ # define VERIFY(fn) test &= (fn)
+ # define VERIFY(fn) fn
+ #endif
+
+ #include <bits/c++config.h>
+
+ // Defined in GLIBCPP_CONFIGURE_TESTSUITE.
+ #ifndef _GLIBCPP_MEM_LIMITS
+
+ // Don't do memory limits.
+ void
+ __set_testsuite_memlimit(float)
+ { }
+
+ #else
+
+ // Do memory limits.
+ #include <sys/resource.h>
+ #include <unistd.h>
+
+ #ifndef MEMLIMIT_MB
+ #define MEMLIMIT_MB 16.0
+ #endif
+
+ void
+ __set_testsuite_memlimit(float __size = MEMLIMIT_MB)
+ {
+ struct rlimit r;
+ r.rlim_cur = (rlim_t)(__size * 1048576);
+
+ // Heap size, seems to be common.
+ #if _GLIBCPP_HAVE_MEMLIMIT_DATA
+ setrlimit(RLIMIT_DATA, &r);
+ #endif
+
+ // Resident set size.
+ #if _GLIBCPP_HAVE_MEMLIMIT_RSS
+ setrlimit(RLIMIT_RSS, &r);
+ #endif
+
+ // Mapped memory (brk + mmap).
+ #if _GLIBCPP_HAVE_MEMLIMIT_VMEM
+ setrlimit(RLIMIT_VMEM, &r);
+ #endif
+
+ // Virtual memory.
+ #if _GLIBCPP_HAVE_MEMLIMIT_AS
+ setrlimit(RLIMIT_AS, &r);
+ #endif
+ }
+ #endif
+
+ #endif // _GLIBCPP_TESTSUITE_HOOKS_H
+
Index: testsuite/testsuite_hooks.h.in
===================================================================
RCS file: testsuite_hooks.h.in
diff -N testsuite_hooks.h.in
*** /sourceware/cvs-tmp/cvs2H2UT0 Thu Aug 9 20:23:21 2001
--- /dev/null Tue May 5 13:32:27 1998
***************
*** 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
-
--- 0 ----
More information about the Gcc-patches
mailing list