Commit 8d59b230 by Benjamin Kosnik Committed by Benjamin Kosnik

Renames, namespaces for testsuite utilities.


2003-01-12  Benjamin Kosnik  <bkoz@redhat.com>

	Renames, namespaces for testsuite utilities.
	* testsuite/testsuite_hooks.h: Put into namespace __gnu_cxx_test.
	(gnu_allocator_tracker): Rename to allocation_tracker.
	(gnu_new_allocator): Rename to tracker_alloc.
	(__set_testsuite_memlimit): Rename to set_memory_limits.
	(gnu_assignment_operator): Rename to assignment_operator.
	(gnu_destructor): Rename to destructor.
	(gnu_copy_tracker): Rename to copy_tracker.
	(gnu_char, gnu_int, gnu_long): Rename to pod_char, pod_int, pod_long.
	(run_tests_wrapped_locale): New.
	(run_tests_wrapped_env): New.
	* testsuite/testsuite_hooks.cc: Same.
	(class locale_data): Add.
	(class enviornment_variable): Add.
	(class not_found): Add.
	* testsuite/testsuite_allocator.h: Same.
	* testsuite/testsuite_allocator.cc: Same.
	* testsuite/23_containers/deque_ctor.cc
	(test_copy_ctor_exception_safety): Change gnu_allocator_tracker to
	allocation_tracker.
	Change gnu_new_allocator to tracker_alloc.
	Change gnu_counting_struct to counter.
	Change gnu_copy_tracker to copy_tracker.
	Change gnu_copy_constructor to copy_constructor.
	Change gnu_assignment_operator to assignment_operator.
	Inject.
	* testsuite/23_containers/vector_capacity.cc: Same.
	* testsuite/23_containers/vector_ctor.cc (test01): Same.
	* testsuite/23_containers/list_modifiers.cc: Change
	gnu_copy_tracker to copy_tracker.
	* testsuite/21_strings/ctor_copy_dtor.cc (main): Change
	__set_testsuite_memlimit to set_memory_limits.
	* testsuite/21_strings/insert.cc (main): Same.
	* testsuite/27_io/filebuf.cc: Change gnu_char to pod_char.
	* testsuite/27_io/stringstream.cc: Same.
	* testsuite/27_io/stringbuf.cc: Same.
	* testsuite/27_io/streambuf.cc: Same.
	* testsuite/27_io/ostream.cc: Same.
	* testsuite/27_io/istream.cc: Same.
	* testsuite/27_io/fstream.cc: Same.
	* testsuite/lib/libstdc++-v3-dg.exp
	(libstdc++-v3-list-sourcefiles): Additionally handle files two and
	three levels deeper in glob patterns.

