This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch] New libstdc++ docs on testing and library versioning


I've been working on some changes to the libstdc++ manual recently.

A lot of the changes are just using DocBook markup with more semantic
meaning (e.g. <option> or <filename> instead of using <code> for
everything that should use a monospace font) but there are some
changes to content too.

I've added a new subsection documenting the steps needed to bump the
library version when adding new symbols, and rewritten the section on
writing testcases. The main reason for the latter is to encourage the
use of { dg-do run { target c++11 } } rather than the { dg-options
"-std=gnu++11" } approach used until now. I've also started
documenting the libstdc++-specific dg-require-SUPPORT directives
available for our tests.

The core of the new guidelines for writing tests is this:

[begin]
 Test cases that use features of a particular C++ standard should
 specify the minimum required standard as an effective target:

   // { dg-do run { target c++11 } }

 or

   // { dg-require-effective-target c++11 }

 Specifying the minimum required standard for a test allows it to be
 run using later standards, so that we can verify that C++11
 components still work correctly when compiled as C++14 or later.
 Specifying a minimum also means the test will be skipped if the test
 is compiled using an older standard, e.g. using
RUNTESTFLAGS=--target_board=unix/-std=gnu++98.
 It is possible to indicate that a test should /only/ be run for a
 specific standard (and not later standards) using an effective
 target like c++11_only. However, this means the test will be skipped
 by default (because the default mode is gnu++14), and so will only
 run when -std=gnu++11 or -std=c++11 is used explicitly. For tests
 that require a specific standard it is better to use a dg-options
 directive:

   // { dg-options "-std=gnu++11" }

 This means the test will not get skipped by default, and will always
 use the specific standard dialect that the test requires. This isn't
 needed often, and most tests should use an effective target to
 specify a minimum standard instead, to allow them to be tested for
 all possible variations.

 Similarly, tests which depend on a newer standard than the default
 should use dg-options instead of an effective target, so that they
 are not skipped by default. For example, tests for C++17 features
 should use

   // { dg-options "-std=gnu++17" }

 and not

   // { dg-do run "c++1z" }
[end]


I'd like to get feedback on this proposed change to how we write
tests, and any comments on the other doc changes are also welcome.

To make it easier to read them I've uploaded the generated HTML pages
to http://kayari.org/tmp/test.html and
http://kayari.org/tmp/appendix_porting.html#build_hacking.configure.version

The current versions of those pages are
https://gcc.gnu.org/onlinedocs/libstdc++/manual/test.html and
https://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_porting.html


