From 8ea08b7d7bd834782e403121564b9eb2ee6e15a0 Mon Sep 17 00:00:00 2001 From: Phil Edwards Date: Tue, 28 May 2002 23:15:18 +0000 Subject: [PATCH] Makefile.am (noinst_LIBRARIES): New target. 2002-05-28 Phil Edwards * testsuite/Makefile.am (noinst_LIBRARIES): New target. Pull in CXX/INCLUDES. * testsuite/Makefile.in: Regenerate. * testsuite/testsuite_hooks.h (gnu_copy_tracker): Move from list_modifiers.cc and rename from 'T'. Move code bodies... * testsuite/testsuite_hooks.cc: ...to here. New file. * testsuite/23_containers/list_modifiers.cc: Move 'T' class out. * testsuite/lib/libstdc++-v3-dg.exp (libstdc++-v3_target_compile): Add libv3test.a to link options. From-SVN: r53977 --- libstdc++-v3/ChangeLog | 12 + .../testsuite/23_containers/list_modifiers.cc | 56 +---- libstdc++-v3/testsuite/Makefile.am | 11 +- libstdc++-v3/testsuite/Makefile.in | 244 ++++++++++++++++++--- libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp | 7 +- .../{testsuite_hooks.h => testsuite_hooks.cc} | 72 +----- libstdc++-v3/testsuite/testsuite_hooks.h | 101 +++++---- 7 files changed, 316 insertions(+), 187 deletions(-) copy libstdc++-v3/testsuite/{testsuite_hooks.h => testsuite_hooks.cc} (50%) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 65f9f397755..a8e3e701bd1 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,15 @@ +2002-05-28 Phil Edwards + + * testsuite/Makefile.am (noinst_LIBRARIES): New target. Pull in + CXX/INCLUDES. + * testsuite/Makefile.in: Regenerate. + * testsuite/testsuite_hooks.h (gnu_copy_tracker): Move from + list_modifiers.cc and rename from 'T'. Move code bodies... + * testsuite/testsuite_hooks.cc: ...to here. New file. + * testsuite/23_containers/list_modifiers.cc: Move 'T' class out. + * testsuite/lib/libstdc++-v3-dg.exp (libstdc++-v3_target_compile): + Add libv3test.a to link options. + 2002-05-27 Benjamin Kosnik * src/misc-inst.cc: Define unnecessary algorithm diff --git a/libstdc++-v3/testsuite/23_containers/list_modifiers.cc b/libstdc++-v3/testsuite/23_containers/list_modifiers.cc index 9ce078143ad..14b53657e05 100644 --- a/libstdc++-v3/testsuite/23_containers/list_modifiers.cc +++ b/libstdc++-v3/testsuite/23_containers/list_modifiers.cc @@ -21,59 +21,9 @@ #include #include -bool test = true; - -// Here's a class with nontrivial ctor/dtor that provides -// the ability to track the number of copy ctors and dtors -// and will throw on demand during copy. -class T -{ -public: - // default constructor - T(int anId, bool throwOnDemand = false) - : itsId(anId), willThrow(throwOnDemand) - { } - - // copy constructor - T(const T& rhs) - : itsId(rhs.id()), willThrow(rhs.willThrow) - { - ++itsCopyCount; - if (willThrow) - throw "exception"; - } - - ~T() - { ++itsDtorCount; } - - int - id() const - { return itsId; } +typedef gnu_copy_tracker T; -private: - const int itsId; - const bool willThrow; - -public: - static void - reset() - { itsCopyCount = 0; itsDtorCount = 0; } - - static int - copyCount() - { return itsCopyCount; } - - static int - dtorCount() - { return itsDtorCount; } - -private: - static int itsCopyCount; - static int itsDtorCount; -}; - -int T::itsCopyCount = 0; -int T::itsDtorCount = 0; +bool test = true; // This test verifies the following. @@ -314,7 +264,7 @@ test03() VERIFY(e == list0301.end()); } -main(int argc, char* argv[]) +int main() { test01(); test02(); diff --git a/libstdc++-v3/testsuite/Makefile.am b/libstdc++-v3/testsuite/Makefile.am index 6aecb39485a..dba4ccf20c8 100644 --- a/libstdc++-v3/testsuite/Makefile.am +++ b/libstdc++-v3/testsuite/Makefile.am @@ -1,6 +1,6 @@ ## Makefile for the testsuite subdirectory of the GNU C++ Standard library. ## -## Copyright (C) 2001 Free Software Foundation, Inc. +## Copyright (C) 2001, 2002 Free Software Foundation, Inc. ## ## This file is part of the libstdc++ version 3 distribution. ## Process this file with automake to produce Makefile.in. @@ -35,3 +35,12 @@ RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then \ RUNTESTFLAGS = +CXX = @glibcpp_CXX@ @GLIBCPP_INCLUDES@ +# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES +INCLUDES = @TOPLEVEL_INCLUDES@ + +noinst_LIBRARIES = libv3test.a + +libv3test_a_SOURCES = testsuite_hooks.cc + + diff --git a/libstdc++-v3/testsuite/Makefile.in b/libstdc++-v3/testsuite/Makefile.in index 4e20e949753..79c9a4189a3 100644 --- a/libstdc++-v3/testsuite/Makefile.in +++ b/libstdc++-v3/testsuite/Makefile.in @@ -1,6 +1,6 @@ -# Makefile.in generated automatically by automake 1.4-p5 from Makefile.am +# Makefile.in generated automatically by automake 1.4 from Makefile.am -# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc. +# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -68,6 +68,9 @@ AS = @AS@ ATOMICITY_INC_SRCDIR = @ATOMICITY_INC_SRCDIR@ AWK = @AWK@ BASIC_FILE_H = @BASIC_FILE_H@ +BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCODECVT_C = @CCODECVT_C@ CCODECVT_H = @CCODECVT_H@ @@ -77,17 +80,27 @@ CPP = @CPP@ CPU_LIMITS_INC_SRCDIR = @CPU_LIMITS_INC_SRCDIR@ CSHADOW_FLAGS = @CSHADOW_FLAGS@ CSTDIO_H = @CSTDIO_H@ -CXX = @CXX@ CXXCPP = @CXXCPP@ C_INCLUDE_DIR = @C_INCLUDE_DIR@ +DATADIRNAME = @DATADIRNAME@ DEBUG_FLAGS = @DEBUG_FLAGS@ DLLTOOL = @DLLTOOL@ EXEEXT = @EXEEXT@ EXTRA_CXX_FLAGS = @EXTRA_CXX_FLAGS@ GCJ = @GCJ@ GCJFLAGS = @GCJFLAGS@ +GENCAT = @GENCAT@ +GLIBC21 = @GLIBC21@ GLIBCPP_INCLUDES = @GLIBCPP_INCLUDES@ GLIBCPP_IS_CROSS_COMPILING = @GLIBCPP_IS_CROSS_COMPILING@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +INSTOBJEXT = @INSTOBJEXT@ +INTLBISON = @INTLBISON@ +INTLLIBS = @INTLLIBS@ +INTLOBJS = @INTLOBJS@ +INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@ +LIBICONV = @LIBICONV@ LIBIO_INCLUDES = @LIBIO_INCLUDES@ LIBMATHOBJS = @LIBMATHOBJS@ LIBMATH_INCLUDES = @LIBMATH_INCLUDES@ @@ -98,17 +111,22 @@ LIBUNWIND_FLAG = @LIBUNWIND_FLAG@ LN_S = @LN_S@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ OBJDUMP = @OBJDUMP@ OBJEXT = @OBJEXT@ OPTIMIZE_CXXFLAGS = @OPTIMIZE_CXXFLAGS@ OPT_LDFLAGS = @OPT_LDFLAGS@ OS_INC_SRCDIR = @OS_INC_SRCDIR@ PACKAGE = @PACKAGE@ +POFILES = @POFILES@ +POSUB = @POSUB@ RANLIB = @RANLIB@ SECTION_FLAGS = @SECTION_FLAGS@ SECTION_LDFLAGS = @SECTION_LDFLAGS@ STRIP = @STRIP@ TOPLEVEL_INCLUDES = @TOPLEVEL_INCLUDES@ +USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ WARN_FLAGS = @WARN_FLAGS@ @@ -149,9 +167,31 @@ RUNTEST = `if [ -f @glibcpp_srcdir@/../dejagnu/runtest ] ; then \ RUNTESTFLAGS = + +CXX = @glibcpp_CXX@ @GLIBCPP_INCLUDES@ +# Use common includes from acinclude.m4/GLIBCPP_EXPORT_INCLUDES +INCLUDES = @TOPLEVEL_INCLUDES@ + +noinst_LIBRARIES = libv3test.a + +libv3test_a_SOURCES = testsuite_hooks.cc mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = +LIBRARIES = $(noinst_LIBRARIES) + + +DEFS = @DEFS@ -I. -I$(srcdir) -I.. +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +libv3test_a_LIBADD = +libv3test_a_OBJECTS = testsuite_hooks.$(OBJEXT) +CXXFLAGS = @CXXFLAGS@ +CXXCOMPILE = $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) --mode=compile $(CXX) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) --mode=link $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ DIST_COMMON = README Makefile.am Makefile.in @@ -159,26 +199,120 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) TAR = gtar GZIP_ENV = --best +DEP_FILES = .deps/testsuite_hooks.P +SOURCES = $(libv3test_a_SOURCES) +OBJECTS = $(libv3test_a_OBJECTS) + all: all-redirect .SUFFIXES: +.SUFFIXES: .S .c .cc .lo .o .obj .s $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) - cd $(top_srcdir) && $(AUTOMAKE) --cygnus testsuite/Makefile + cd $(top_srcdir) && $(AUTOMAKE) --foreign testsuite/Makefile -Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) cd $(top_builddir) \ && CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status + +mostlyclean-noinstLIBRARIES: + +clean-noinstLIBRARIES: + -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) + +distclean-noinstLIBRARIES: + +maintainer-clean-noinstLIBRARIES: + +# FIXME: We should only use cygpath when building on Windows, +# and only if it is available. +.c.obj: + $(COMPILE) -c `cygpath -w $<` + +.s.o: + $(COMPILE) -c $< + +.S.o: + $(COMPILE) -c $< + +mostlyclean-compile: + -rm -f *.o core *.core + -rm -f *.$(OBJEXT) + +clean-compile: + +distclean-compile: + -rm -f *.tab.c + +maintainer-clean-compile: + +.s.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +.S.lo: + $(LIBTOOL) --mode=compile $(COMPILE) -c $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +distclean-libtool: + +maintainer-clean-libtool: + +libv3test.a: $(libv3test_a_OBJECTS) $(libv3test_a_DEPENDENCIES) + -rm -f libv3test.a + $(AR) cru libv3test.a $(libv3test_a_OBJECTS) $(libv3test_a_LIBADD) + $(RANLIB) libv3test.a +.cc.o: + $(CXXCOMPILE) -c $< +.cc.obj: + $(CXXCOMPILE) -c `cygpath -w $<` +.cc.lo: + $(LTCXXCOMPILE) -c $< + tags: TAGS -TAGS: +ID: $(HEADERS) $(SOURCES) $(LISP) + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + here=`pwd` && cd $(srcdir) \ + && mkid -f$$here/ID $$unique $(LISP) + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) + tags=; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS)'; \ + unique=`for i in $$list; do echo $$i; done | \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ + test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ + || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) + +mostlyclean-tags: + +clean-tags: + +distclean-tags: + -rm -f TAGS ID + +maintainer-clean-tags: distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) subdir = testsuite distdir: $(DISTFILES) + here=`cd $(top_builddir) && pwd`; \ + top_distdir=`cd $(top_distdir) && pwd`; \ + distdir=`cd $(distdir) && pwd`; \ + cd $(top_srcdir) \ + && $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --foreign testsuite/Makefile @for file in $(DISTFILES); do \ - if test -f $$file; then d=.; else d=$(srcdir); fi; \ + d=$(srcdir); \ if test -d $$d/$$file; then \ cp -pr $$d/$$file $(distdir)/$$file; \ else \ @@ -188,15 +322,62 @@ distdir: $(DISTFILES) fi; \ done +DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) + +-include $(DEP_FILES) + +mostlyclean-depend: + +clean-depend: + +distclean-depend: + -rm -rf .deps + +maintainer-clean-depend: + +%.o: %.c + @echo '$(COMPILE) -c $<'; \ + $(COMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.c + @echo '$(LTCOMPILE) -c $<'; \ + $(LTCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + +%.o: %.cc + @echo '$(CXXCOMPILE) -c $<'; \ + $(CXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-cp .deps/$(*F).pp .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm .deps/$(*F).pp + +%.lo: %.cc + @echo '$(LTCXXCOMPILE) -c $<'; \ + $(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c $< + @-sed -e 's/^\([^:]*\)\.o[ ]*:/\1.lo \1.o :/' \ + < .deps/$(*F).pp > .deps/$(*F).P; \ + tr ' ' '\012' < .deps/$(*F).pp \ + | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \ + >> .deps/$(*F).P; \ + rm -f .deps/$(*F).pp + RUNTESTDEFAULTFLAGS = --tool $(DEJATOOL) --srcdir $$srcdir check-DEJAGNU: site.exp srcdir=`cd $(srcdir) && pwd`; export srcdir; \ EXPECT=$(EXPECT); export EXPECT; \ - if [ -f $(top_builddir)/../expect/expect ]; then \ - TCL_LIBRARY=`cd $(top_srcdir)/../tcl/library && pwd`; \ - export TCL_LIBRARY; \ - fi; \ runtest=$(RUNTEST); \ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \ $$runtest $(RUNTESTDEFAULTFLAGS) $(RUNTESTFLAGS); \ @@ -225,13 +406,11 @@ info-am: info: info-am dvi-am: dvi: dvi-am -check-am: +check-am: all-am $(MAKE) $(AM_MAKEFLAGS) check-DEJAGNU check: check-am installcheck-am: installcheck: installcheck-am -install-info-am: -install-info: install-info-am install-exec-am: install-exec: install-exec-am @@ -243,7 +422,7 @@ install-am: all-am install: install-am uninstall-am: uninstall: uninstall-am -all-am: Makefile +all-am: Makefile $(LIBRARIES) all-redirect: all-am install-strip: $(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install @@ -259,31 +438,46 @@ distclean-generic: -rm -f config.cache config.log stamp-h stamp-h[0-9]* maintainer-clean-generic: -mostlyclean-am: mostlyclean-generic +mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \ + mostlyclean-libtool mostlyclean-tags mostlyclean-depend \ + mostlyclean-generic mostlyclean: mostlyclean-am -clean-am: clean-generic mostlyclean-am +clean-am: clean-noinstLIBRARIES clean-compile clean-libtool clean-tags \ + clean-depend clean-generic mostlyclean-am clean: clean-am -distclean-am: distclean-generic clean-am +distclean-am: distclean-noinstLIBRARIES distclean-compile \ + distclean-libtool distclean-tags distclean-depend \ + distclean-generic clean-am -rm -f libtool distclean: distclean-am -maintainer-clean-am: maintainer-clean-generic distclean-am +maintainer-clean-am: maintainer-clean-noinstLIBRARIES \ + maintainer-clean-compile maintainer-clean-libtool \ + maintainer-clean-tags maintainer-clean-depend \ + maintainer-clean-generic distclean-am @echo "This command is intended for maintainers to use;" @echo "it deletes files that may require special tools to rebuild." maintainer-clean: maintainer-clean-am -.PHONY: tags distdir check-DEJAGNU info-am info dvi-am dvi check \ -check-am installcheck-am installcheck install-info-am install-info \ -install-exec-am install-exec install-data-am install-data install-am \ -install uninstall-am uninstall all-redirect all-am all installdirs \ -mostlyclean-generic distclean-generic clean-generic \ -maintainer-clean-generic clean mostlyclean distclean maintainer-clean +.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \ +clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \ +mostlyclean-compile distclean-compile clean-compile \ +maintainer-clean-compile mostlyclean-libtool distclean-libtool \ +clean-libtool maintainer-clean-libtool tags mostlyclean-tags \ +distclean-tags clean-tags maintainer-clean-tags distdir \ +mostlyclean-depend distclean-depend clean-depend \ +maintainer-clean-depend check-DEJAGNU info-am info dvi-am dvi check \ +check-am installcheck-am installcheck install-exec-am install-exec \ +install-data-am install-data install-am install uninstall-am uninstall \ +all-redirect all-am all installdirs mostlyclean-generic \ +distclean-generic clean-generic maintainer-clean-generic clean \ +mostlyclean distclean maintainer-clean # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp b/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp index adbd148e0bb..a9433ef3680 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp @@ -196,7 +196,12 @@ proc libstdc++-v3_target_compile { source dest type options } { set cxx_final [concat $cxx_final $cxxflags] set cxx_final [concat $cxx_final $includes] - lappend options "compiler=$cxx_final"; + lappend options "compiler=$cxx_final" + + # Picks up our local freshly-built testsuite library. We could just + # name it directly, "./libv3test.a" but this is more portable. + lappend options "ldflags=-L." + lappend options "libs=-lv3test" return [target_compile $source $dest $type $options] } diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.cc similarity index 50% copy from libstdc++-v3/testsuite/testsuite_hooks.h copy to libstdc++-v3/testsuite/testsuite_hooks.cc index eb87d51f297..53bd753b1a8 100644 --- a/libstdc++-v3/testsuite/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/testsuite_hooks.cc @@ -1,6 +1,6 @@ // Utility subroutines for the C++ library testsuite. // -// Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc. +// Copyright (C) 2002 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 @@ -27,58 +27,14 @@ // 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 . -// 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 -// not #defined before including this header, then no limiting is attempted. -// -// 3) gnu_counting_struct -// This is a POD with a static data member, gnu_counting_struct::count, -// which starts at zero, increments on instance construction, and decrements -// on instance destruction. "assert_count(n)" can be called to VERIFY() -// that the count equals N. - -#ifndef _GLIBCPP_TESTSUITE_HOOKS_H -#define _GLIBCPP_TESTSUITE_HOOKS_H - -#ifdef DEBUG_ASSERT -# include -# define VERIFY(fn) assert(fn) -#else -# define VERIFY(fn) test &= (fn) -#endif - -#include - -// Defined in GLIBCPP_CONFIGURE_TESTSUITE. -#ifndef _GLIBCPP_MEM_LIMITS - -// Don't do memory limits. -void -__set_testsuite_memlimit(float x = 0) -{ } - -#else +#include -// Do memory limits. +#ifdef _GLIBCPP_MEM_LIMITS #include #include -#ifndef MEMLIMIT_MB -#define MEMLIMIT_MB 16.0 -#endif - void -__set_testsuite_memlimit(float __size = MEMLIMIT_MB) +__set_testsuite_memlimit(float __size) { struct rlimit r; rlim_t limit = (rlim_t)(__size * 1048576); @@ -111,25 +67,11 @@ __set_testsuite_memlimit(float __size = MEMLIMIT_MB) setrlimit(RLIMIT_AS, &r); #endif } -#endif +#endif /* _GLIBCPP_MEM_LIMITS */ -struct gnu_counting_struct -{ - // Specifically and glaringly-obviously marked 'signed' so that when - // count mistakenly goes negative, we can track the patterns of - // deletions easier. - typedef signed int size_type; - static size_type count; - gnu_counting_struct() { ++count; } - gnu_counting_struct (const gnu_counting_struct&) { ++count; } - ~gnu_counting_struct() { --count; } -}; - -#define assert_count(n) VERIFY(gnu_counting_struct::count == n) - gnu_counting_struct::size_type gnu_counting_struct::count = 0; - -#endif // _GLIBCPP_TESTSUITE_HOOKS_H +int gnu_copy_tracker::itsCopyCount = 0; +int gnu_copy_tracker::itsDtorCount = 0; diff --git a/libstdc++-v3/testsuite/testsuite_hooks.h b/libstdc++-v3/testsuite/testsuite_hooks.h index eb87d51f297..4412336d47f 100644 --- a/libstdc++-v3/testsuite/testsuite_hooks.h +++ b/libstdc++-v3/testsuite/testsuite_hooks.h @@ -46,6 +46,10 @@ // which starts at zero, increments on instance construction, and decrements // on instance destruction. "assert_count(n)" can be called to VERIFY() // that the count equals N. +// +// 4) gnu_copy_tracker, from Stephen M. Webb . +// A class with nontrivial ctor/dtor that provides the ability to track the +// number of copy ctors and dtors, and will throw on demand during copy. #ifndef _GLIBCPP_TESTSUITE_HOOKS_H #define _GLIBCPP_TESTSUITE_HOOKS_H @@ -61,64 +65,28 @@ // Defined in GLIBCPP_CONFIGURE_TESTSUITE. #ifndef _GLIBCPP_MEM_LIMITS - // Don't do memory limits. -void +extern void __set_testsuite_memlimit(float x = 0) { } #else // Do memory limits. -#include -#include - #ifndef MEMLIMIT_MB #define MEMLIMIT_MB 16.0 #endif -void -__set_testsuite_memlimit(float __size = MEMLIMIT_MB) -{ - struct rlimit r; - rlim_t limit = (rlim_t)(__size * 1048576); - - // Heap size, seems to be common. -#if _GLIBCPP_HAVE_MEMLIMIT_DATA - getrlimit(RLIMIT_DATA, &r); - r.rlim_cur = limit; - setrlimit(RLIMIT_DATA, &r); -#endif - - // Resident set size. -#if _GLIBCPP_HAVE_MEMLIMIT_RSS - getrlimit(RLIMIT_RSS, &r); - r.rlim_cur = limit; - setrlimit(RLIMIT_RSS, &r); -#endif - - // Mapped memory (brk + mmap). -#if _GLIBCPP_HAVE_MEMLIMIT_VMEM - getrlimit(RLIMIT_VMEM, &r); - r.rlim_cur = limit; - setrlimit(RLIMIT_VMEM, &r); -#endif - - // Virtual memory. -#if _GLIBCPP_HAVE_MEMLIMIT_AS - getrlimit(RLIMIT_AS, &r); - r.rlim_cur = limit; - setrlimit(RLIMIT_AS, &r); -#endif -} +extern void +__set_testsuite_memlimit(float __size = MEMLIMIT_MB); #endif struct gnu_counting_struct { // Specifically and glaringly-obviously marked 'signed' so that when - // count mistakenly goes negative, we can track the patterns of - // deletions easier. + // COUNT mistakenly goes negative, we can track the patterns of + // deletions more easily. typedef signed int size_type; static size_type count; gnu_counting_struct() { ++count; } @@ -128,7 +96,56 @@ struct gnu_counting_struct #define assert_count(n) VERIFY(gnu_counting_struct::count == n) -gnu_counting_struct::size_type gnu_counting_struct::count = 0; + +class gnu_copy_tracker +{ + public: + // Cannot be explicit. Conversion ctor used by list_modifiers.cc's + // test03(), "range fill at beginning". + gnu_copy_tracker (int anId, bool throwOnDemand = false) + : itsId(anId), willThrow(throwOnDemand) + {} + + gnu_copy_tracker (const gnu_copy_tracker& rhs) + : itsId(rhs.id()), willThrow(rhs.willThrow) + { + ++itsCopyCount; + if (willThrow) throw "copy tracker exception"; + } + + gnu_copy_tracker& operator=(const gnu_copy_tracker& rhs) + { + itsId = rhs.id(); + // willThrow must obviously already be false to get this far + } + + ~gnu_copy_tracker() { ++itsDtorCount; } + + int + id() const + { return itsId; } + + private: + int itsId; + const bool willThrow; + + public: + static void + reset() + { itsCopyCount = 0; itsDtorCount = 0; } + + static int + copyCount() + { return itsCopyCount; } + + static int + dtorCount() + { return itsDtorCount; } + + private: + static int itsCopyCount; + static int itsDtorCount; +}; #endif // _GLIBCPP_TESTSUITE_HOOKS_H -- 2.11.4.GIT