OSDN Git Service

* testsuite/thread/pthread1.cc: New test.
[pf3gnuchains/gcc-fork.git] / libstdc++-v3 / testsuite / testsuite_hooks.h
index b7e96cb..08d93d3 100644 (file)
@@ -1,6 +1,6 @@
 // Utility subroutines for the C++ library testsuite.
 //
-// Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+// Copyright (C) 2000, 2001, 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
 //   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.
+//   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
@@ -99,5 +105,23 @@ __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.
+    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