commit 2315b0e19ce83875b1d8076b6faee74d4fc8bdbe
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Thu Aug 4 22:08:42 2016 +0100

    Improve libstdc++ docs on testing and library versioning
    
    	* doc/xml/manual/build_hacking.xml: Improve markup.
    	(build_hacking.configure.version):
    	New section on updating the library version.
    	* doc/xml/manual/test.xml: Improve markup.
    	(test.new_tests): Rewrite.
    	* doc/html/manual/*: Regenerate.

diff --git a/libstdc++-v3/doc/xml/manual/build_hacking.xml b/libstdc++-v3/doc/xml/manual/build_hacking.xml
index 1b789d3..90489d1 100644
--- a/libstdc++-v3/doc/xml/manual/build_hacking.xml
+++ b/libstdc++-v3/doc/xml/manual/build_hacking.xml
@@ -93,7 +93,7 @@ in the build directory starts the build process. The <literal>all</literal> targ
 
   <para>
     Regenerate all generated files by using the command 
-    <code>autoreconf</code> at the top level of the libstdc++ source
+    <command>autoreconf</command> at the top level of the libstdc++ source
     directory.
   </para>
 </section>
@@ -108,10 +108,10 @@ in the build directory starts the build process. The <literal>all</literal> targ
 
 
   <para>
-    Until that glorious day when we can use AC_TRY_LINK with a
-    cross-compiler, we have to hardcode the results of what the tests
+    Until that glorious day when we can use <literal>AC_TRY_LINK</literal>
+    with a cross-compiler, we have to hardcode the results of what the tests
     would have shown if they could be run.  So we have an inflexible
-    mess like crossconfig.m4.
+    mess like <filename>crossconfig.m4</filename>.
   </para>
 
   <para>
@@ -119,8 +119,8 @@ in the build directory starts the build process. The <literal>all</literal> targ
     like configure.host, which can be modified without needing to
     regenerate anything, and can even be tweaked without really
     knowing how the configury all works?  Perhaps break the pieces of
-    crossconfig.m4 out and place them in their appropriate
-    config/{cpu,os} directory.
+    <filename>crossconfig.m4</filename> out and place them in their appropriate
+    <filename class="directory">config/{cpu,os}</filename> directory.
   </para>
 
   <para>
@@ -141,33 +141,37 @@ in the build directory starts the build process. The <literal>all</literal> targ
 
   <para>
     Most comments should use {octothorpes, shibboleths, hash marks,
-    pound signs, whatever} rather than "dnl".  Nearly all comments in
-    configure.ac should.  Comments inside macros written in ancillary
-    .m4 files should.  About the only comments which should
-    <emphasis>not</emphasis> use #, but use dnl instead, are comments
-    <emphasis>outside</emphasis> our own macros in the ancillary
-    files.  The difference is that # comments show up in
-    <code>configure</code> (which is most helpful for debugging),
-    while dnl'd lines just vanish.  Since the macros in ancillary
-    files generate code which appears in odd places, their "outside"
-    comments tend to not be useful while reading
-    <code>configure</code>.
+    pound signs, whatever} rather than "<literal>dnl</literal>".
+    Nearly all comments in <filename>configure.ac</filename> should.
+    Comments inside macros written in ancillary
+    <filename class="extension">.m4</filename> files should.
+    About the only comments which should <emphasis>not</emphasis>
+    use <literal>#</literal>, but use <literal>dnl</literal> instead,
+    are comments <emphasis>outside</emphasis> our own macros in the ancillary
+    files.  The difference is that <literal>#</literal> comments show up in
+    <filename>configure</filename> (which is most helpful for debugging),
+    while <literal>dnl</literal>'d lines just vanish.  Since the macros
+    in ancillary files generate code which appears in odd places,
+    their "outside" comments tend to not be useful while reading
+    <filename>configure</filename>.
   </para>
 
   <para>
     Do not use any <code>$target*</code> variables, such as
-    <code>$target_alias</code>.  The single exception is in
-    configure.ac, for automake+dejagnu's sake.
+    <varname>$target_alias</varname>.  The single exception is in
+    <filename>configure.ac</filename>, for automake+dejagnu's sake.
   </para>
 </section>
 
 <section xml:id="build_hacking.configure.acinclude"><info><title>The acinclude.m4 layout</title></info>
 
   <para>
-    The nice thing about acinclude.m4/aclocal.m4 is that macros aren't
+    The nice thing about
+    <filename>acinclude.m4</filename>/<filename>aclocal.m4</filename>
+    is that macros aren't
     actually performed/called/expanded/whatever here, just loaded.  So
     we can arrange the contents however we like.  As of this writing,
-    acinclude.m4 is arranged as follows:
+    <filename>acinclude.m4</filename> is arranged as follows:
   </para>
   <programlisting>
     GLIBCXX_CHECK_HOST
@@ -175,7 +179,8 @@ in the build directory starts the build process. The <literal>all</literal> targ
     GLIBCXX_CONFIGURE
   </programlisting>
   <para>
-    All the major variable "discovery" is done here.  CXX, multilibs,
+    All the major variable "discovery" is done here.
+    <varname>CXX</varname>, multilibs,
     etc.
   </para>
   <programlisting>
@@ -263,7 +268,8 @@ in the build directory starts the build process. The <literal>all</literal> targ
 <orderedlist>
  <listitem>
    <para>
-     Builds the call to the <literal>AC_ARG_ENABLE</literal> macro, with --help text
+     Builds the call to the <literal>AC_ARG_ENABLE</literal> macro, with
+     <option>--help</option> text
      properly quoted and aligned.  (Death to changequote!)
    </para>
  </listitem>
@@ -305,21 +311,25 @@ in the build directory starts the build process. The <literal>all</literal> targ
 <itemizedlist>
  <listitem>
    <para>
-     FEATURE is the string that follows --enable.  The results of the
-     test (such as it is) will be in the variable $enable_FEATURE,
-     where FEATURE has been squashed.  Example:
-     <code>[extra-foo]</code>, controlled by the --enable-extra-foo
-     option and stored in $enable_extra_foo.
+     <literal>FEATURE</literal> is the string that follows
+     <option>--enable</option>.  The results of the
+     test (such as it is) will be in the variable
+     <varname>$enable_FEATURE</varname>,
+     where <literal>FEATURE</literal> has been squashed.  Example:
+     <code>[extra-foo]</code>, controlled by the
+     <option>--enable-extra-foo</option>
+     option and stored in <varname>$enable_extra_foo</varname>.
    </para>
  </listitem>
  <listitem>
    <para>
-     DEFAULT is the value to store in $enable_FEATURE if the user does
-     not pass --enable/--disable.  It should be one of the permitted
-     values passed later.  Examples: <code>[yes]</code>, or
-     <code>[bar]</code>, or <code>[$1]</code> (which passes the
-     argument given to the <literal>GLIBCXX_ENABLE_FOO</literal> macro
-     as the default).
+     <literal>DEFAULT</literal> is the value to store in
+     <varname>$enable_FEATURE</varname> if the user does
+     not pass <option>--enable</option>/<option>--disable</option>.
+     It should be one of the permitted values passed later.
+     Examples: <code>[yes]</code>, or <code>[bar]</code>, or
+     <code>[$1]</code> (which passes the argument given to the
+     <literal>GLIBCXX_ENABLE_FOO</literal> macro as the default).
    </para>
    <para>
      For cases where we need to probe for particular models of things,
@@ -329,11 +339,11 @@ in the build directory starts the build process. The <literal>all</literal> targ
  </listitem>
  <listitem>
    <para>
-     HELP-ARG is any text to append to the option string itself in the
-     --help output.  Examples: <code>[]</code> (i.e., an empty string,
-     which appends nothing), <code>[=BAR]</code>, which produces
-     <code>--enable-extra-foo=BAR</code>, and
-     <code>[@&lt;:@=BAR@:&gt;@]</code>, which produces
+     <literal>HELP-ARG</literal> is any text to append to the option string
+     itself in the <option>--help</option> output.  Examples:
+     <code>[]</code> (i.e., an empty string, which appends nothing),
+     <code>[=BAR]</code>, which produces <code>--enable-extra-foo=BAR</code>,
+     and <code>[@&lt;:@=BAR@:&gt;@]</code>, which produces
      <code>--enable-extra-foo[=BAR]</code>.  See the difference?  See
      what it implies to the user?
    </para>
@@ -345,18 +355,19 @@ in the build directory starts the build process. The <literal>all</literal> targ
  </para>
  </listitem>
  <listitem>
-   <para>HELP-STRING is what you think it is.  Do not include the
+   <para><literal>HELP-STRING</literal> is what you think it is.  Do not include the
    "default" text like we used to do; it will be done for you by
-   GLIBCXX_ENABLE.  By convention, these are not full English
-   sentences.  Example: [turn on extra foo]
+   <literal>GLIBCXX_ENABLE</literal>.  By convention, these are not full English
+   sentences.  Example: <literal>[turn on extra foo]</literal>
    </para>
  </listitem>
 </itemizedlist>
 
 <para>
   With no other arguments, only the standard autoconf patterns are
-  allowed: "<code>--{enable,disable}-foo[={yes,no}]</code>" The
-  $enable_FEATURE variable is guaranteed to equal either "yes" or "no"
+  allowed: "<option>--{enable,disable}-foo[={yes,no}]</option>" The
+  <varname>$enable_FEATURE</varname> variable is guaranteed to equal
+  either "<literal>yes</literal>" or "<literal>no</literal>"
   after the macro.  If the user tries to pass something else, an
   explanatory error message will be given, and configure will halt.
 </para>
@@ -365,11 +376,14 @@ in the build directory starts the build process. The <literal>all</literal> targ
   The second signature takes a fifth argument, "<code>[permit
   a | b | c | ...]</code>"
   This allows <emphasis>a</emphasis> or <emphasis>b</emphasis> or
-  ... after the equals sign in the option, and $enable_FEATURE is
+  ... after the equals sign in the option, and
+  <varname>$enable_FEATURE</varname> is
   guaranteed to equal one of them after the macro.  Note that if you
-  want to allow plain --enable/--disable with no "=whatever", you must
-  include "yes" and "no" in the list of permitted values.  Also note
-  that whatever you passed as DEFAULT must be in the list.  If the
+  want to allow plain <option>--enable</option>/<option>--disable</option>
+  with no "<literal>=whatever</literal>", you must
+  include "<literal>yes</literal>" and "<literal>no</literal>" in the
+  list of permitted values.  Also note that whatever you passed as
+  <literal>DEFAULT</literal> must be in the list.  If the
   user tries to pass something not on the list, a semi-explanatory
   error message will be given, and configure will halt.  Example:
   <code>[permit generic|gnu|ieee_1003.1-2001|yes|no|auto]</code>
@@ -380,8 +394,123 @@ in the build directory starts the build process. The <literal>all</literal> targ
   code to execute if the user actually passes the enable/disable
   option.  (If the user does not, the default is used.  Duh.)  No
   argument checking at all is done in this signature.  See
-  GLIBCXX_ENABLE_CXX_FLAGS for an example of handling, and an error
-  message.
+  <literal>GLIBCXX_ENABLE_CXX_FLAGS</literal> for an example of handling,
+  and an error message.
+</para>
+
+</section>
+
+<section xml:id="build_hacking.configure.version"><info><title>Shared Library Versioning</title></info>
+
+<para>
+The <filename class="library">libstdc++.so</filename> shared library must
+be carefully managed to maintain binary compatible with older versions
+of the library. This ensures a new version of the library is still usable by
+programs that were linked against an older version.
+</para>
+
+<para>
+Dependent on the target supporting it, the library uses <link
+xmlns:xlink="http://www.w3.org/1999/xlink";
+xlink:href="https://www.akkadia.org/drepper/symbol-versioning";>ELF
+symbol versioning</link> for all exported symbols. The symbol versions
+are defined by a <link xmlns:xlink="http://www.w3.org/1999/xlink";
+xlink:href="https://sourceware.org/binutils/docs/ld/VERSION.html";>linker
+script</link> that assigns a version to every symbol.
+The set of symbols in each version is fixed when a GCC
+release is made, and must not change after that.
+</para>
+
+<para> When new symbols are added to the library they must be added
+to a new symbol version, which must be created the first time new symbols
+are added after a release. Adding a new symbol version involves the
+following steps:
+</para>
+
+<itemizedlist>
+<listitem><para>
+Edit <filename>acinclude.m4</filename> to update the "revision" value of
+<varname>libtool_VERSION</varname>, e.g. from <literal>6:22:0</literal>
+to <literal>6:23:0</literal>, which will cause the shared library to be
+built as <filename class="library">libstdc++.so.6.0.23</filename>.
+</para>
+</listitem>
+<listitem><para>
+Regenerate the <filename>configure</filename> script by running the
+<command>autoreconf</command> tool from the correct version of the Autoconf
+package (as dictated by the <link xmlns:xlink="http://www.w3.org/1999/xlink";
+xlink:href="https://gcc.gnu.org/install/prerequisites.html";>GCC
+prerequisites</link>).
+</para>
+</listitem>
+<listitem><para>
+Edit the file <filename>config/abi/pre/gnu.ver</filename> to
+add a new version node after the last new node. The node name should be
+<literal>GLIBCXX_3.4.X</literal> where <literal>X</literal> is the new
+revision set in <filename>acinclude.m4</filename>, and the node should
+depend on the previous version e.g.
+<programlisting>
+    GLIBCXX_3.4.23 {
+
+    } GLIBCXX_3.4.22;
+</programlisting>
+For symbols in the ABI runtime, libsupc++, the symbol version naming uses
+<literal>CXXABI_1.3.Y</literal> where <literal>Y</literal> increases
+monotonically with each new version. Again, the new node must depend on the
+previous version node e.g.
+<programlisting>
+    CXXABI_1.3.11 {
+
+    } CXXABI_1.3.10;
+</programlisting>
+</para>
+</listitem>
+<listitem><para>
+In order for the <link linkend="test.run.variations">check-abi</link> test
+target to pass the testsuite must be updated to know about the new symbol
+version(s). Edit the file <filename>testsuite/util/testsuite_abi.cc</filename>
+file to add the new versions to the <varname>known_versions</varname> list,
+and update the checks for the latest versions that set the
+<varname>latestp</varname> variable).
+</para>
+</listitem>
+</itemizedlist>
+
+<para>
+Once the new symbol version has been added you can add the names of your new
+symbols in the new version node:
+<programlisting>
+    GLIBCXX_3.4.23 {
+
+      # basic_string&lt;C, T, A&gt;::_Alloc_hider::_Alloc_hider(C*, A&amp;&amp;)
+      _ZNSt7__cxx1112basic_stringI[cw]St11char_traitsI[cw]ESaI[cw]EE12_Alloc_hiderC[12]EP[cw]OS3_;
+
+    } GLIBCXX_3.4.22;
+</programlisting>
+You can either use mangled names, or demangled names inside an
+<literal>extern "C++"</literal> block. You might find that the new symbol
+matches an existing pattern in an old symbol version (causing the
+<literal>check-abi</literal> test target to fail). If that happens then the
+existing pattern must be adjusted to be more specific so that it doesn't
+match the new symbol.
+</para>
+
+<para>
+For an example of these steps, including adjusting old patterns to be less
+greedy, see <link xmlns:xlink="http://www.w3.org/1999/xlink";
+xlink:href="https://gcc.gnu.org/ml/gcc-patches/2016-07/msg01926.html";>https://gcc.gnu.org/ml/gcc-patches/2016-07/msg01926.html</link>
+and the attached patch.
+</para>
+
+<para>
+If it wasn't done for the last release, you might also need to regenerate
+the <filename>baseline_symbols.txt</filename> file that defines the set
+of expected symbols for old symbol versions. A new baseline file can be
+generated by running <userinput>make new-abi-baseline</userinput> in the
+<filename class="directory"><replaceable>libbuildir</replaceable>/testsuite</filename>
+directory. Be sure to generate the baseline from a clean build using
+unmodified sources, or you will incorporate your local changes into the
+baseline file.
 </para>
 
 </section>
@@ -430,7 +559,7 @@ in the build directory starts the build process. The <literal>all</literal> targ
    <para>
      Generates a libtool convenience library,
      <filename>libc++98convenience</filename> with language-support
-     routines. Uses the <literal>-std=gnu++98</literal> dialect.
+     routines. Uses the <option>-std=gnu++98</option> dialect.
    </para>
  </listitem>
  <listitem>
@@ -440,7 +569,7 @@ in the build directory starts the build process. The <literal>all</literal> targ
    <para>
      Generates a libtool convenience library,
      <filename>libc++11convenience</filename> with language-support
-     routines. Uses the <literal>-std=gnu++11</literal> dialect.
+     routines. Uses the <option>-std=gnu++11</option> dialect.
    </para>
  </listitem>
  <listitem>
diff --git a/libstdc++-v3/doc/xml/manual/test.xml b/libstdc++-v3/doc/xml/manual/test.xml
index 456c48b..39a67a1 100644
--- a/libstdc++-v3/doc/xml/manual/test.xml
+++ b/libstdc++-v3/doc/xml/manual/test.xml
@@ -2,7 +2,7 @@
 	 xml:id="manual.intro.setup.test" xreflabel="Testing">
 <?dbhtml filename="test.html"?>
 
-<info><title>Test</title>
+<info><title>Testing</title>
   <keywordset>
     <keyword>ISO C++</keyword>
     <keyword>test</keyword>
@@ -19,66 +19,104 @@ The libstdc++ testsuite includes testing for standard conformance,
 regressions, ABI, and performance.
 </para>
 
-<section xml:id="test.organization" xreflabel="Test Organization"><info><title>Organization</title></info>
+<section xml:id="test.organization" xreflabel="Test Organization"><info><title>Test Organization</title></info>
 
 
 <section xml:id="test.organization.layout" xreflabel="Directory Layout"><info><title>Directory Layout</title></info>
 
 
 <para>
-  The directory <emphasis>libsrcdir/testsuite</emphasis> contains the
-  individual test cases organized in sub-directories corresponding to
-  clauses of the C++ standard (detailed below), the dejagnu test
-  harness support files, and sources to various testsuite utilities
-  that are packaged in a separate testing library.
+  The directory
+  <filename class="directory"><replaceable>gccsrcdir</replaceable>/libstdc++-v3/testsuite</filename>
+  contains the individual test cases organized in sub-directories
+  corresponding to clauses of the C++ standard (detailed below),
+  the DejaGnu test harness support files, and sources to various
+  testsuite utilities that are packaged in a separate testing library.
 </para>
 
 <para>
   All test cases for functionality required by the runtime components
   of the C++ standard (ISO 14882) are files within the following
-  directories.
-</para>
+  directories:
 
    <programlisting>
-17_intro
-18_support
-19_diagnostics
-20_util
-21_strings
-22_locale
-23_containers
-25_algorithms
-26_numerics
-27_io
-28_regex
-29_atomics
-30_threads
+    17_intro
+    18_support
+    19_diagnostics
+    20_util
+    21_strings
+    22_locale
+    23_containers
+    24_iterators
+    25_algorithms
+    26_numerics
+    27_io
+    28_regex
+    29_atomics
+    30_threads
    </programlisting>
+</para>
 
    <para>
       In addition, the following directories include test files:
-   </para>
 
-   <programlisting>
-tr1		  Tests for components as described by the Technical Report on Standard Library Extensions (TR1).
-backward	  Tests for backwards compatibility and deprecated features.
-demangle	  Tests for __cxa_demangle, the IA 64 C++ ABI demangler
-ext		  Tests for extensions.
-performance	  Tests for performance analysis, and performance regressions.
-   </programlisting>
+<variablelist spacing="compact">
+<varlistentry>
+  <term><filename class="directory">tr1</filename></term>
+  <listitem>Tests for components as described by the Technical Report
+    on Standard Library Extensions (<link linked="status.iso.tr1">TR1</link>).
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">backward</filename></term>
+  <listitem>Tests for backwards compatibility and deprecated features.
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">demangle</filename></term>
+  <listitem>Tests for <function>__cxa_demangle</function>, the IA-64 C++ ABI
+    demangler.
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">ext</filename></term>
+  <listitem>Tests for extensions.</listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">performance</filename></term>
+  <listitem>Tests for performance analysis, and performance regressions.
+  </listitem>
+</varlistentry>
+</variablelist>
+   </para>
 
    <para>
       Some directories don't have test files, but instead contain
       auxiliary information:
-   </para>
 
-   <programlisting>
-config		  Files for the dejagnu test harness.
-lib		  Files for the dejagnu test harness.
-libstdc++*     	  Files for the dejagnu test harness.
-data		  Sample text files for testing input and output.
-util		  Files for libtestc++, utilities and testing routines.
-   </programlisting>
+<variablelist spacing="compact">
+<varlistentry>
+  <term><filename class="directory">config</filename></term>
+  <listitem>Files for the DejaGnu test harness.</listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">lib</filename></term>
+  <listitem>Files for the DejaGnu test harness.</listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">libstdc++*</filename></term>
+  <listitem>Files for the DejaGnu test harness.</listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">data</filename></term>
+  <listitem>Sample text files for testing input and output.</listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">util</filename></term>
+  <listitem>Files for libtestc++, utilities and testing routines.</listitem>
+</varlistentry>
+</variablelist>
+   </para>
 
    <para>
       Within a directory that includes test files, there may be
@@ -86,13 +124,9 @@ util		  Files for libtestc++, utilities and testing routines.
       were appended to one file that represented a particular section
       of the chapter under test, and was named accordingly. For
       instance, to test items related to <code> 21.3.6.1 -
-      basic_string::find [lib.string::find]</code> in the standard,
-      the following was used:
-   </para>
-   <programlisting>
-21_strings/find.cc
-   </programlisting>
-   <para>
+      <function>basic_string::find</function> [lib.string::find]</code>
+      in the standard, the following was used:
+<programlisting>    21_strings/find.cc </programlisting>
       However, that practice soon became a liability as the test cases
       became huge and unwieldy, and testing new or extended
       functionality (like wide characters or named locales) became
@@ -102,19 +136,17 @@ util		  Files for libtestc++, utilities and testing routines.
       above issues and gives finer grained results and more manageable
       error debugging. As an example, the test case quoted above
       becomes:
+<programlisting>    21_strings/basic_string/find/char/1.cc
+    21_strings/basic_string/find/char/2.cc
+    21_strings/basic_string/find/char/3.cc
+    21_strings/basic_string/find/wchar_t/1.cc
+    21_strings/basic_string/find/wchar_t/2.cc
+    21_strings/basic_string/find/wchar_t/3.cc</programlisting>
    </para>
-   <programlisting>
-21_strings/basic_string/find/char/1.cc
-21_strings/basic_string/find/char/2.cc
-21_strings/basic_string/find/char/3.cc
-21_strings/basic_string/find/wchar_t/1.cc
-21_strings/basic_string/find/wchar_t/2.cc
-21_strings/basic_string/find/wchar_t/3.cc
-   </programlisting>
 
    <para>
-      All new tests should be written with the policy of one test
-      case, one file in mind.
+      All new tests should be written with the policy of "one test
+      case, one file" in mind.
    </para>
 </section>
 
@@ -128,87 +160,72 @@ util		  Files for libtestc++, utilities and testing routines.
       tests.
    </para>
 
-<itemizedlist>
-<listitem>
-  <para>
-   <emphasis>_xin.cc</emphasis>
-  </para>
-   <para>
+<variablelist>
+<varlistentry>
+  <term><filename class="extension">_xin.cc</filename></term>
+  <listitem>
       This test case expects some kind of interactive input in order
       to finish or pass. At the moment, the interactive tests are not
       run by default. Instead, they are run by hand, like:
-   </para>
       <programlisting>
 g++ 27_io/objects/char/3_xin.cc
-cat 27_io/objects/char/3_xin.in | a.out
-     </programlisting>
-</listitem>
-<listitem>
-   <para>
-     <emphasis>.in</emphasis>
-   </para>
-   <para>
+cat 27_io/objects/char/3_xin.in | a.out</programlisting>
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="extension">.in</filename></term>
+  <listitem>
       This file contains the expected input for the corresponding <emphasis>
       _xin.cc</emphasis> test case.
-   </para>
-</listitem>
-<listitem>
-  <para>
-   <emphasis>_neg.cc</emphasis>
-  </para>
-   <para>
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="extension">_neg.cc</filename></term>
+  <listitem>
       This test case is expected to fail: it's a negative test. At the
       moment, these are almost always compile time errors.
-   </para>
-</listitem>
-<listitem>
-  <para>
-   <emphasis>char</emphasis>
-  </para>
-   <para>
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">char</filename></term>
+  <listitem>
       This can either be a directory name or part of a longer file
       name, and indicates that this file, or the files within this
       directory are testing the <code>char</code> instantiation of a
       template.
-   </para>
-</listitem>
-<listitem>
-  <para>
-   <emphasis>wchar_t</emphasis>
-  </para>
-   <para>
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">wchar_t</filename></term>
+  <listitem>
       This can either be a directory name or part of a longer file
       name, and indicates that this file, or the files within this
       directory are testing the <code>wchar_t</code> instantiation of
       a template. Some hosts do not support <code>wchar_t</code>
       functionality, so for these targets, all of these tests will not
       be run.
-   </para>
-</listitem>
-<listitem>
-  <para>
-   <emphasis>thread</emphasis>
-  </para>
-   <para>
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">thread</filename></term>
+  <listitem>
       This can either be a directory name or part of a longer file
       name, and indicates that this file, or the files within this
       directory are testing situations where multiple threads are
       being used.
-   </para>
-</listitem>
-<listitem>
-  <para>
-   <emphasis>performance</emphasis>
-  </para>
-   <para>
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><filename class="directory">performance</filename></term>
+  <listitem>
       This can either be an enclosing directory name or part of a
       specific file name. This indicates a test that is used to
       analyze runtime performance, for performance regression testing,
       or for other optimization related analysis. At the moment, these
       test cases are not run by default.
-   </para>
-</listitem>
-</itemizedlist>
+  </listitem>
+</varlistentry>
+</variablelist>
 
 </section>
 </section>
@@ -222,24 +239,29 @@ cat 27_io/objects/char/3_xin.in | a.out
 
     <para>
       You can check the status of the build without installing it
-      using the dejagnu harness, much like the rest of the gcc
-      tools.</para>
-   <programlisting> make check</programlisting>
-   <para>in the <emphasis>libbuilddir</emphasis> directory.</para>
-   <para>or</para>
-   <programlisting> make check-target-libstdc++-v3</programlisting>
-   <para>in the <emphasis>gccbuilddir</emphasis> directory.
-     </para>
+      using the DejaGnu harness, much like the rest of the gcc
+      tools, i.e.
+   <userinput>make check</userinput>
+      in the
+      <filename class="directory"><replaceable>libbuilddir</replaceable></filename>
+      directory, or
+   <userinput>make check-target-libstdc++-v3</userinput>
+       in the
+      <filename class="directory"><replaceable>gccbuilddir</replaceable></filename>
+       directory.
+    </para>
 
      <para>
        These commands are functionally equivalent and will create a
-       'testsuite' directory underneath
-       <emphasis>libbuilddir</emphasis> containing the results of the
-       tests. Two results files will be generated: <emphasis>
-       libstdc++.sum</emphasis>, which is a PASS/FAIL summary for each
-       test, and <emphasis>libstdc++.log</emphasis> which is a log of
-       the exact command line passed to the compiler, the compiler
-       output, and the executable output (if any).
+       '<filename class="directory">testsuite</filename>' directory underneath
+       <filename class="directory"><replaceable>libbuilddir</replaceable></filename>
+       containing the results of the
+       tests. Two results files will be generated:
+       <filename>libstdc++.sum</filename>, which is a PASS/FAIL summary
+       for each test, and
+       <filename>libstdc++.log</filename> which is a log of
+       the exact command-line passed to the compiler, the compiler
+       output, and the executable output (if any) for each test.
      </para>
 
      <para>
@@ -262,88 +284,88 @@ cat 27_io/objects/char/3_xin.in | a.out
       checking the exported symbols of the shared library.
     </para>
     <para>
-      To debug the dejagnu test harness during runs, try invoking with a
-      specific argument to the variable RUNTESTFLAGS, as below.
-    </para>
-
+      To debug the DejaGnu test harness during runs, try invoking with a
+      specific argument to the variable <varname>RUNTESTFLAGS</varname>,
+      like so:
 <programlisting>
-make check-target-libstdc++-v3 RUNTESTFLAGS="-v"
+    make check-target-libstdc++-v3 RUNTESTFLAGS="-v"
 </programlisting>
-
-    <para>
       or
-    </para>
-
 <programlisting>
-make check-target-libstdc++-v3 RUNTESTFLAGS="-v -v"
+    make check-target-libstdc++-v3 RUNTESTFLAGS="-v -v"
 </programlisting>
+    </para>
 
     <para>
       To run a subset of the library tests, you can either generate the
-      <emphasis>testsuite_files</emphasis> file (described below) by running
-      <command>make testsuite_files</command> in the
-      <emphasis>libbuilddir/testsuite</emphasis> directory, then edit the
+      <filename>testsuite_files</filename> file (described below) by running
+      <userinput>make testsuite_files</userinput> in the
+      <filename class="directory"><replaceable>libbuilddir</replaceable>/testsuite</filename>
+      directory, then edit the
       file to remove the tests you don't want and then run the testsuite as
       normal, or you can specify a testsuite and a subset of tests in the
-      RUNTESTFLAGS variable.
+      <varname>RUNTESTFLAGS</varname> variable.
     </para>
 
     <para>
       For example, to run only the tests for containers you could use:
-    </para>
 
 <programlisting>
-make check-target-libstdc++-v3 RUNTESTFLAGS="conformance.exp=23_containers/*"
+    make check-target-libstdc++-v3 RUNTESTFLAGS="conformance.exp=23_containers/*"
 </programlisting>
-
-    <para>
-      When combining this with other options in RUNTESTFLAGS the
-      <emphasis>testsuite.exp=testfiles</emphasis> options must come first.
     </para>
 
     <para>
-      There are two ways to run on a simulator: set up DEJAGNU to point to a
-      specially crafted site.exp, or pass down --target_board flags.
+      When combining this with other options in <varname>RUNTESTFLAGS</varname>
+      the <option>testsuite.exp=testfiles</option> options must come first.
+    </para>
+
+    <para>
+      There are two ways to run on a simulator: set up <envar>DEJAGNU</envar>
+      to point to a specially crafted <filename>site.exp</filename>,
+      or pass down <option>--target_board</option> flags.
     </para>
 
     <para>
     Example flags to pass down for various embedded builds are as follows:
-    </para>
 
 <programlisting>
-      --target=powerpc-eabism (libgloss/sim)
-make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=powerpc-sim"
+  --target=powerpc-eabisim <emphasis>(libgloss/sim)</emphasis>
+  make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=powerpc-sim"
 
---target=calmrisc32 (libgloss/sid)
-make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=calmrisc32-sid"
+  --target=calmrisc32 <emphasis>(libgloss/sid)</emphasis>
+  make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=calmrisc32-sid"
 
---target=xscale-elf (newlib/sim)
-make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim"
+  --target=xscale-elf <emphasis>(newlib/sim)</emphasis>
+  make check-target-libstdc++-v3 RUNTESTFLAGS="--target_board=arm-sim"
 </programlisting>
+    </para>
 
     <para>
       Also, here is an example of how to run the libstdc++ testsuite
       for a multilibed build directory with different ABI settings:
-    </para>
 
  <programlisting>
-make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board \"unix{-mabi=32,,-mabi=64}\"'
+    make check-target-libstdc++-v3 RUNTESTFLAGS='--target_board \"unix{-mabi=32,,-mabi=64}\"'
 </programlisting>
+    </para>
 
     <para>
       You can run the tests with a compiler and library that have
       already been installed.  Make sure that the compiler (e.g.,
-      <code>g++</code>) is in your <code>PATH</code>.  If you are
+      <command>g++</command>) is in your <envar>PATH</envar>.  If you are
       using shared libraries, then you must also ensure that the
       directory containing the shared version of libstdc++ is in your
-      <code>LD_LIBRARY_PATH</code>, or equivalent.  If your GCC source
-      tree is at <code>/path/to/gcc</code>, then you can run the tests
-      as follows:
-    </para>
+      <envar>LD_LIBRARY_PATH</envar>, or
+      <link linkend="manual.intro.using.linkage.dynamic">equivalent</link>.
+      If your GCC source tree is at
+      <filename class="directory">/path/to/gcc</filename>,
+      then you can run the tests as follows:
 
 <programlisting>
-runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
+    runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
 </programlisting>
+    </para>
 
     <para>
       The testsuite will create a number of files in the directory in
@@ -356,111 +378,171 @@ runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
     <para>
       In addition, there are some testing options that are mostly of
       interest to library maintainers and system integrators. As such,
-      these tests may not work on all cpu and host combinations, and
+      these tests may not work on all CPU and host combinations, and
       may need to be executed in the
-      <emphasis>libbuilddir/testsuite</emphasis> directory.  These
+      <filename class="directory"><replaceable>libbuilddir</replaceable>/testsuite</filename>
+      directory.  These
       options include, but are not necessarily limited to, the
       following:
-   </para>
+    </para>
 
-   <programlisting>
+<variablelist>
+<varlistentry>
+   <term><userinput>
    make testsuite_files
-   </programlisting>
+   </userinput></term>>
 
+  <listitem>
   <para>
     Five files are generated that determine what test files
     are run. These files are:
-  </para>
 
-   <itemizedlist>
-     <listitem>
-       <para>
-	 <emphasis>testsuite_files</emphasis>
-       </para>
-       <para>
+    <variablelist>
+    <varlistentry>
+      <term> <filename>testsuite_files</filename> </term>
+      <listitem>
 	 This is a list of all the test cases that will be run. Each
 	 test case is on a separate line, given with an absolute path
-	 from the <emphasis>libsrcdir/testsuite</emphasis> directory.
-       </para>
-     </listitem>
+	 from the
+         <filename class="directory"><replaceable>libsrcdir</replaceable>/testsuite</filename>
+         directory.
+      </listitem>
+    </varlistentry>
 
-     <listitem>
-       <para>
-	 <emphasis>testsuite_files_interactive</emphasis>
-       </para>
-       <para>
+    <varlistentry>
+      <term> <filename>testsuite_files_interactive</filename> </term>
+      <listitem>
 	 This is a list of all the interactive test cases, using the
 	 same format as the file list above. These tests are not run
 	 by default.
-     </para>
-     </listitem>
+      </listitem>
+    </varlistentry>
 
-     <listitem>
-       <para>
-	 <emphasis>testsuite_files_performance</emphasis>
-       </para>
-       <para>
+    <varlistentry>
+      <term> <filename>testsuite_files_performance</filename> </term>
+      <listitem>
 	 This is a list of all the performance test cases, using the
 	 same format as the file list above. These tests are not run
 	 by default.
-     </para>
-     </listitem>
+      </listitem>
+    </varlistentry>
 
-     <listitem>
-       <para>
-	 <emphasis>testsuite_thread</emphasis>
-       </para>
-       <para>
+    <varlistentry>
+      <term> <filename>testsuite_thread</filename> </term>
+      <listitem>
 	 This file indicates that the host system can run tests which
 	 involved multiple threads.
-       </para>
-     </listitem>
+      </listitem>
+    </varlistentry>
 
-     <listitem>
-       <para>
-	 <emphasis>testsuite_wchar_t</emphasis>
-       </para>
-       <para>
-	 This file indicates that the host system can run the wchar_t
-	 tests, and corresponds to the macro definition <code>
-	 _GLIBCXX_USE_WCHAR_T</code> in the file c++config.h.
-       </para>
-     </listitem>
-    </itemizedlist>
+    <varlistentry>
+      <term> <filename>testsuite_wchar_t</filename> </term>
+      <listitem>
+	 This file indicates that the host system can run the
+         <code>wchar_t</code> tests, and corresponds to the macro
+         definition <literal>_GLIBCXX_USE_WCHAR_T</literal> in the
+         file <filename>c++config.h</filename>.
+      </listitem>
+    </varlistentry>
+    </variablelist>
+  </para>
+  </listitem>
+</varlistentry>
 
-   <programlisting>
+<varlistentry>
+   <term><userinput>
    make check-abi
-   </programlisting>
+   </userinput></term>>
 
+   <listitem>
    <para>
      The library ABI can be tested. This involves testing the shared
-     library against an ABI-defining previous version of symbol
-     exports.
+     library against a baseline list of symbol exports that defines the
+     previous version of the ABI. The tests require that no exported
+     symbols are removed, no new symbols are added to the old symbol
+     versions, and any new symbols have the latest symbol version.
+     See <link linkend="abi.versioning">Versioning</link> for more details
+     of the ABI version history.
    </para>
+   </listitem>
+</varlistentry>
 
-  <programlisting>
+<varlistentry>
+   <term><userinput>
+   make new-abi-baseline
+   </userinput></term>>
+
+   <listitem>
+   <para>
+     Generate a new baseline set of symbols exported from the library
+     (written to a file under
+     <filename class="directory"><replaceable>libsrcdir</replaceable>/config/abi/post/<replaceable>target</replaceable>/</filename>).
+     A different baseline symbols file is needed for each architecture and
+     is used by the <literal>check-abi</literal> target described above.
+     The files are usually re-generated by target maintainers for releases.
+   </para>
+   </listitem>
+</varlistentry>
+
+<varlistentry>
+  <term><userinput>
    make check-compile
-  </programlisting>
+  </userinput></term>>
 
+   <listitem>
    <para>
      This rule compiles, but does not link or execute, the
-     <emphasis>testsuite_files</emphasis> test cases and displays the
+     <filename>testsuite_files</filename> test cases and displays the
      output on stdout.
    </para>
+   </listitem>
+</varlistentry>
 
-   <programlisting>
+<varlistentry>
+   <term><userinput>
    make check-performance
-   </programlisting>
+   </userinput></term>>
 
+   <listitem>
    <para>
      This rule runs through the
-     <emphasis>testsuite_files_performance</emphasis> test cases and
+     <filename>testsuite_files_performance</filename> test cases and
      collects information for performance analysis and can be used to
      spot performance regressions. Various timing information is
      collected, as well as number of hard page faults, and memory
      used. This is not run by default, and the implementation is in
      flux.
    </para>
+   </listitem>
+</varlistentry>
+
+<varlistentry>
+   <term><userinput>
+   make check-debug
+   </userinput></term>>
+
+   <listitem>
+   <para>
+     This rule runs through the test suite under the
+     <link linkend="manual.ext.debug_mode">debug mode</link>.
+   </para>
+   </listitem>
+</varlistentry>
+
+<varlistentry>
+   <term><userinput>
+   make check-parallel
+   </userinput></term>>
+
+   <listitem>
+   <para>
+     This rule runs through the test suite under the
+     <link linkend="manual.ext.parallel_mode">parallel mode</link>.
+   </para>
+   </listitem>
+</varlistentry>
+
+</variablelist>
 
    <para>
       We are interested in any strange failures of the testsuite;
@@ -472,29 +554,65 @@ runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
   <section xml:id="test.run.permutations"><info><title>Permutations</title></info>
     
     <para>
-      To run the libstdc++ test suite under the <link linkend="manual.ext.debug_mode">debug mode</link>, edit
-      <filename>libstdc++-v3/scripts/testsuite_flags</filename> to add the
-      compile-time flag <constant>-D_GLIBCXX_DEBUG</constant> to the
-      result printed by the <literal>--build-cxx</literal>
+      The tests will be compiled with a set of default compiler flags defined
+      by the
+      <filename><replaceable>libbuildir</replaceable>/scripts/testsuite_flags</filename>
+      file, as well as options specified in individual tests. You can run
+      the tests with different options by adding them to the output of
+      the <option>--cxxflags</option> option of that script, or by setting
+      the <varname>CXXFLAGS</varname> variable when running
+      <command>make</command>, or via options for the DejaGnu test framework
+      (described below). The latter approach uses the
+      <option>--target_board</option> option that was shown earlier.
+      For example, to run the tests with <option>-O1 -D_GLIBCXX_ASSERT</option>
+      you could use:
+<programlisting>    make RUNTESTFLAGS=--target_board=unix/-O1/-D_GLIBCXX_ASSERTIONS</programlisting>
+    </para>
+
+    <para>
+      The <option>--target_board</option> option can also be used to run the
+      tests multiple times in different variations. For example, to run the
+      entire testsuite three times using <option>-O3</option> but with
+      different <option>-std</option> options:
+<programlisting>    make 'RUNTESTFLAGS=--target_board=unix/-O3\"{-std=gnu++98,-std=gnu++11,-std=gnu++14}\"'</programlisting>
+      N.B. that set of variations could also be written as
+      <literal>unix/-O3\"{-std=gnu++98,-std=gnu++11,}\"</literal> so that
+      the third variation would use the default for <option>-std</option>
+      (which is <option>-std=gnu++14</option> as of GCC 6).
+    </para>
+
+    <para>
+      To run the libstdc++ test suite under the
+      <link linkend="manual.ext.debug_mode">debug mode</link>, use
+      <userinput>make check-debug</userinput>. Alternatively, edit
+      <filename><replaceable>libbuildir</replaceable>/scripts/testsuite_flags</filename>
+      to add the compile-time flag <option>-D_GLIBCXX_DEBUG</option> to the
+      result printed by the <option>--cxxflags</option>
       option. Additionally, add the
-      <constant>-D_GLIBCXX_DEBUG_PEDANTIC</constant> flag to turn on
+      <option>-D_GLIBCXX_DEBUG_PEDANTIC</option> flag to turn on
       pedantic checking. The libstdc++ test suite should produce
-      precisely the same results under debug mode that it does under
-      release mode: any deviation indicates an error in either the
-      library or the test suite.
+      the same results under debug mode that it does under release mode:
+      any deviation indicates an error in either the library or the test suite.
+      Note, however, that the number of tests that PASS may change, because
+      some test cases are skipped in normal mode, and some are skipped in
+      debug mode, as determined by the
+      <literal>dg-require-<replaceable>support</replaceable></literal>
+      directives described below.
     </para>
 
     <para>
       The <link linkend="manual.ext.parallel_mode">parallel
-      mode</link> can be tested in much the same manner, substituting
-      <constant>-D_GLIBCXX_PARALLEL</constant> for
-      <constant>-D_GLIBCXX_DEBUG</constant> in the previous paragraph.
+      mode</link> can be tested using
+      <userinput>make check-parallel</userinput>, or in much the same manner
+      as the debug mode, substituting
+      <option>-D_GLIBCXX_PARALLEL</option> for
+      <option>-D_GLIBCXX_DEBUG</option> in the previous paragraph.
     </para>
 
     <para>
-      Or, just run the testsuites with <constant>CXXFLAGS</constant>
-      set to <constant>-D_GLIBCXX_DEBUG</constant> or
-      <constant>-D_GLIBCXX_PARALLEL</constant>.
+      Or, just run the testsuite
+      <option>-D_GLIBCXX_DEBUG</option> or <option>-D_GLIBCXX_PARALLEL</option>
+      in <varname>CXXFLAGS</varname> or <varname>RUNTESTFLAGS</varname>.
     </para>
   </section>
 </section>
@@ -511,12 +629,17 @@ runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
    <para>
     All files are copyright the FSF, and GPL'd: this is very
     important.  The first copyright year should correspond to the date
-    the file was checked in to SVN.
+    the file was checked in to version control. If a test is copied from
+    an existing file it should retain the copyright years from the
+    original file.
    </para>
 
    <para>
-     As per the dejagnu instructions, always return 0 from main to
-     indicate success.
+     The DejaGnu instructions say to always return <literal>0</literal>
+     from <function>main</function> to indicate success. Strictly speaking
+     this is redundant in C++, since returning from <function>main</function>
+     is defined to return <literal>0</literal>. Most tests still have an
+     explicit return.
    </para>
 
    <para>
@@ -528,128 +651,259 @@ runtest --tool libstdc++ --srcdir=/path/to/gcc/libstdc++-v3/testsuite
    </para>
 
    <para>
-   For a test that needs to take advantage of the dejagnu test
-   harness, what follows below is a list of special keyword that
-   harness uses. Basically, a test case contains dg-keywords (see
-   dg.exp) indicating what to do and what kinds of behavior are to be
-   expected.  New test cases should be written with the new style
-   DejaGnu framework in mind.
+    Tests that need to perform runtime checks should use the
+    <literal>VERIFY</literal> macro, defined in the
+    <filename class="headerfile">&lt;testsuite_hooks.h&gt;</filename> header.
+    This usually expands to the standard <literal>assert</literal> macro, but
+    allows targets to define it to something different. In order to support
+    the alternative expansions of <literal>VERIFY</literal>, before any
+    use of the macro there must be a variable called <varname>test</varname>
+    in scope, which is usually defined like so (the attribute avoids
+    warnings about an unused variable):
+    <programlisting>
+    bool test __attribute__((unused)) = true;
+    </programlisting>
    </para>
 
    <para>
-    To ease transition, here is the list of dg-keyword documentation
-    lifted from dg.exp.
-   </para>
+    The testsuite uses the DejaGnu framework to compile and run the tests.
+    Test cases are normal C++ files which contain special directives in
+    comments.  These directives look like <literal>{ dg-* ... }</literal>
+    and tell DejaGnu what to do and what kinds of behavior are to be expected
+    for a test.  The core DejaGnu directives are documented in the
+    <filename>dg.exp</filename> file installed by DejaGnu.
+    The GCC testsuites support additional directives
+    as described in the GCC internals documentation, see <link
+    xmlns:xlink="http://www.w3.org/1999/xlink";
+    xlink:href="https://gcc.gnu.org/onlinedocs/gccint/Directives.html";>Syntax
+    and Descriptions of test directives</link>. GCC also defines many <link
+    xmlns:xlink="http://www.w3.org/1999/xlink";
+    xlink:href="https://gcc.gnu.org/onlinedocs/gccint/Effective-Target-Keywords.html";>
+    Keywords describing target attributes</link> (a.k.a effective targets)
+    which can be used where a target <replaceable>selector</replaceable> can
+    appear.
+  </para>
 
+  <para>
+  Some directives commonly used in the libstdc++ testsuite are:
+
+<variablelist>
+<varlistentry>
+  <term><literal>{ dg-do <replaceable>do-what-keyword</replaceable> [{ target/xfail <replaceable>selector</replaceable> }] }</literal></term>
+  <listitem>Where <replaceable>do-what-keyword</replaceable> is usually
+    one of <literal>run</literal> (which is the default),
+    <literal>compile</literal>, or <literal>link</literal>,
+    and typical selectors are targets such as <literal>*-*-gnu*</literal>
+    or an effective target such as <literal>c++11</literal>.
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><literal>{ dg-require-<replaceable>support</replaceable> args }</literal></term>
+  <listitem>Skip the test if the target does not provide the required support.
+    See below for values of <replaceable>support</replaceable>.
+  </listitem>
+</varlistentry>
+<varlistentry>
+  <term><literal>{ dg-options <replaceable>options</replaceable> [{ target <replaceable>selector</replaceable> }] }</literal></term>
+</varlistentry>
+<varlistentry>
+  <term><literal>{ dg-error <replaceable>regexp</replaceable> [ <replaceable>comment</replaceable> [{ target/xfail <replaceable>selector</replaceable> } [<replaceable>line</replaceable>] ]] }</literal></term>
+</varlistentry>
+<varlistentry>
+  <term><literal>{ dg-excess-errors <replaceable>comment</replaceable> [{ target/xfail <replaceable>selector</replaceable> }] }</literal></term>
+</varlistentry>
+</variablelist>
+  For full details of these and other directives see the main GCC DejaGnu
+  documentation in the internals manual.
+  </para>
+
+  <para>
+    Test cases that use features of a particular C++ standard should specify
+    the minimum required standard as an effective target:
+<programlisting>    // { dg-do run { target c++11 } }</programlisting>
+    or
+<programlisting>    // { dg-require-effective-target c++11 }</programlisting>
+    Specifying the minimum required standard for a test allows it to be run
+    using later standards, so that we can verify that C++11 components still
+    work correctly when compiled as C++14 or later. Specifying a minimum also
+    means the test will be skipped if the test is compiled using
+    an older standard, e.g. using
+    <option>RUNTESTFLAGS=--target_board=unix/-std=gnu++98</option>.
+  </para>
+
+  <para>
+    It is possible to indicate that a test should <emphasis>only</emphasis>
+    be run for a specific standard (and not later standards) using an
+    effective target like <literal>c++11_only</literal>. However, this means
+    the test will be skipped by default (because the default mode is
+    <literal>gnu++14</literal>), and so will only run when
+    <option>-std=gnu++11</option> or <option>-std=c++11</option> is used
+    explicitly. For tests that require a specific standard it is better to
+    use a <literal>dg-options</literal> directive:
+<programlisting>    // { dg-options "-std=gnu++11" }</programlisting>
+    This means the test will not get skipped by default, and will always use
+    the specific standard dialect that the test requires. This isn't needed
+    often, and most tests should use an effective target to specify a
+    minimum standard instead, to allow them to be tested for all
+    possible variations.
+  </para>
+
+  <para>
+    Similarly, tests which depend on a newer standard than the default
+    should use <literal>dg-options</literal> instead of an effective target,
+    so that they are not skipped by default.
+    For example, tests for C++17 features should use
+<programlisting>    // { dg-options "-std=gnu++17" }</programlisting>
+    and not
+<programlisting>    // { dg-do run "c++1z" }</programlisting>
+  </para>
+
+<section xml:id="tests.dg.examples"><info><title>Examples of Test Directives</title></info>
+
+   <para>
+Example 1: Testing compilation only:
 <programlisting>
-# The currently supported options are:
-#
-# dg-prms-id N
-#	set prms_id to N
-#
-# dg-options "options ..." [{ target selector }]
-#	specify special options to pass to the tool (eg: compiler)
-#
-# dg-do do-what-keyword [{ target/xfail selector }]
-#	`do-what-keyword' is tool specific and is passed unchanged to
-#	${tool}-dg-test.  An example is gcc where `keyword' can be any of:
-#	preprocess|compile|assemble|link|run
-#	and will do one of: produce a .i, produce a .s, produce a .o,
-#	produce an a.out, or produce an a.out and run it (the default is
-#	compile).
-#
-# dg-error regexp comment [{ target/xfail selector } [{.|0|linenum}]]
-#	indicate an error message &lt;regexp&gt; is expected on this line
-#	(the test fails if it doesn't occur)
-#	Linenum=0 for general tool messages (eg: -V arg missing).
-#	"." means the current line.
-#
-# dg-warning regexp comment [{ target/xfail selector } [{.|0|linenum}]]
-#	indicate a warning message &lt;regexp&gt; is expected on this line
-#	(the test fails if it doesn't occur)
-#
-# dg-bogus regexp comment [{ target/xfail selector } [{.|0|linenum}]]
-#	indicate a bogus error message &lt;regexp&gt; use to occur here
-#	(the test fails if it does occur)
-#
-# dg-build regexp comment [{ target/xfail selector }]
-#	indicate the build use to fail for some reason
-#	(errors covered here include bad assembler generated, tool crashes,
-#	and link failures)
-#	(the test fails if it does occur)
-#
-# dg-excess-errors comment [{ target/xfail selector }]
-#	indicate excess errors are expected (any line)
-#	(this should only be used sparingly and temporarily)
-#
-# dg-output regexp [{ target selector }]
-#	indicate the expected output of the program is &lt;regexp&gt;
-#	(there may be multiple occurrences of this, they are concatenated)
-#
-# dg-final { tcl code }
-#	add some tcl code to be run at the end
-#	(there may be multiple occurrences of this, they are concatenated)
-#	(unbalanced braces must be \-escaped)
-#
-# "{ target selector }" is a list of expressions that determine whether the
-# test succeeds or fails for a particular target, or in some cases whether the
-# option applies for a particular target.  If the case of `dg-do' it specifies
-# whether the test case is even attempted on the specified target.
-#
-# The target selector is always optional.  The format is one of:
-#
-# { xfail *-*-* ... } - the test is expected to fail for the given targets
-# { target *-*-* ... } - the option only applies to the given targets
-#
-# At least one target must be specified, use *-*-* for "all targets".
-# At present it is not possible to specify both `xfail' and `target'.
-# "native" may be used in place of "*-*-*".
-
-Example 1: Testing compilation only
 // { dg-do compile }
+</programlisting>
 
-Example 2: Testing for expected warnings on line 36, which all targets fail
+Example 2: Testing for expected warnings on line 36, which all targets fail:
+<programlisting>
 // { dg-warning "string literals" "" { xfail *-*-* } 36 }
+</programlisting>
 
-Example 3: Testing for expected warnings on line 36
+Example 3: Testing for expected warnings on line 36:
+<programlisting>
 // { dg-warning "string literals" "" { target *-*-* } 36 }
+</programlisting>
 
-Example 4: Testing for compilation errors on line 41
+Example 4: Testing for compilation errors on line 41:
+<programlisting>
 // { dg-do compile }
 // { dg-error "no match for" "" { target *-*-* } 41 }
+</programlisting>
 
 Example 5: Testing with special command line settings, or without the
-use of pre-compiled headers, in particular the stdc++.h.gch file. Any
-options here will override the DEFAULT_CXXFLAGS and PCH_CXXFLAGS set
-up in the normal.exp file.
+use of pre-compiled headers, in particular the
+<filename class="headerfile">stdc++.h.gch</filename> file. Any
+options here will override the <varname>DEFAULT_CXXFLAGS</varname> and
+<varname>PCH_CXXFLAGS</varname> set up in the <filename>normal.exp</filename>
+file:
+<programlisting>
 // { dg-options "-O0" { target *-*-* } }
 </programlisting>
 
-   <para>
-    More examples can be found in the libstdc++-v3/testsuite/*/*.cc files.
+Example 6: Compiling and linking a test only for C++14 and later, and only
+if Debug Mode is active:
+<programlisting>
+// { dg-do link { target c++14 } }
+// { dg-require-debug-mode "" }
+</programlisting>
+
+Example 7: Running a test only on x86 targets, and only for C++11 and later,
+with specific options, and additional options for 32-bit x86:
+<programlisting>
+// { dg-options "-fstrict-enums" }
+// { dg-additional-options "-march=i486" { target ia32 } }
+// { dg-do run { target { ia32 || x86_64-*-* } } }
+// { dg-require-effective-target "c++11" }
+</programlisting>
    </para>
