]> gcc.gnu.org Git - gcc.git/commit
libstdc++: Add support for running tests with multiple -std options
authorJonathan Wakely <jwakely@redhat.com>
Fri, 1 Sep 2023 20:27:57 +0000 (21:27 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 15 Sep 2023 20:57:38 +0000 (21:57 +0100)
commit3a0e01f6bb1d6ec444001f2caea6ef43a4a83e3a
tree852c105156014aa2b7480a926bf79acadc8e7131
parent038c0afa893f8cb2277ff44be3e2c09cfab4bc0c
libstdc++: Add support for running tests with multiple -std options

This copies the code from the compiler's gcc/testsuite/lib/g++-dg.exp so
that each test can be run multiple times, with different -std options.
This means that we can remove most { dg-options "-std=gnu++20" }
directives from tests, because the testsuite will automatically select
a set of -std options that includes that version.

Tests that should only run for a specific standard (e.g. ones that use
something like { dg-do run { target c++11_only } }) should still specify
that standard with { dg-options "-std=gnu++11" }, which overrides the
automatic selection. But a dg-options that selects a newer standard than
the default can be removed, because that standard will be selected
automatically based on a selector like { target c++20 } in the dg-do
directive. This will allow those tests to be run for more than just the
one they currently hardcode, so that e.g. std::format tests can be run
for all of C++20, C++23 and C++26. Currently that has to be done by
adding a second test file that uses a different dg-options line.

By default most tests will continue to run with only the default dialect
(currently -std=gnu++17) so that the time to run the entire testsuite is
not increased. We can revisit this later if increasing the testsuite
time (and coverage) is acceptable. Libstdc++ developers can easily
override the defaults to run for multiple versions. To test all
versions, either add 'set v3_std_list { 98 11 14 17 20 23 26 }' to
~/.dejagnurc or define GLIBCXX_TESTSUITE_STDS="98,11,14,17,20,23,26" in
the environment.

This should be more efficient than the current way to test with multple
standards, i.e. --target_board=unix{-std=c++14,-std=c++17,-std=c++20},
because today all tests with an explicit -std option hardcoded in them
get run for each target board variation but using the exact same
hardcoded -std every time. With the new approach you can just use the
default --target_board=unix and set GLIBCXX_TESTSUITE_STDS="14,17,20"
and now a test that has { target c++20 } will only run once (and be
UNSUPPORTED twice), instead of running with identical options three
times.

In order to support ~/.dejagnurc and $DEJAGNU files that need to work
with versions of GCC without this change, a new variable is added to
site.tmp to detect whether v3_std_list is supported. That allows e.g.

if { [info exists v3-use-std-list] } {
  set v3_std_list { 11 17 23 }
  set target_list { "unix{,-m32}" }
} else {
  set target_list { "unix{,-std=gnu++2b,-std=gnu++11,-m32}" }
}

libstdc++-v3/ChangeLog:

* doc/xml/manual/test.xml: Update documentation on running and
writing tests.
* doc/html/manual/test.html: Regenerate.
* testsuite/Makefile.am: Add v3-use-std-list to site.tmp
* testsuite/Makefile.in: Regenerate.
* testsuite/lib/dg-options.exp (add_options_for_strict_std): New
proc.
* testsuite/lib/libstdc++.exp (search_for): New utility proc.
(v3-dg-runtest): New proc to replace dg-runtest.
* testsuite/libstdc++-dg/conformance.exp: Use v3-dg-runtest.
libstdc++-v3/doc/html/manual/test.html
libstdc++-v3/doc/xml/manual/test.xml
libstdc++-v3/testsuite/Makefile.am
libstdc++-v3/testsuite/Makefile.in
libstdc++-v3/testsuite/lib/dg-options.exp
libstdc++-v3/testsuite/lib/libstdc++.exp
libstdc++-v3/testsuite/libstdc++-dg/conformance.exp
This page took 0.059221 seconds and 5 git commands to generate.