From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2181) id 7F1063858024; Thu, 14 Sep 2023 13:27:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7F1063858024 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1694698034; bh=2vg+p7VO5oVmpjUu7pt0H9PSdh1mOJo79v1B5jD3lq4=; h=From:To:Subject:Date:From; b=sXZb/t6RuV3YCyI4RMs6j1rNb0cZcXolTdQL7eLbj+sVZ0gtyhoOcRYeKVmtHLXkD KEPv+g/BsdxzaO0NfUVQkMniWlPeUuGEXev+p9tKLAqS9B6AFlPN0lAu7F7+3HZMKr dNPigj3RVcb1a6yvHE4i/E0MKxDng3tHsaUFuj0Q= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jonathan Wakely To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org Subject: [gcc r14-3991] libstdc++: Support dg-additional-files in tests X-Act-Checkin: gcc X-Git-Author: Jonathan Wakely X-Git-Refname: refs/heads/master X-Git-Oldrev: b9b9d0a7db098e2b7e6894dca98ddd551067cad1 X-Git-Newrev: 9da3c935e3f46e32d9f801f07916634dc9a65886 Message-Id: <20230914132714.7F1063858024@sourceware.org> Date: Thu, 14 Sep 2023 13:27:14 +0000 (GMT) List-Id: https://gcc.gnu.org/g:9da3c935e3f46e32d9f801f07916634dc9a65886 commit r14-3991-g9da3c935e3f46e32d9f801f07916634dc9a65886 Author: Jonathan Wakely Date: Wed Sep 13 10:57:08 2023 +0100 libstdc++: Support dg-additional-files in tests Some tests rely on text files with specific content being present in the test directory. This has historically been done by copying testsuite/data/*.tst and testsuite/data/*.txt to the test dir at the start, in the libstdc++_init procedure. Some tests modify their data files, so if the same test runs more than once in the same directory the second and subsequent tests will see the modified files, and FAIL because the content of the file is not in the expected state. This change adds support for the dg-additional-files directive from the main compiler testsuite and changes v3_target_compile to copy the specified files to the directory where the test will run. This ensures that a fresh copy of the files is present each time the test runs. Eventually all tests could be transitioned to use dg-additional-files and then libstdc++_init could be changed to remove the initial copy of all files. This change only adds dg-additional-files to the tests that modify their files and FAIL when re-run in the same directory. The tests that rely on additional data files have comments containing the strings "@require@" and "@diff@" which seem to be related to the libstdc++-v3/mkcheck.in testing script that was removed in 2003. Those comments can be used to find tests that should be migrated to use the new dg-additional-files support, and then the comments can be removed. libstdc++-v3/ChangeLog: * testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc: Use dg-additional-files. Remove @require@ and @diff@ comments. * testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc: Likewise. * testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc: Likewise. * testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc: Likewise. * testsuite/lib/dg-options.exp (v3_additional_files): New global variable. (dg-additional-files): New proc. * testsuite/lib/libstdc++.exp (v3_target_compile): Copy additional files to test directory. Diff: --- libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc | 4 +--- libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc | 4 +--- libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc | 4 +--- libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc | 4 +--- libstdc++-v3/testsuite/lib/dg-options.exp | 8 ++++++++ libstdc++-v3/testsuite/lib/libstdc++.exp | 9 ++++++++- 6 files changed, 20 insertions(+), 13 deletions(-) diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc index c812c528f26..5afa33e596e 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc @@ -21,14 +21,12 @@ // { dg-require-fileio "" } // { dg-require-binary-io "" } +// { dg-additional-files "seekoff-1io.tst" } #include #include #include -// @require@ %-*.tst %-*.txt -// @diff@ %-*.tst %*.txt - const char name_01[] = "seekoff-1io.tst"; void test05() diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc index 4cfaf68c74e..cd3f765d236 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc @@ -21,14 +21,12 @@ // { dg-require-fileio "" } // { dg-require-binary-io "" } +// { dg-additional-files "seekoff-2io.tst" } #include #include #include -// @require@ %-*.tst %-*.txt -// @diff@ %-*.tst %*.txt - const char name_01[] = "seekoff-2io.tst"; void test05() diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc index 57eabe38214..4566ebd27d9 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc @@ -20,14 +20,12 @@ // 27.8.1.4 Overridden virtual functions // { dg-require-fileio "" } +// { dg-additional-files "seekpos-1io.tst" } #include #include #include -// @require@ %-*.tst %-*.txt -// @diff@ %-*.tst %*.txt - const char name_01[] = "seekpos-1io.tst"; // file with data in it void test05() diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc index 714c3d60d2c..8500dd59df8 100644 --- a/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc +++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc @@ -20,14 +20,12 @@ // 27.8.1.4 Overridden virtual functions // { dg-require-fileio "" } +// { dg-additional-files "seekpos-2io.tst" } #include #include #include -// @require@ %-*.tst %-*.txt -// @diff@ %-*.tst %*.txt - const char name_01[] = "seekpos-2io.tst"; // file with data in it void test05() diff --git a/libstdc++-v3/testsuite/lib/dg-options.exp b/libstdc++-v3/testsuite/lib/dg-options.exp index 7ee32fbbf71..e4975f3e8ba 100644 --- a/libstdc++-v3/testsuite/lib/dg-options.exp +++ b/libstdc++-v3/testsuite/lib/dg-options.exp @@ -373,3 +373,11 @@ proc dg-additional-options { args } { eval lappend extra-tool-flags [lindex $args 1] } } + +set v3_additional_files "" + +# Process a { dg-additional-files "filelist" } directive in the test. +proc dg-additional-files { line filelist } { + global v3_additional_files + set v3_additional_files $filelist +} diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp index 271f8772caf..fde687d8bc1 100644 --- a/libstdc++-v3/testsuite/lib/libstdc++.exp +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp @@ -143,7 +143,8 @@ proc libstdc++_init { testfile } { global dg-do-what-default set dg-do-what-default run - # Copy any required data files. + # Copy all required data files. + # TODO: Use dg-additional-files in individual tests instead of doing this. v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"] v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"] @@ -519,6 +520,12 @@ proc v3_target_compile { source dest type options } { lappend options "compiler=$cxx_final" lappend options "timeout=[timeout_value]" + global v3_additional_files + foreach file [split $v3_additional_files " "] { + global srcdir + v3-copy-file "$srcdir/data/$file" $file + } + set comp_output [target_compile $source $dest $type $options] return $comp_output