+
+   <para>
+    More examples can be found in the
+    <filename>libstdc++-v3/testsuite/*/*.cc</filename> files.
+   </para>
+</section>
+
+<section xml:id="tests.dg.directives"><info><title>Directives Specific to Libstdc++ Tests</title></info>
+
+  <para>
+    In addition to the usual <link
+    xmlns:xlink="http://www.w3.org/1999/xlink";
+    xlink:href="https://gcc.gnu.org/onlinedocs/gccint/Require-support.html";>Variants
+    of <literal>dg-require-<replaceable>support</replaceable></literal></link>
+    several more directives are available for use in libstdc++ tests,
+    including the following:
+   </para>
+
+  <variablelist>
+    <varlistentry><term><literal>dg-require-namedlocale</literal> <replaceable>name</replaceable></term>
+      <listitem><para>The named locale must be available.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-debug-mode ""</literal></term>
+      <listitem><para>Skip the test if the Debug Mode is not active
+	(as determined by the <literal>_GLIBCXX_DEBUG</literal> macro).
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-parallel-mode ""</literal></term>
+      <listitem><para>Skip the test if the Parallel Mode is not active
+	(as determined by the <literal>_GLIBCXX_PARALLEL</literal> macro).
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-profile-mode ""</literal></term>
+      <listitem><para>Skip the test if the Profile Mode is not active
+	(as determined by the <literal>_GLIBCXX_PROFILE</literal> macro).
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-normal-mode ""</literal></term>
+      <listitem><para>Skip the test if any of Debug, Parallel or Profile
+	Mode is active.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-atomic-builtins ""</literal></term>
+      <listitem><para>Skip the test if atomic operations on <type>bool</type>
+      and <type>int</type> are not lock-free.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-gthreads ""</literal></term>
+      <listitem><para>Skip the test if the C++11 thread library is not
+      supported, as determined by the <literal>_GLIBCXX_HAS_GTHREADS</literal>
+      macro.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-gthreads-timed ""</literal></term>
+      <listitem><para>Skip the test if C++11 timed mutexes are not supported,
+      as determined by the <literal>_GLIBCXX_HAS_GTHREADS</literal> and
+      <literal>_GTHREAD_USE_MUTEX_TIMEDLOCK</literal> macros.
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-string-conversions ""</literal></term>
+      <listitem><para>Skip the test if the C++11 <function>to_string</function>
+      and <function>stoi</function>, <function>stod</function> etc. functions
+      are not fully supported (including wide character versions).
+      </para></listitem>
+    </varlistentry>
+    <varlistentry><term><literal>dg-require-filesystem-ts ""</literal></term>
+      <listitem><para>Skip the test if the Filesystem TS is not supported.
+      </para></listitem>
+    </varlistentry>
+  </variablelist>
+</section>
+
 </section>
 
 
 <section xml:id="test.harness" xreflabel="Test Harness and Utilities"><info><title>Test Harness and Utilities</title></info>
 
 
-<section xml:id="test.harness.dejagnu"><info><title>Dejagnu Harness Details</title></info>
+<section xml:id="test.harness.dejagnu"><info><title>DejaGnu Harness Details</title></info>
 
   <para>
     Underlying details of testing for conformance and regressions are
-    abstracted via the GNU Dejagnu package. This is similar to the
+    abstracted via the GNU DejaGnu package. This is similar to the
     rest of GCC.
   </para>
 
 
 <para>This is information for those looking at making changes to the testsuite
-structure, and/or needing to trace dejagnu's actions with --verbose.  This
-will not be useful to people who are "merely" adding new tests to the existing
-structure.
+structure, and/or needing to trace DejaGnu's actions with
+<option>--verbose</option>.
+This will not be useful to people who are "merely" adding new tests
+to the existing structure.
 </para>
 
-<para>The first key point when working with dejagnu is the idea of a "tool".
+<para>The first key point when working with DejaGnu is the idea of a "tool".
 Files, directories, and functions are all implicitly used when they are
 named after the tool in use.  Here, the tool will always be "libstdc++".
 </para>
@@ -665,7 +919,7 @@ our own.  Callbacks must be prefixed with the name of the tool.  To easily
 distinguish the others, by convention our own routines are named "v3-*".
 </para>
 
-<para>The next key point when working with dejagnu is "test files".  Any
+<para>The next key point when working with DejaGnu is "test files".  Any
 directory whose name starts with the tool name will be searched for test files.
 (We have only one.)  In those directories, any <code>.exp</code> file is
 considered a test file, and will be run in turn.  Our main test file is called

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]