aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3
diff options
context:
space:
mode:
authorJonathan Wakely <jwakely@redhat.com>2023-09-13 10:57:08 +0100
committerJonathan Wakely <jwakely@redhat.com>2023-09-14 13:58:34 +0100
commit9da3c935e3f46e32d9f801f07916634dc9a65886 (patch)
tree6f96fa15db115cc6a8d270195301187a1afca0fd /libstdc++-v3
parentb9b9d0a7db098e2b7e6894dca98ddd551067cad1 (diff)
downloadgcc-9da3c935e3f46e32d9f801f07916634dc9a65886.zip
gcc-9da3c935e3f46e32d9f801f07916634dc9a65886.tar.gz
gcc-9da3c935e3f46e32d9f801f07916634dc9a65886.tar.bz2
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.
Diffstat (limited to 'libstdc++-v3')
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/1-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekoff/char/2-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/1-io.cc4
-rw-r--r--libstdc++-v3/testsuite/27_io/basic_filebuf/seekpos/char/2-io.cc4
-rw-r--r--libstdc++-v3/testsuite/lib/dg-options.exp8
-rw-r--r--libstdc++-v3/testsuite/lib/libstdc++.exp9
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 c812c52..5afa33e 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 <fstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
-// @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 4cfaf68..cd3f765 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 <fstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
-// @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 57eabe3..4566ebd 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 <fstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
-// @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 714c3d6..8500dd5 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 <fstream>
#include <testsuite_hooks.h>
#include <testsuite_io.h>
-// @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 7ee32fb..e4975f3 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 271f877..fde687d 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