Commit 8ea08b7d by Phil Edwards

Makefile.am (noinst_LIBRARIES): New target.

2002-05-28  Phil Edwards  <pme@gcc.gnu.org>

	* 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
parent 64de6c0a
2002-05-28 Phil Edwards <pme@gcc.gnu.org>
* 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 <bkoz@redhat.com>
* src/misc-inst.cc: Define unnecessary algorithm
......
......@@ -21,59 +21,9 @@
#include <list>
#include <testsuite_hooks.h>
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();
......
## 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
......@@ -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]
}
......
// Utility subroutines for the C++ library testsuite.
//
// 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
// 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.
#include <testsuite_hooks.h>
#ifdef _GLIBCPP_MEM_LIMITS
#include <sys/resource.h>
#include <unistd.h>
void
__set_testsuite_memlimit(float __size)
{
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
}
#endif /* _GLIBCPP_MEM_LIMITS */
gnu_counting_struct::size_type gnu_counting_struct::count = 0;
int gnu_copy_tracker::itsCopyCount = 0;
int gnu_copy_tracker::itsDtorCount = 0;
......@@ -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 <stephen@bregmasoft.com>.
// 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 <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;
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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment