test.xml revision 1.3
1<section xmlns="http://docbook.org/ns/docbook" version="5.0" 
2	 xml:id="manual.intro.setup.test" xreflabel="Testing">
3<?dbhtml filename="test.html"?>
4
5<info><title>Test</title>
6  <keywordset>
7    <keyword>ISO C++</keyword>
8    <keyword>test</keyword>
9    <keyword>testsuite</keyword>
10    <keyword>performance</keyword>
11    <keyword>conformance</keyword>
12    <keyword>ABI</keyword>
13    <keyword>exception safety</keyword>
14  </keywordset>
15</info>
16
17<para>
18The libstdc++ testsuite includes testing for standard conformance,
19regressions, ABI, and performance.
20</para>
21
22<section xml:id="test.organization" xreflabel="Test Organization"><info><title>Organization</title></info>
23
24
25<section xml:id="test.organization.layout" xreflabel="Directory Layout"><info><title>Directory Layout</title></info>
26
27
28<para>
29  The directory <emphasis>libsrcdir/testsuite</emphasis> contains the
30  individual test cases organized in sub-directories corresponding to
31  chapters of the C++ standard (detailed below), the dejagnu test
32  harness support files, and sources to various testsuite utilities
33  that are packaged in a separate testing library.
34</para>
35
36<para>
37  All test cases for functionality required by the runtime components
38  of the C++ standard (ISO 14882) are files within the following
39  directories.
40</para>
41
42   <programlisting>
4317_intro
4418_support
4519_diagnostics
4620_util
4721_strings
4822_locale
4923_containers
5025_algorithms
5126_numerics
5227_io
5328_regex
5429_atomics
5530_threads
56   </programlisting>
57
58   <para>
59      In addition, the following directories include test files:
60   </para>
61
62   <programlisting>
63tr1		  Tests for components as described by the Technical Report on Standard Library Extensions (TR1).
64backward	  Tests for backwards compatibility and deprecated features.
65demangle	  Tests for __cxa_demangle, the IA 64 C++ ABI demangler
66ext		  Tests for extensions.
67performance	  Tests for performance analysis, and performance regressions.
68   </programlisting>
69
70   <para>
71      Some directories don't have test files, but instead contain
72      auxiliary information:
73   </para>
74
75   <programlisting>
76config		  Files for the dejagnu test harness.
77lib		  Files for the dejagnu test harness.
78libstdc++*     	  Files for the dejagnu test harness.
79data		  Sample text files for testing input and output.
80util		  Files for libtestc++, utilities and testing routines.
81   </programlisting>
82
83   <para>
84      Within a directory that includes test files, there may be
85      additional subdirectories, or files.  Originally, test cases
86      were appended to one file that represented a particular section
87      of the chapter under test, and was named accordingly. For
88      instance, to test items related to <code> 21.3.6.1 -
89      basic_string::find [lib.string::find]</code> in the standard,
90      the following was used:
91   </para>
92   <programlisting>
9321_strings/find.cc
94   </programlisting>
95   <para>
96      However, that practice soon became a liability as the test cases
97      became huge and unwieldy, and testing new or extended
98      functionality (like wide characters or named locales) became
99      frustrating, leading to aggressive pruning of test cases on some
100      platforms that covered up implementation errors. Now, the test
101      suite has a policy of one file, one test case, which solves the
102      above issues and gives finer grained results and more manageable
103      error debugging. As an example, the test case quoted above
104      becomes:
105   </para>
106   <programlisting>
10721_strings/basic_string/find/char/1.cc
10821_strings/basic_string/find/char/2.cc
10921_strings/basic_string/find/char/3.cc
11021_strings/basic_string/find/wchar_t/1.cc
11121_strings/basic_string/find/wchar_t/2.cc
11221_strings/basic_string/find/wchar_t/3.cc
113   </programlisting>
114
115   <para>
116      All new tests should be written with the policy of one test
117      case, one file in mind.
118   </para>
119</section>
120
121
122<section xml:id="test.organization.naming" xreflabel="Naming Conventions"><info><title>Naming Conventions</title></info>
123
124
125   <para>
126      In addition, there are some special names and suffixes that are
127      used within the testsuite to designate particular kinds of
128      tests.
129   </para>
130
131<itemizedlist>
132<listitem>
133  <para>
134   <emphasis>_xin.cc</emphasis>
135  </para>
136   <para>
137      This test case expects some kind of interactive input in order
138      to finish or pass. At the moment, the interactive tests are not
139      run by default. Instead, they are run by hand, like:
140   </para>
141      <programlisting>
142g++ 27_io/objects/char/3_xin.cc
143cat 27_io/objects/char/3_xin.in | a.out
144     </programlisting>
145</listitem>
146<listitem>
147   <para>
148     <emphasis>.in</emphasis>
149   </para>
150   <para>
151      This file contains the expected input for the corresponding <emphasis>
152      _xin.cc</emphasis> test case.
153   </para>
154</listitem>
155<listitem>
156  <para>
157   <emphasis>_neg.cc</emphasis>
158  </para>
159   <para>
160      This test case is expected to fail: it's a negative test. At the
161      moment, these are almost always compile time errors.
162   </para>
163</listitem>
164<listitem>
165  <para>
166   <emphasis>char</emphasis>
167  </para>
168   <para>
169      This can either be a directory name or part of a longer file
170      name, and indicates that this file, or the files within this
171      directory are testing the <code>char</code> instantiation of a
172      template.
173   </para>
174</listitem>
175<listitem>
176  <para>
177   <emphasis>wchar_t</emphasis>
178  </para>
179   <para>
180      This can either be a directory name or part of a longer file
181      name, and indicates that this file, or the files within this
182      directory are testing the <code>wchar_t</code> instantiation of
183      a template. Some hosts do not support <code>wchar_t</code>
184      functionality, so for these targets, all of these tests will not
185      be run.
186   </para>
187</listitem>
188<listitem>
189  <para>
190   <emphasis>thread</emphasis>
191  </para>
192   <para>
193      This can either be a directory name or part of a longer file
194      name, and indicates that this file, or the files within this
195      directory are testing situations where multiple threads are
196      being used.
197   </para>
198</listitem>
199<listitem>
200  <para>
201   <emphasis>performance</emphasis>
202  </para>
203   <para>
204      This can either be an enclosing directory name or part of a
205      specific file name. This indicates a test that is used to
206      analyze runtime performance, for performance regression testing,
207      or for other optimization related analysis. At the moment, these
208      test cases are not run by default.
209   </para>
210</listitem>
211</itemizedlist>
212
213</section>
214</section>
215
216
217<section xml:id="test.run" xreflabel="Running the Testsuite"><info><title>Running the Testsuite</title></info>
218
219
220  <section xml:id="test.run.basic"><info><title>Basic</title></info>
221    
222
223    <para>
224      You can check the status of the build without installing it
225      using the dejagnu harness, much like the rest of the gcc
226      tools.</para>
227   <programlisting> make check</programlisting>
228   <para>in the <emphasis>libbuilddir</emphasis> directory.</para>
229   <para>or</para>
230   <programlisting> make check-target-libstdc++-v3</programlisting>
231   <para>in the <emphasis>gccbuilddir</emphasis> directory.
232     </para>
233
234     <para>
235       These commands are functionally equivalent and will create a
236       'testsuite' directory underneath
237       <emphasis>libbuilddir</emphasis> containing the results of the
238       tests. Two results files will be generated: <emphasis>
239       libstdc++.sum</emphasis>, which is a PASS/FAIL summary for each
240       test, and <emphasis>libstdc++.log</emphasis> which is a log of
241       the exact command line passed to the compiler, the compiler
242       output, and the executable output (if any).
243     </para>
244
245     <para>
246       Archives of test results for various versions and platforms are
247       available on the GCC website in the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/gcc-4.3/buildstat.html">build
248       status</link> section of each individual release, and are also
249       archived on a daily basis on the <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/ml/gcc-testresults/current">gcc-testresults</link>
250       mailing list. Please check either of these places for a similar
251       combination of source version, operating system, and host CPU.
252     </para>
253  </section>
254
255  <section xml:id="test.run.variations"><info><title>Variations</title></info>
256    
257    <para>
258      There are several options for running tests, including testing
259      the regression tests, testing a subset of the regression tests,
260      testing the performance tests, testing just compilation, testing
261      installed tools, etc. In addition, there is a special rule for
262      checking the exported symbols of the shared library.
263    </para>
264    <para>
265      To debug the dejagnu test harness during runs, try invoking with a
266      specific argument to the variable RUNTESTFLAGS, as below.
267    </para>
268
269<programlisting>
270make check-target-libstdc++-v3 RUNTESTFLAGS="-v"
271</programlisting>
272
273    <para>
274      or
275    </para>
276
277<programlisting>
278make check-target-libstdc++-v3 RUNTESTFLAGS="-v -v"
279</programlisting>
280
281    <para>
282      To run a subset of the library tests, you will need to generate
283      the <emphasis>testsuite_files</emphasis> file by running
284      <command>make testsuite_files</command> in the
285      <emphasis>libbuilddir/testsuite</emphasis> directory, described
286      below.  Edit the file to remove the tests you don't want and
287      then run the testsuite as normal.
288    </para>
289
290    <para>
291      There are two ways to run on a simulator: set up DEJAGNU to point to a
292      specially crafted site.exp, or pass down --target_board flags.
293    </para>
294
295    <para>
296    Example flags to pass down for various embedded builds are as follows:
297    </para>
298
299<programlisting>
300      --target=powerpc-eabism (libgloss/sim)
301make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=powerpc-sim"
302
303--target=calmrisc32 (libgloss/sid)
304make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=calmrisc32-sid"
305
306--target=xscale-elf (newlib/sim)
307make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim"
308</programlisting>
309
310    <para>
311      Also, here is an example of how to run the libstdc++ testsuite
312      for a multilibed build directory with different ABI settings:
313    </para>
314
315 <programlisting>
316make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board \"unix{-mabi=32,,-mabi=64}\"'
317</programlisting>
318
319    <para>
320      You can run the tests with a compiler and library that have
321      already been installed.  Make sure that the compiler (e.g.,
322      <code>g++</code>) is in your <code>PATH</code>.  If you are
323      using shared libraries, then you must also ensure that the
324      directory containing the shared version of libstdc++ is in your
325      <code>LD_LIBRARY_PATH</code>, or equivalent.  If your GCC source
326      tree is at <code>/path/to/gcc</code>, then you can run the tests
327      as follows:
328    </para>
329
330<programlisting>
331runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
332</programlisting>
333
334    <para>
335      The testsuite will create a number of files in the directory in
336      which you run this command,.  Some of those files might use the
337      same name as files created by other testsuites (like the ones
338      for GCC and G++), so you should not try to run all the
339      testsuites in parallel from the same directory.
340    </para>
341
342    <para>
343      In addition, there are some testing options that are mostly of
344      interest to library maintainers and system integrators. As such,
345      these tests may not work on all cpu and host combinations, and
346      may need to be executed in the
347      <emphasis>libbuilddir/testsuite</emphasis> directory.  These
348      options include, but are not necessarily limited to, the
349      following:
350   </para>
351
352   <programlisting>
353   make testsuite_files
354   </programlisting>
355
356  <para>
357    Five files are generated that determine what test files
358    are run. These files are:
359  </para>
360
361   <itemizedlist>
362     <listitem>
363       <para>
364	 <emphasis>testsuite_files</emphasis>
365       </para>
366       <para>
367	 This is a list of all the test cases that will be run. Each
368	 test case is on a separate line, given with an absolute path
369	 from the <emphasis>libsrcdir/testsuite</emphasis> directory.
370       </para>
371     </listitem>
372
373     <listitem>
374       <para>
375	 <emphasis>testsuite_files_interactive</emphasis>
376       </para>
377       <para>
378	 This is a list of all the interactive test cases, using the
379	 same format as the file list above. These tests are not run
380	 by default.
381     </para>
382     </listitem>
383
384     <listitem>
385       <para>
386	 <emphasis>testsuite_files_performance</emphasis>
387       </para>
388       <para>
389	 This is a list of all the performance test cases, using the
390	 same format as the file list above. These tests are not run
391	 by default.
392     </para>
393     </listitem>
394
395     <listitem>
396       <para>
397	 <emphasis>testsuite_thread</emphasis>
398       </para>
399       <para>
400	 This file indicates that the host system can run tests which
401	 involved multiple threads.
402       </para>
403     </listitem>
404
405     <listitem>
406       <para>
407	 <emphasis>testsuite_wchar_t</emphasis>
408       </para>
409       <para>
410	 This file indicates that the host system can run the wchar_t
411	 tests, and corresponds to the macro definition <code>
412	 _GLIBCXX_USE_WCHAR_T</code> in the file c++config.h.
413       </para>
414     </listitem>
415    </itemizedlist>
416
417   <programlisting>
418   make check-abi
419   </programlisting>
420
421   <para>
422     The library ABI can be tested. This involves testing the shared
423     library against an ABI-defining previous version of symbol
424     exports.
425   </para>
426
427  <programlisting>
428   make check-compile
429  </programlisting>
430
431   <para>
432     This rule compiles, but does not link or execute, the
433     <emphasis>testsuite_files</emphasis> test cases and displays the
434     output on stdout.
435   </para>
436
437   <programlisting>
438   make check-performance
439   </programlisting>
440
441   <para>
442     This rule runs through the
443     <emphasis>testsuite_files_performance</emphasis> test cases and
444     collects information for performance analysis and can be used to
445     spot performance regressions. Various timing information is
446     collected, as well as number of hard page faults, and memory
447     used. This is not run by default, and the implementation is in
448     flux.
449   </para>
450
451   <para>
452      We are interested in any strange failures of the testsuite;
453      please email the main libstdc++ mailing list if you see
454      something odd or have questions.
455   </para>
456  </section>
457
458  <section xml:id="test.run.permutations"><info><title>Permutations</title></info>
459    
460    <para>
461      To run the libstdc++ test suite under the <link linkend="manual.ext.debug_mode">debug mode</link>, edit
462      <filename>libstdc++-v3/scripts/testsuite_flags</filename> to add the
463      compile-time flag <constant>-D_GLIBCXX_DEBUG</constant> to the
464      result printed by the <literal>--build-cxx</literal>
465      option. Additionally, add the
466      <constant>-D_GLIBCXX_DEBUG_PEDANTIC</constant> flag to turn on
467      pedantic checking. The libstdc++ test suite should produce
468      precisely the same results under debug mode that it does under
469      release mode: any deviation indicates an error in either the
470      library or the test suite.
471    </para>
472
473    <para>
474      The <link linkend="manual.ext.parallel_mode">parallel
475      mode</link> can be tested in much the same manner, substituting
476      <constant>-D_GLIBCXX_PARALLEL</constant> for
477      <constant>-D_GLIBCXX_DEBUG</constant> in the previous paragraph.
478    </para>
479
480    <para>
481      Or, just run the testsuites with <constant>CXXFLAGS</constant>
482      set to <constant>-D_GLIBCXX_DEBUG</constant> or
483      <constant>-D_GLIBCXX_PARALLEL</constant>.
484    </para>
485  </section>
486</section>
487
488<section xml:id="test.new_tests"><info><title>Writing a new test case</title></info>
489
490
491   <para>
492    The first step in making a new test case is to choose the correct
493    directory and file name, given the organization as previously
494    described.
495   </para>
496
497   <para>
498    All files are copyright the FSF, and GPL'd: this is very
499    important.  The first copyright year should correspond to the date
500    the file was checked in to SVN.
501   </para>
502
503   <para>
504     As per the dejagnu instructions, always return 0 from main to
505     indicate success.
506   </para>
507
508   <para>
509   A bunch of utility functions and classes have already been
510   abstracted out into the testsuite utility library, <code>
511   libtestc++</code>. To use this functionality, just include the
512   appropriate header file: the library or specific object files will
513   automatically be linked in as part of the testsuite run.
514   </para>
515
516   <para>
517   For a test that needs to take advantage of the dejagnu test
518   harness, what follows below is a list of special keyword that
519   harness uses. Basically, a test case contains dg-keywords (see
520   dg.exp) indicating what to do and what kinds of behavior are to be
521   expected.  New test cases should be written with the new style
522   DejaGnu framework in mind.
523   </para>
524
525   <para>
526    To ease transition, here is the list of dg-keyword documentation
527    lifted from dg.exp.
528   </para>
529
530<programlisting>
531# The currently supported options are:
532#
533# dg-prms-id N
534#	set prms_id to N
535#
536# dg-options "options ..." [{ target selector }]
537#	specify special options to pass to the tool (eg: compiler)
538#
539# dg-do do-what-keyword [{ target/xfail selector }]
540#	`do-what-keyword' is tool specific and is passed unchanged to
541#	${tool}-dg-test.  An example is gcc where `keyword' can be any of:
542#	preprocess|compile|assemble|link|run
543#	and will do one of: produce a .i, produce a .s, produce a .o,
544#	produce an a.out, or produce an a.out and run it (the default is
545#	compile).
546#
547# dg-error regexp comment [{ target/xfail selector } [{.|0|linenum}]]
548#	indicate an error message &lt;regexp&gt; is expected on this line
549#	(the test fails if it doesn't occur)
550#	Linenum=0 for general tool messages (eg: -V arg missing).
551#	"." means the current line.
552#
553# dg-warning regexp comment [{ target/xfail selector } [{.|0|linenum}]]
554#	indicate a warning message &lt;regexp&gt; is expected on this line
555#	(the test fails if it doesn't occur)
556#
557# dg-bogus regexp comment [{ target/xfail selector } [{.|0|linenum}]]
558#	indicate a bogus error message &lt;regexp&gt; use to occur here
559#	(the test fails if it does occur)
560#
561# dg-build regexp comment [{ target/xfail selector }]
562#	indicate the build use to fail for some reason
563#	(errors covered here include bad assembler generated, tool crashes,
564#	and link failures)
565#	(the test fails if it does occur)
566#
567# dg-excess-errors comment [{ target/xfail selector }]
568#	indicate excess errors are expected (any line)
569#	(this should only be used sparingly and temporarily)
570#
571# dg-output regexp [{ target selector }]
572#	indicate the expected output of the program is &lt;regexp&gt;
573#	(there may be multiple occurrences of this, they are concatenated)
574#
575# dg-final { tcl code }
576#	add some tcl code to be run at the end
577#	(there may be multiple occurrences of this, they are concatenated)
578#	(unbalanced braces must be \-escaped)
579#
580# "{ target selector }" is a list of expressions that determine whether the
581# test succeeds or fails for a particular target, or in some cases whether the
582# option applies for a particular target.  If the case of `dg-do' it specifies
583# whether the test case is even attempted on the specified target.
584#
585# The target selector is always optional.  The format is one of:
586#
587# { xfail *-*-* ... } - the test is expected to fail for the given targets
588# { target *-*-* ... } - the option only applies to the given targets
589#
590# At least one target must be specified, use *-*-* for "all targets".
591# At present it is not possible to specify both `xfail' and `target'.
592# "native" may be used in place of "*-*-*".
593
594Example 1: Testing compilation only
595// { dg-do compile }
596
597Example 2: Testing for expected warnings on line 36, which all targets fail
598// { dg-warning "string literals" "" { xfail *-*-* } 36 }
599
600Example 3: Testing for expected warnings on line 36
601// { dg-warning "string literals" "" { target *-*-* } 36 }
602
603Example 4: Testing for compilation errors on line 41
604// { dg-do compile }
605// { dg-error "no match for" "" { target *-*-* } 41 }
606
607Example 5: Testing with special command line settings, or without the
608use of pre-compiled headers, in particular the stdc++.h.gch file. Any
609options here will override the DEFAULT_CXXFLAGS and PCH_CXXFLAGS set
610up in the normal.exp file.
611// { dg-options "-O0" { target *-*-* } }
612</programlisting>
613
614   <para>
615    More examples can be found in the libstdc++-v3/testsuite/*/*.cc files.
616   </para>
617</section>
618
619
620<section xml:id="test.harness" xreflabel="Test Harness and Utilities"><info><title>Test Harness and Utilities</title></info>
621
622
623<section xml:id="test.harness.dejagnu"><info><title>Dejagnu Harness Details</title></info>
624
625  <para>
626    Underlying details of testing for conformance and regressions are
627    abstracted via the GNU Dejagnu package. This is similar to the
628    rest of GCC.
629  </para>
630
631
632<para>This is information for those looking at making changes to the testsuite
633structure, and/or needing to trace dejagnu's actions with --verbose.  This
634will not be useful to people who are "merely" adding new tests to the existing
635structure.
636</para>
637
638<para>The first key point when working with dejagnu is the idea of a "tool".
639Files, directories, and functions are all implicitly used when they are
640named after the tool in use.  Here, the tool will always be "libstdc++".
641</para>
642
643<para>The <code>lib</code> subdir contains support routines.  The
644<code>lib/libstdc++.exp</code> file ("support library") is loaded
645automagically, and must explicitly load the others.  For example, files can
646be copied from the core compiler's support directory into <code>lib</code>.
647</para>
648
649<para>Some routines in <code>lib/libstdc++.exp</code> are callbacks, some are
650our own.  Callbacks must be prefixed with the name of the tool.  To easily
651distinguish the others, by convention our own routines are named "v3-*".
652</para>
653
654<para>The next key point when working with dejagnu is "test files".  Any
655directory whose name starts with the tool name will be searched for test files.
656(We have only one.)  In those directories, any <code>.exp</code> file is
657considered a test file, and will be run in turn.  Our main test file is called
658<code>normal.exp</code>; it runs all the tests in testsuite_files using the
659callbacks loaded from the support library.
660</para>
661
662<para>The <code>config</code> directory is searched for any particular "target
663board" information unique to this library.  This is currently unused and sets
664only default variables.
665</para>
666
667</section>
668
669<section xml:id="test.harness.utils"><info><title>Utilities</title></info>
670
671  <para>
672  </para>
673  <para>
674   The testsuite directory also contains some files that implement
675   functionality that is intended to make writing test cases easier,
676   or to avoid duplication, or to provide error checking in a way that
677   is consistent across platforms and test harnesses. A stand-alone
678   executable, called <emphasis>abi_check</emphasis>, and a static
679   library called <emphasis>libtestc++</emphasis> are
680   constructed. Both of these items are not installed, and only used
681   during testing.
682  </para>
683
684  <para>
685  These files include the following functionality:
686  </para>
687
688  <itemizedlist>
689     <listitem>
690       <para>
691       <emphasis>testsuite_abi.h</emphasis>,
692       <emphasis>testsuite_abi.cc</emphasis>,
693       <emphasis>testsuite_abi_check.cc</emphasis>
694       </para>
695       <para>
696	Creates the executable <emphasis>abi_check</emphasis>.
697	Used to check correctness of symbol versioning, visibility of
698	exported symbols, and compatibility on symbols in the shared
699	library, for hosts that support this feature. More information
700	can be found in the ABI documentation <link linkend="appendix.porting.abi">here</link>
701       </para>
702     </listitem>
703     <listitem>
704       <para>
705       <emphasis>testsuite_allocator.h</emphasis>,
706       <emphasis>testsuite_allocator.cc</emphasis>
707       </para>
708       <para>
709	Contains specialized allocators that keep track of construction
710	and destruction. Also, support for overriding global new and
711	delete operators, including verification that new and delete
712	are called during execution, and that allocation over max_size
713	fails.
714       </para>
715     </listitem>
716     <listitem>
717       <para>
718       <emphasis>testsuite_character.h</emphasis>
719       </para>
720       <para>
721	Contains <code>std::char_traits</code> and
722	<code>std::codecvt</code> specializations for a user-defined
723	POD.
724       </para>
725     </listitem>
726     <listitem>
727       <para>
728       <emphasis>testsuite_hooks.h</emphasis>,
729       <emphasis>testsuite_hooks.cc</emphasis>
730       </para>
731       <para>
732       A large number of utilities, including:
733       </para>
734       <itemizedlist>
735	 <listitem><para>VERIFY</para></listitem>
736	 <listitem><para>set_memory_limits</para></listitem>
737	 <listitem><para>verify_demangle</para></listitem>
738	 <listitem><para>run_tests_wrapped_locale</para></listitem>
739	 <listitem><para>run_tests_wrapped_env</para></listitem>
740	 <listitem><para>try_named_locale</para></listitem>
741	 <listitem><para>try_mkfifo</para></listitem>
742	 <listitem><para>func_callback</para></listitem>
743	 <listitem><para>counter</para></listitem>
744	 <listitem><para>copy_tracker</para></listitem>
745	 <listitem><para>copy_constructor</para></listitem>
746	 <listitem><para>assignment_operator</para></listitem>
747	 <listitem><para>destructor</para></listitem>
748	 <listitem>
749	 <para>pod_char, pod_int and associated char_traits specializations</para>
750	 </listitem>
751       </itemizedlist>
752     </listitem>
753     <listitem>
754       <para>
755	 <emphasis>testsuite_io.h</emphasis>
756       </para>
757       <para>
758       Error, exception, and constraint checking for
759       <code>std::streambuf, std::basic_stringbuf, std::basic_filebuf</code>.
760       </para>
761     </listitem>
762     <listitem>
763       <para>
764	 <emphasis>testsuite_iterators.h</emphasis>
765       </para>
766       <para>
767	 Wrappers for various iterators.
768       </para>
769     </listitem>
770     <listitem>
771       <para>
772	 <emphasis>testsuite_performance.h</emphasis>
773       </para>
774       <para>
775       A number of class abstractions for performance counters, and
776       reporting functions including:
777       </para>
778      <itemizedlist>
779	 <listitem><para>time_counter</para></listitem>
780	 <listitem><para>resource_counter</para></listitem>
781	 <listitem><para>report_performance</para></listitem>
782      </itemizedlist>
783     </listitem>
784  </itemizedlist>
785</section>
786
787</section>
788
789<section xml:id="test.special"><info><title>Special Topics</title></info>
790
791
792<section xml:id="test.exception.safety"><info><title>
793  Qualifying Exception Safety Guarantees
794  <indexterm>
795    <primary>Test</primary>
796    <secondary>Exception Safety</secondary>
797  </indexterm>
798</title></info>
799
800
801<section xml:id="test.exception.safety.overview"><info><title>Overview</title></info>
802
803
804       <para>
805	 Testing is composed of running a particular test sequence,
806	 and looking at what happens to the surrounding code when
807	 exceptions are thrown. Each test is composed of measuring
808	 initial state, executing a particular sequence of code under
809	 some instrumented conditions, measuring a final state, and
810	 then examining the differences between the two states.
811       </para>
812
813       <para>
814	 Test sequences are composed of constructed code sequences
815	 that exercise a particular function or member function, and
816	 either confirm no exceptions were generated, or confirm the
817	 consistency/coherency of the test subject in the event of a
818	 thrown exception.
819       </para>
820
821       <para>
822	 Random code paths can be constructed using the basic test
823	 sequences and instrumentation as above, only combined in a
824	 random or pseudo-random way.
825       </para>
826
827       <para> To compute the code paths that throw, test instruments
828	 are used that throw on allocation events
829	 (<classname>__gnu_cxx::throw_allocator_random</classname>
830	 and <classname>__gnu_cxx::throw_allocator_limit</classname>)
831	 and copy, assignment, comparison, increment, swap, and
832	 various operators
833	 (<classname>__gnu_cxx::throw_type_random</classname>
834	 and <classname>__gnu_cxx::throw_type_limit</classname>). Looping
835	 through a given test sequence and conditionally throwing in
836	 all instrumented places.  Then, when the test sequence
837	 completes without an exception being thrown, assume all
838	 potential error paths have been exercised in a sequential
839	 manner.
840       </para>
841</section>
842
843
844<section xml:id="test.exception.safety.status"><info><title>
845    Existing tests
846</title></info>
847
848
849  <itemizedlist>
850     <listitem>
851       <para>
852	 Ad Hoc
853       </para>
854       <para>
855	 For example,
856	 <filename>testsuite/23_containers/list/modifiers/3.cc</filename>.
857       </para>
858     </listitem>
859
860     <listitem>
861       <para>
862	 Policy Based Data Structures
863       </para>
864       <para>
865	 For example, take the test
866	 functor <classname>rand_reg_test</classname> in
867	 in <filename>testsuite/ext/pb_ds/regression/tree_no_data_map_rand.cc</filename>. This uses <classname>container_rand_regression_test</classname> in
868<filename>testsuite/util/regression/rand/assoc/container_rand_regression_test.h</filename>.
869
870       </para>
871
872       <para>
873	 Which has several tests for container member functions,
874Includes control and test container objects. Configuration includes
875random seed, iterations, number of distinct values, and the
876probability that an exception will be thrown. Assumes instantiating
877container uses an extension
878allocator, <classname>__gnu_cxx::throw_allocator_random</classname>,
879as the allocator type.
880       </para>
881     </listitem>
882
883     <listitem>
884       <para>
885	 C++11 Container Requirements.
886       </para>
887
888       <para>
889	 Coverage is currently limited to testing container
890	 requirements for exception safety,
891	 although <classname>__gnu_cxx::throw_type</classname> meets
892	 the additional type requirements for testing numeric data
893	 structures and instantiating algorithms.
894       </para>
895
896       <para>
897	 Of particular interest is extending testing to algorithms and
898	 then to parallel algorithms. Also io and locales.
899       </para>
900
901       <para>
902	 The test instrumentation should also be extended to add
903	 instrumentation to <classname>iterator</classname>
904	 and <classname>const_iterator</classname> types that throw
905	 conditionally on iterator operations.
906       </para>
907     </listitem>
908  </itemizedlist>
909</section>
910
911
912<section xml:id="test.exception.safety.containers"><info><title>
913C++11 Requirements Test Sequence Descriptions
914</title></info>
915
916
917  <itemizedlist>
918     <listitem>
919       <para>
920	 Basic
921       </para>
922
923       <para>
924	 Basic consistency on exception propagation tests. For
925	 each container, an object of that container is constructed,
926	 a specific member function is exercised in
927	 a <literal>try</literal> block, and then any thrown
928	 exceptions lead to error checking in the appropriate
929	 <literal>catch</literal> block. The container's use of
930	 resources is compared to the container's use prior to the
931	 test block. Resource monitoring is limited to allocations
932	 made through the container's <type>allocator_type</type>,
933	 which should be sufficient for container data
934	 structures. Included in these tests are member functions
935	 are <type>iterator</type> and <type>const_iterator</type>
936	 operations, <function>pop_front</function>, <function>pop_back</function>, <function>push_front</function>, <function>push_back</function>, <function>insert</function>, <function>erase</function>, <function>swap</function>, <function>clear</function>,
937	 and <function>rehash</function>. The container in question is
938	 instantiated with two instrumented template arguments,
939	 with <classname>__gnu_cxx::throw_allocator_limit</classname>
940	 as the allocator type, and
941	 with <classname>__gnu_cxx::throw_type_limit</classname> as
942	 the value type. This allows the test to loop through
943	 conditional throw points.
944       </para>
945
946     <para>
947	 The general form is demonstrated in
948	 <filename>testsuite/23_containers/list/requirements/exception/basic.cc
949	 </filename>. The instantiating test object is <classname>__gnu_test::basic_safety</classname> and is detailed in <filename>testsuite/util/exception/safety.h</filename>.
950       </para>
951     </listitem>
952
953
954     <listitem>
955       <para>
956	 Generation Prohibited
957       </para>
958
959       <para>
960	 Exception generation tests. For each container, an object of
961	 that container is constructed and all member functions
962	 required to not throw exceptions are exercised. Included in
963	 these tests are member functions
964	 are <type>iterator</type> and <type>const_iterator</type> operations, <function>erase</function>, <function>pop_front</function>, <function>pop_back</function>, <function>swap</function>,
965	 and <function>clear</function>. The container in question is
966	 instantiated with two instrumented template arguments,
967	 with <classname>__gnu_cxx::throw_allocator_random</classname>
968	 as the allocator type, and
969	 with <classname>__gnu_cxx::throw_type_random</classname> as
970	 the value type. This test does not loop, an instead is sudden
971	 death: first error fails.
972       </para>
973       <para>
974	 The general form is demonstrated in
975	 <filename>testsuite/23_containers/list/requirements/exception/generation_prohibited.cc
976	 </filename>. The instantiating test object is <classname>__gnu_test::generation_prohibited</classname> and is detailed in <filename>testsuite/util/exception/safety.h</filename>.
977       </para>
978     </listitem>
979
980
981     <listitem>
982       <para>
983	 Propagation Consistent
984       </para>
985
986       <para>
987	 Container rollback on exception propagation tests. For
988	 each container, an object of that container is constructed,
989	 a specific member function that requires rollback to a previous
990	 known good state is exercised in
991	 a <literal>try</literal> block, and then any thrown
992	 exceptions lead to error checking in the appropriate
993	 <literal>catch</literal> block. The container is compared to
994	 the container's last known good state using such parameters
995	 as size, contents, and iterator references. Included in these
996	 tests are member functions
997	 are <function>push_front</function>, <function>push_back</function>, <function>insert</function>,
998	 and <function>rehash</function>. The container in question is
999	 instantiated with two instrumented template arguments,
1000	 with <classname>__gnu_cxx::throw_allocator_limit</classname>
1001	 as the allocator type, and
1002	 with <classname>__gnu_cxx::throw_type_limit</classname> as
1003	 the value type. This allows the test to loop through
1004	 conditional throw points.
1005       </para>
1006
1007       <para>
1008	 The general form demonstrated in
1009	 <filename>testsuite/23_containers/list/requirements/exception/propagation_coherent.cc
1010	 </filename>. The instantiating test object is <classname>__gnu_test::propagation_coherent</classname> and is detailed in <filename>testsuite/util/exception/safety.h</filename>.
1011       </para>
1012     </listitem>
1013  </itemizedlist>
1014
1015</section>
1016
1017</section>
1018
1019</section>
1020
1021</section>
1022