From-SVN: r61261
parent fd371a93
2003-01-12 Benjamin Kosnik <bkoz@redhat.com>
Renames, namespaces for testsuite utilities.
* testsuite/testsuite_hooks.h: Put into namespace __gnu_cxx_test.
(gnu_allocator_tracker): Rename to allocation_tracker.
(gnu_new_allocator): Rename to tracker_alloc.
(__set_testsuite_memlimit): Rename to set_memory_limits.
(gnu_assignment_operator): Rename to assignment_operator.
(gnu_destructor): Rename to destructor.
(gnu_copy_tracker): Rename to copy_tracker.
(gnu_char, gnu_int, gnu_long): Rename to pod_char, pod_int, pod_long.
(run_tests_wrapped_locale): New.
(run_tests_wrapped_env): New.
* testsuite/testsuite_hooks.cc: Same.
(class locale_data): Add.
(class enviornment_variable): Add.
(class not_found): Add.
* testsuite/testsuite_allocator.h: Same.
* testsuite/testsuite_allocator.cc: Same.
* testsuite/23_containers/deque_ctor.cc
(test_copy_ctor_exception_safety): Change gnu_allocator_tracker to
allocation_tracker.
Change gnu_new_allocator to tracker_alloc.
Change gnu_counting_struct to counter.
Change gnu_copy_tracker to copy_tracker.
Change gnu_copy_constructor to copy_constructor.
Change gnu_assignment_operator to assignment_operator.
Inject.
* testsuite/23_containers/vector_capacity.cc: Same.
* testsuite/23_containers/vector_ctor.cc (test01): Same.
* testsuite/23_containers/list_modifiers.cc: Change
gnu_copy_tracker to copy_tracker.
* testsuite/21_strings/ctor_copy_dtor.cc (main): Change
__set_testsuite_memlimit to set_memory_limits.
* testsuite/21_strings/insert.cc (main): Same.
* testsuite/27_io/filebuf.cc: Change gnu_char to pod_char.
* testsuite/27_io/stringstream.cc: Same.
* testsuite/27_io/stringbuf.cc: Same.
* testsuite/27_io/streambuf.cc: Same.
* testsuite/27_io/ostream.cc: Same.
* testsuite/27_io/istream.cc: Same.
* testsuite/27_io/fstream.cc: Same.
* testsuite/lib/libstdc++-v3-dg.exp
(libstdc++-v3-list-sourcefiles): Additionally handle files two and
three levels deeper in glob patterns.
2003-01-11 Phil Edwards <pme@gcc.gnu.org>
* docs/doxygen/tables.html: Finished now.
......
// 1999-06-04 bkoz
// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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
......@@ -230,7 +230,7 @@ void test05()
int main()
{
__set_testsuite_memlimit();
__gnu_cxx_test::set_memory_limits();
test01();
test02();
test03();
......
// 1999-06-03 bkoz
// Copyright (C) 1999 Free Software Foundation, Inc.
// Copyright (C) 1999, 2003 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
......@@ -246,7 +246,7 @@ int test02(void)
int main()
{
__set_testsuite_memlimit();
__gnu_cxx_test::set_memory_limits();
test01();
test02();
return 0;
......
// 2001-12-27 pme
//
// Copyright (C) 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 2001, 2002, 2003 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
......@@ -26,7 +26,15 @@
#include <testsuite_allocator.h>
#include <testsuite_hooks.h>
typedef std::deque<gnu_counting_struct> gdeque;
using __gnu_cxx_test::copy_tracker;
using __gnu_cxx_test::allocation_tracker;
using __gnu_cxx_test::tracker_alloc;
using __gnu_cxx_test::copy_constructor;
using __gnu_cxx_test::assignment_operator;
using __gnu_cxx_test::counter;
using __gnu_cxx_test::destructor;
typedef std::deque<counter> gdeque;
bool test = true;
......@@ -133,10 +141,10 @@ void
defaultConstructorCheck()
{
// setup
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
gnu_copy_tracker::reset();
copy_tracker::reset();
// run test
const X u;
......@@ -171,7 +179,7 @@ void
copyConstructorCheck()
{
// setup
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const int copyBaseSize = 17; // arbitrary
......@@ -179,7 +187,7 @@ copyConstructorCheck()
X a;
for (int i = 0; i < copyBaseSize; ++i)
a.push_back(i);
gnu_copy_tracker::reset();
copy_tracker::reset();
// assert preconditions
VERIFY(!a.empty());
......@@ -192,7 +200,7 @@ copyConstructorCheck()
// assert postconditions
VERIFY(u == a);
VERIFY(copyBaseSize == gnu_copy_constructor::count());
VERIFY(copyBaseSize == copy_constructor::count());
// teardown
}
......@@ -212,20 +220,20 @@ void
fillConstructorCheck()
{
// setup
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const X::size_type n(23);
const X::value_type t(111);
gnu_copy_tracker::reset();
copy_tracker::reset();
// run test
X a(n, t);
// assert postconditions
VERIFY(n == a.size());
VERIFY(n == gnu_copy_constructor::count());
VERIFY(n == copy_constructor::count());
// teardown
}
......@@ -239,18 +247,18 @@ fillConstructorCheck()
void
fillConstructorCheck2()
{
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const int f = 23;
const int l = 111;
gnu_copy_tracker::reset();
copy_tracker::reset();
X a(f, l);
VERIFY(f == a.size());
VERIFY(f == gnu_copy_constructor::count());
VERIFY(f == copy_constructor::count());
}
......@@ -265,7 +273,7 @@ void
rangeConstructorCheckForwardIterator()
{
// setup
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const X::size_type n(726);
......@@ -275,14 +283,14 @@ rangeConstructorCheckForwardIterator()
X::iterator j = source.end();
X::size_type rangeSize = std::distance(i, j);
gnu_copy_tracker::reset();
copy_tracker::reset();
// test
X a(i, j);
// assert postconditions
VERIFY(rangeSize == a.size());
VERIFY(gnu_copy_constructor::count() <= rangeSize);
VERIFY(copy_constructor::count() <= rangeSize);
}
......@@ -295,7 +303,7 @@ rangeConstructorCheckForwardIterator()
void
rangeConstructorCheckInputIterator()
{
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
std::istringstream ibuf("1234567890123456789");
......@@ -303,12 +311,12 @@ rangeConstructorCheckInputIterator()
std::istream_iterator<char> i(ibuf);
std::istream_iterator<char> j;
gnu_copy_tracker::reset();
copy_tracker::reset();
X a(i, j);
VERIFY(rangeSize == a.size());
VERIFY(gnu_copy_constructor::count() <= (2 * rangeSize));
VERIFY(copy_constructor::count() <= (2 * rangeSize));
}
......@@ -316,7 +324,7 @@ rangeConstructorCheckInputIterator()
void
copyAssignmentCheck()
{
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const X::size_type n(18);
......@@ -324,12 +332,12 @@ copyAssignmentCheck()
X a(n, t);
X r;
gnu_copy_tracker::reset();
copy_tracker::reset();
r = a;
VERIFY(r == a);
VERIFY(n == gnu_copy_constructor::count());
VERIFY(n == copy_constructor::count());
}
......@@ -343,7 +351,7 @@ copyAssignmentCheck()
void
fillAssignmentCheck()
{
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const X::size_type starting_size(10);
......@@ -352,7 +360,7 @@ fillAssignmentCheck()
const X::value_type t(111);
X a(starting_size, starting_value);
gnu_copy_tracker::reset();
copy_tracker::reset();
// preconditions
VERIFY(starting_size == a.size());
......@@ -362,8 +370,8 @@ fillAssignmentCheck()
// postconditions
VERIFY(n == a.size());
VERIFY(n == (gnu_copy_constructor::count() + gnu_assignment_operator::count()));
VERIFY(starting_size == (gnu_destructor::count() + gnu_assignment_operator::count()));
VERIFY(n == (copy_constructor::count() + assignment_operator::count()));
VERIFY(starting_size == (destructor::count() + assignment_operator::count()));
}
......@@ -391,7 +399,7 @@ fillAssignmentCheck()
void
rangeAssignmentCheck()
{
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
const X::size_type source_size(726);
......@@ -407,13 +415,13 @@ rangeAssignmentCheck()
X a(starting_size, starting_value);
VERIFY(starting_size == a.size());
gnu_copy_tracker::reset();
copy_tracker::reset();
a.assign(i, j);
VERIFY(source == a);
VERIFY(rangeSize == (gnu_copy_constructor::count() + gnu_assignment_operator::count()));
VERIFY(starting_size == (gnu_destructor::count() + gnu_assignment_operator::count()));
VERIFY(rangeSize == (copy_constructor::count() + assignment_operator::count()));
VERIFY(starting_size == (destructor::count() + assignment_operator::count()));
}
......@@ -423,7 +431,7 @@ void
rangeAssignmentCheckWithException()
{
// setup
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
// test
......@@ -436,7 +444,7 @@ void
fillAssignmentCheck2()
{
// setup
typedef gnu_copy_tracker T;
typedef copy_tracker T;
typedef std::deque<T> X;
// test
......@@ -449,12 +457,12 @@ void
test_default_ctor_exception_safety()
{
// setup
typedef gnu_copy_tracker T;
typedef std::deque<T, gnu_new_allocator<T> > X;
typedef copy_tracker T;
typedef std::deque<T, tracker_alloc<T> > X;
T::reset();
gnu_copy_constructor::throw_on(3);
gnu_allocator_tracker::resetCounts();
copy_constructor::throw_on(3);
allocation_tracker::resetCounts();
// test
try
......@@ -467,7 +475,7 @@ test_default_ctor_exception_safety()
}
// assert postconditions
VERIFY(gnu_allocator_tracker::allocationTotal() == gnu_allocator_tracker::deallocationTotal());
VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal());
// teardown
}
......@@ -477,14 +485,14 @@ void
test_copy_ctor_exception_safety()
{
// setup
typedef gnu_copy_tracker T;
typedef std::deque<T, gnu_new_allocator<T> > X;
typedef copy_tracker T;
typedef std::deque<T, tracker_alloc<T> > X;
gnu_allocator_tracker::resetCounts();
allocation_tracker::resetCounts();
{
X a(7);
T::reset();
gnu_copy_constructor::throw_on(3);
copy_constructor::throw_on(3);
// test
......@@ -499,7 +507,7 @@ test_copy_ctor_exception_safety()
}
// assert postconditions
VERIFY(gnu_allocator_tracker::allocationTotal() == gnu_allocator_tracker::deallocationTotal());
VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal());
// teardown
}
......
// Copyright (C) 2001 Free Software Foundation, Inc.
// Copyright (C) 2001, 2003 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
......@@ -21,7 +21,7 @@
#include <list>
#include <testsuite_hooks.h>
typedef gnu_copy_tracker T;
typedef __gnu_cxx_test::copy_tracker T;
bool test = true;
......
// 1999-05-07
// bkoz
// Copyright (C) 1999, 2002 Free Software Foundation, Inc.
// Copyright (C) 1999, 2002, 2003 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
......@@ -26,6 +26,13 @@
#include <testsuite_allocator.h>
#include <testsuite_hooks.h>
using __gnu_cxx_test::copy_tracker;
using __gnu_cxx_test::allocation_tracker;
using __gnu_cxx_test::tracker_alloc;
using __gnu_cxx_test::copy_constructor;
using __gnu_cxx_test::assignment_operator;
using __gnu_cxx_test::destructor;
template<typename T>
struct A { };
......@@ -58,7 +65,6 @@ void test01()
void test02()
{
bool test = true;
{
std::vector<int> array;
const std::size_t size = array.max_size();
......@@ -104,10 +110,11 @@ void test02()
void
test_reserve()
{
typedef gnu_copy_tracker T;
typedef std::vector<T, gnu_new_allocator<T> > X;
bool test = true;
typedef copy_tracker T;
typedef std::vector<T, tracker_alloc<T> > X;
gnu_allocator_tracker::resetCounts();
allocation_tracker::resetCounts();
{
X a(3);
const X::size_type old_size = a.size();
......@@ -121,11 +128,11 @@ test_reserve()
VERIFY(new_capacity <= a.capacity());
// [23.2.4.1 (3)]
VERIFY(old_size == a.size());
VERIFY(gnu_copy_constructor::count() <= old_size);
VERIFY(gnu_destructor::count() <= old_size);
VERIFY(copy_constructor::count() <= old_size);
VERIFY(destructor::count() <= old_size);
}
// check for memory leaks
VERIFY(gnu_allocator_tracker::allocationTotal() == gnu_allocator_tracker::deallocationTotal());
VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal());
}
// Verifies that reserve() with reallocation offers the strong
......@@ -133,17 +140,18 @@ test_reserve()
void
test_reserve_exception_guarantee()
{
typedef gnu_copy_tracker T;
typedef std::vector<T, gnu_new_allocator<T> > X;
bool test = true;
typedef copy_tracker T;
typedef std::vector<T, tracker_alloc<T> > X;
gnu_allocator_tracker::resetCounts();
allocation_tracker::resetCounts();
{
X a(7);
const X::size_type old_size = a.size();
const X::size_type old_capacity = a.capacity();
const X::size_type new_capacity = old_capacity + 10;
T::reset();
gnu_copy_constructor::throw_on(3);
copy_constructor::throw_on(3);
try
{
......@@ -155,9 +163,9 @@ test_reserve_exception_guarantee()
}
VERIFY(old_capacity == a.capacity());
VERIFY(gnu_copy_constructor::count() == gnu_destructor::count()+1);
VERIFY(copy_constructor::count() == destructor::count()+1);
}
VERIFY(gnu_allocator_tracker::allocationTotal() == gnu_allocator_tracker::deallocationTotal());
VERIFY(allocation_tracker::allocationTotal() == allocation_tracker::deallocationTotal());
}
int main()
......
// 1999-01-17 bkoz test functionality of basic_filebuf for char_type == char
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002
// Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003
// Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library. This library is free
......@@ -45,9 +45,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_filebuf<type_t, char_traits<type_t> >;
template class basic_filebuf<gnu_char, char_traits<gnu_char> >;
template class basic_filebuf<pod_char, char_traits<pod_char> >;
} // test
......
// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -50,9 +50,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_fstream<type_t, char_traits<type_t> >;
template class basic_fstream<gnu_char, char_traits<gnu_char> >;
template class basic_fstream<pod_char, char_traits<pod_char> >;
} // test
int main()
......
// 1999-09-20 bkoz
// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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
......@@ -50,9 +50,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_istream<type_t, char_traits<type_t> >;
template class basic_istream<gnu_char, char_traits<gnu_char> >;
template class basic_istream<pod_char, char_traits<pod_char> >;
} // test
int main()
......
// 1999-09-20 bkoz
// Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
// Copyright (C) 1999, 2000, 2001, 2002, 2003 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
......@@ -50,9 +50,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_ostream<type_t, char_traits<type_t> >;
template class basic_ostream<gnu_char, char_traits<gnu_char> >;
template class basic_ostream<pod_char, char_traits<pod_char> >;
} // test
int main()
......
// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -50,9 +50,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_streambuf<type_t, char_traits<type_t> >;
template class basic_streambuf<gnu_char, char_traits<gnu_char> >;
template class basic_streambuf<pod_char, char_traits<pod_char> >;
} // test
int main()
......
// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -50,9 +50,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_stringbuf<type_t, char_traits<type_t> >;
template class basic_stringbuf<gnu_char, char_traits<gnu_char> >;
template class basic_stringbuf<pod_char, char_traits<pod_char> >;
} // test
int main()
......
// 2002-07-25 Benjamin Kosnik <bkoz@redhat.com>
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -50,9 +50,10 @@ void test01()
namespace test
{
using namespace std;
using __gnu_cxx_test::pod_char;
typedef short type_t;
template class basic_stringstream<type_t, char_traits<type_t> >;
template class basic_stringstream<gnu_char, char_traits<gnu_char> >;
template class basic_stringstream<pod_char, char_traits<pod_char> >;
} // test
int main()
......
......@@ -233,7 +233,7 @@ proc libstdc++-v3-list-sourcefiles { } {
set f [open $files_file "w"]
set where_we_were [pwd]
cd $srcdir
foreach s [lsort [glob -nocomplain "{,*/}*/*.cc"]] {
foreach s [lsort [glob -nocomplain "*/*.cc" "*/*/*.cc" "{,*/}*/*/*/*.cc" ]] {
lappend sfiles ${srcdir}/${s}
puts $f $s
}
......
// -*- C++ -*-
// Testing allocator for the C++ library testsuite.
//
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -28,8 +30,11 @@
#include <testsuite_allocator.h>
gnu_allocator_tracker::size_type gnu_allocator_tracker::allocationTotal_ = 0;
gnu_allocator_tracker::size_type gnu_allocator_tracker::deallocationTotal_ = 0;
int gnu_allocator_tracker::constructCount_ = 0;
int gnu_allocator_tracker::destructCount_ = 0;
namespace __gnu_cxx_test
{
allocation_tracker::size_type allocation_tracker::allocationTotal_ = 0;
allocation_tracker::size_type allocation_tracker::deallocationTotal_ = 0;
int allocation_tracker::constructCount_ = 0;
int allocation_tracker::destructCount_ = 0;
}; // namespace __cxx_test
// -*- C++ -*-
// Testing allocator for the C++ library testsuite.
//
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -37,71 +38,66 @@
#include <cstddef>
#include <limits>
class gnu_allocator_tracker
namespace __gnu_cxx_test
{
public:
typedef std::size_t size_type;
static void*
allocate(size_type blocksize)
class allocation_tracker
{
allocationTotal_ += blocksize;
return ::operator new(blocksize);
}
static void
construct()
{ constructCount_++; }
static void
destroy()
{ destructCount_++; }
static void
deallocate(void* p, size_type blocksize)
{
::operator delete(p);
deallocationTotal_ += blocksize;
}
static size_type
allocationTotal()
{ return allocationTotal_; }
public:
typedef std::size_t size_type;
static void*
allocate(size_type blocksize)
{
allocationTotal_ += blocksize;
return ::operator new(blocksize);
}
static void
construct() { constructCount_++; }
static size_type
deallocationTotal()
{ return deallocationTotal_; }
static void
destroy() { destructCount_++; }
static int
constructCount()
{ return constructCount_; }
static void
deallocate(void* p, size_type blocksize)
{
::operator delete(p);
deallocationTotal_ += blocksize;
}
static size_type
allocationTotal() { return allocationTotal_; }
static size_type
deallocationTotal() { return deallocationTotal_; }
static int
constructCount() { return constructCount_; }
static int
destructCount()
{ return destructCount_; }
static int
destructCount() { return destructCount_; }
static void
resetCounts()
{
allocationTotal_ = 0;
deallocationTotal_ = 0;
constructCount_ = 0;
static void
resetCounts()
{
allocationTotal_ = 0;
deallocationTotal_ = 0;
constructCount_ = 0;
destructCount_ = 0;
}
}
private:
static size_type allocationTotal_;
static size_type deallocationTotal_;
static int constructCount_;
static int destructCount_;
};
// A simple basic allocator that just forwards to the
// gnu_allocator_tracker to fulfill memory requests. This class is
// templated on the target object type, but gnu_allocator_tracker
// isn't.
template<class T>
class gnu_new_allocator
static size_type allocationTotal_;
static size_type deallocationTotal_;
static int constructCount_;
static int destructCount_;
};
// A simple basic allocator that just forwards to the
// allocation_tracker to fulfill memory requests. This class is
// templated on the target object type, but tracker isn't.
template<class T>
class tracker_alloc
{
public:
typedef T value_type;
......@@ -112,7 +108,7 @@ template<class T>
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template<class U> struct rebind { typedef gnu_new_allocator<U> other; };
template<class U> struct rebind { typedef tracker_alloc<U> other; };
pointer
address(reference value) const
......@@ -122,17 +118,17 @@ template<class T>
address(const_reference value) const
{ return &value; }
gnu_new_allocator() throw()
tracker_alloc() throw()
{ }
gnu_new_allocator(const gnu_new_allocator&) throw()
tracker_alloc(const tracker_alloc&) throw()
{ }
template<class U>
gnu_new_allocator(const gnu_new_allocator<U>&) throw()
tracker_alloc(const tracker_alloc<U>&) throw()
{ }
~gnu_new_allocator() throw()
~tracker_alloc() throw()
{ }
size_type
......@@ -140,42 +136,40 @@ template<class T>
{ return std::numeric_limits<std::size_t>::max() / sizeof(T); }
pointer
allocate(size_type num, const void* = 0)
allocate(size_type n, const void* = 0)
{
return static_cast<pointer>(gnu_allocator_tracker::allocate(num *
sizeof(T)));
return static_cast<pointer>(allocation_tracker::allocate(n * sizeof(T)));
}
void
construct(pointer p, const T& value)
{
new (p) T(value);
gnu_allocator_tracker::construct();
allocation_tracker::construct();
}
void
destroy(pointer p)
{
p->~T();
gnu_allocator_tracker::destroy();
allocation_tracker::destroy();
}
void
deallocate(pointer p, size_type num)
{ gnu_allocator_tracker::deallocate(p, num * sizeof(T)); }
{ allocation_tracker::deallocate(p, num * sizeof(T)); }
};
template<class T1, class T2>
bool
operator==(const gnu_new_allocator<T1>&,
const gnu_new_allocator<T2>&) throw()
{ return true; }
template<class T1, class T2>
bool
operator!=(const gnu_new_allocator<T1>&,
const gnu_new_allocator<T2>&) throw()
{ return false; }
template<class T1, class T2>
bool
operator==(const tracker_alloc<T1>&, const tracker_alloc<T2>&) throw()
{ return true; }
template<class T1, class T2>
bool
operator!=(const tracker_alloc<T1>&, const tracker_alloc<T2>&) throw()
{ return false; }
}; // namespace __gnu_cxx_test
#endif // _GLIBCPP_TESTSUITE_ALLOCATOR_H
// Utility subroutines for the C++ library testsuite.
// -*- C++ -*-
// Utility subroutines for the C++ library testsuite.
//
// Copyright (C) 2002 Free Software Foundation, Inc.
// Copyright (C) 2002, 2003 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
......@@ -33,14 +34,22 @@
#include <unistd.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif
#include <list>
#include <string>
#include <stdexcept>
#include <clocale>
#include <locale>
void
__set_testsuite_memlimit(float __size)
namespace __gnu_cxx_test
{
#ifdef _GLIBCPP_MEM_LIMITS
void
set_memory_limits(float size)
{
struct rlimit r;
// Cater to the absence of rlim_t.
__typeof__ (r.rlim_cur) limit
= (__typeof__ (r.rlim_cur))(__size * 1048576);
__typeof__ (r.rlim_cur) limit = (__typeof__ (r.rlim_cur))(size * 1048576);
// Heap size, seems to be common.
#if _GLIBCPP_HAVE_MEMLIMIT_DATA
......@@ -69,19 +78,90 @@ __set_testsuite_memlimit(float __size)
r.rlim_cur = limit;
setrlimit(RLIMIT_AS, &r);
#endif
}
}
#else
void
__set_testsuite_memlimit(float) { }
#endif /* _GLIBCPP_MEM_LIMITS */
void
set_memory_limits(float) { }
#endif
// Useful exceptions.
class locale_data : public std::runtime_error
{
public:
explicit
locale_data(const std::string& __arg) : runtime_error(__arg) { }
};
class environment_variable: public std::runtime_error
{
public:
explicit
environment_variable(const std::string& __arg) : runtime_error(__arg) { }
};
gnu_counting_struct::size_type gnu_counting_struct::count = 0;
class not_found : public std::runtime_error
{
public:
explicit
not_found(const std::string& __arg) : runtime_error(__arg) { }
};
unsigned int gnu_copy_constructor::count_ = 0;
unsigned int gnu_copy_constructor::throw_on_ = 0;
unsigned int gnu_assignment_operator::count_ = 0;
unsigned int gnu_assignment_operator::throw_on_ = 0;
unsigned int gnu_destructor::count_ = 0;
int gnu_copy_tracker::next_id_ = 0;
void
run_tests_wrapped_locale(const char* name, const func_callback& l)
{
using namespace std;
bool test = true;
// Set the global locale.
locale loc_name(name);
locale orig = locale::global(loc_name);
const char* res = setlocale(LC_ALL, name);
if (res != NULL)
{
string preLC_ALL = res;
for (func_callback::const_iterator i = l.begin(); i != l.end(); ++i)
(*i)();
string postLC_ALL= setlocale(LC_ALL, NULL);
VERIFY( preLC_ALL == postLC_ALL );
}
else
throw environment_variable(string("LC_ALL for") + string(name));
}
void
run_tests_wrapped_env(const char* name, const char* env,
const func_callback& l)
{
using namespace std;
bool test = true;
#ifdef _GLIBCPP_HAVE_SETENV
// Set the global locale.
locale loc_name(name);
locale orig = locale::global(loc_name);
// Set environment variable env to value in name.
const char* oldENV = getenv(env);
if (!setenv(env, name, 1))
{
for (func_callback::const_iterator i = l.begin(); i != l.end(); ++i)
(*i)();
setenv(env, oldENV ? oldENV : "", 1);
}
else
throw environment_variable(string(env) + string(" to ") + string(name));
#else
throw not_found("setenv");
#endif
}
counter::size_type counter::count = 0;
unsigned int copy_constructor::count_ = 0;
unsigned int copy_constructor::throw_on_ = 0;
unsigned int assignment_operator::count_ = 0;
unsigned int assignment_operator::throw_on_ = 0;
unsigned int destructor::_M_count = 0;
int copy_tracker::next_id_ = 0;
}; // namespace __cxx_test
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