https://gcc.gnu.org/g:515da03a838db05443ebcc4c543a405bed764188

commit r15-2248-g515da03a838db05443ebcc4c543a405bed764188
Author: Jonathan Wakely <jwak...@redhat.com>
Date:   Mon Jul 22 14:39:57 2024 +0100

    libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests
    
    This adds a new dg-final action to compare two files after a test has
    run, so that we can verify that fstream operations produce the expected
    results. With this change, all uses of @diff@ that seem potentially
    useful have been converted to actually compare the files and FAIL if
    they differ.
    
    The file-io-diff action can take two arguments naming the files to be
    compared, or for convenience it can take a single string and will
    compare STR.tst and STR.txt, as that's how it's commonly used.
    
    Additionally, all remaining uses of @require@ are converted to
    dg-additional-files directives, so that the TODO in libstdc++.exp can
    be resolved.
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/27_io/basic_filebuf/close/char/1.cc: Remove
            @require@ and @diff@. Use dg-final file-io-diff action.
            * testsuite/27_io/basic_istream/extractors_other/char/2.cc:
            Likewise.
            * testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc:
            Likewise.
            * testsuite/27_io/basic_istream/get/char/2.cc: Likewise.
            * testsuite/27_io/basic_istream/get/wchar_t/2.cc: Likewise.
            * testsuite/27_io/basic_istream/ignore/char/3.cc: Likewise.
            * testsuite/27_io/basic_istream/ignore/wchar_t/3.cc: Likewise.
            * testsuite/27_io/basic_istream/peek/char/6414.cc: Likewise.
            * testsuite/27_io/basic_istream/peek/wchar_t/6414.cc: Likewise.
            * testsuite/27_io/basic_istream/seekg/char/fstream.cc: Likewise.
            * testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc:
            Likewise.
            * testsuite/27_io/basic_istream/tellg/char/fstream.cc: Likewise.
            * testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc:
            Likewise.
            * testsuite/27_io/basic_ofstream/open/char/1.cc: Likewise.
            * testsuite/27_io/basic_ostream/inserters_other/char/1.cc:
            Likewise.
            * testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc:
            Likewise.
            * testsuite/27_io/ios_base/sync_with_stdio/1.cc: Likewise.
            * testsuite/27_io/basic_ostream/inserters_other/char/2.cc:
            Likewise. Check file positions.
            * testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc:
            Likewise.
            * testsuite/lib/libstdc++.exp (file-io-diff): New proc.

Diff:
---
 .../testsuite/27_io/basic_filebuf/close/char/1.cc  |  6 ++--
 .../27_io/basic_istream/extractors_other/char/2.cc |  9 ++++--
 .../basic_istream/extractors_other/wchar_t/2.cc    |  9 ++++--
 .../testsuite/27_io/basic_istream/get/char/2.cc    |  8 ++++--
 .../testsuite/27_io/basic_istream/get/wchar_t/2.cc |  8 ++++--
 .../testsuite/27_io/basic_istream/ignore/char/3.cc |  8 ++++--
 .../27_io/basic_istream/ignore/wchar_t/3.cc        |  8 ++++--
 .../27_io/basic_istream/peek/char/6414.cc          |  9 ++++--
 .../27_io/basic_istream/peek/wchar_t/6414.cc       |  9 ++++--
 .../27_io/basic_istream/seekg/char/fstream.cc      | 10 +++++--
 .../27_io/basic_istream/seekg/wchar_t/fstream.cc   | 12 +++++---
 .../27_io/basic_istream/tellg/char/fstream.cc      | 10 +++++--
 .../27_io/basic_istream/tellg/wchar_t/fstream.cc   | 10 +++++--
 .../testsuite/27_io/basic_ofstream/open/char/1.cc  |  5 ++--
 .../27_io/basic_ostream/inserters_other/char/1.cc  |  8 ++++--
 .../27_io/basic_ostream/inserters_other/char/2.cc  |  7 +++--
 .../basic_ostream/inserters_other/wchar_t/1.cc     |  8 ++++--
 .../basic_ostream/inserters_other/wchar_t/2.cc     |  7 +++--
 .../testsuite/27_io/ios_base/sync_with_stdio/1.cc  |  5 ++--
 libstdc++-v3/testsuite/lib/libstdc++.exp           | 32 ++++++++++++++++++++++
 20 files changed, 131 insertions(+), 57 deletions(-)

diff --git a/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc 
b/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc
index e2b336a711d6..d9e9c53e3e6e 100644
--- a/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_filebuf/close/char/1.cc
@@ -15,14 +15,14 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.8.1.3 filebuf member functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.8.1.3 filebuf member functions
 
 // various tests for filebuf::open() and filebuf::close() including
 // the non-portable functionality in the libstdc++-v3 IO library
 
 // { dg-require-fileio "" }
+// { dg-additional-files "filebuf_members-1.tst filebuf_members-1.txt" }
+// { dg-final { file-io-diff "filebuf_members-1" } }
 
 #include <fstream>
 #include <testsuite_hooks.h>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc
index 589402308c30..77543310caa3 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/char/2.cc
@@ -17,11 +17,14 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.2.3 basic_istream::operator>>
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.2.3 basic_istream::operator>>
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_extractor_other-1.tst" }
+// { dg-additional-files "istream_extractor_other-1.txt" }
+// { dg-additional-files "istream_extractor_other-2.tst" }
+// { dg-final { file-io-diff "istream_extractor_other-1" } }
+// { dg-final { file-io-diff "istream_extractor_other-2" } }
 
 #include <istream>
 #include <fstream>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc
index b50dd26513a9..82df1a17149d 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/extractors_other/wchar_t/2.cc
@@ -15,11 +15,14 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.2.3 basic_istream::operator>>
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.2.3 basic_istream::operator>>
 
 // { dg-require-fileio "" }
+// { dg-additional-files "wistream_extractor_other-1.tst" }
+// { dg-additional-files "wistream_extractor_other-1.txt" }
+// { dg-additional-files "wistream_extractor_other-2.tst" }
+// { dg-final { file-io-diff "wistream_extractor_other-1" } }
+// { dg-final { file-io-diff "wistream_extractor_other-2" } }
 
 #include <istream>
 #include <fstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc
index cf646f379efb..95bad8badb90 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/char/2.cc
@@ -17,11 +17,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
 
 #include <istream>
 #include <sstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc
index 0ea162d8171b..c155e402e2c8 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/get/wchar_t/2.cc
@@ -15,11 +15,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
 
 #include <istream>
 #include <sstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc
index 222e450e9c84..acfafbcd83b1 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/char/3.cc
@@ -17,11 +17,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
 
 #include <istream>
 #include <fstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc
index c9e942a712c5..60c2655b6066 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/ignore/wchar_t/3.cc
@@ -15,11 +15,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.1.3 unformatted input functions
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_unformatted-1.tst" }
+// { dg-additional-files "istream_unformatted-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_unformatted-1" } }
 
 #include <istream>
 #include <fstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc
index 0e0b44153a8e..ffa0e88d8eb9 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/char/6414.cc
@@ -17,10 +17,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
 // NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+
+// { dg-additional-files "istream_seeks-1.tst" }
+// { dg-additional-files "istream_seeks-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "istream_seeks-1" } }
 
 #include <istream>
 #include <fstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc
index fbfbfbb27816..0d2172fe85d6 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/peek/wchar_t/6414.cc
@@ -15,10 +15,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
 // NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+
+// { dg-additional-files "wistream_seeks-1.tst" }
+// { dg-additional-files "wistream_seeks-1.txt" }
+// Reading the .txt file should not alter it:
+// { dg-final { file-io-diff "wistream_seeks-1" } }
 
 #include <istream>
 #include <fstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc
index 0fa91a2716bf..52401ca88fdf 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/char/fstream.cc
@@ -17,12 +17,16 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
 // NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_seeks-1.tst" }
+// { dg-additional-files "istream_seeks-1.txt" }
+// { dg-additional-files "istream_seeks-2.tst" }
+// Do not create istream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "istream_seeks-1" } }
+// { dg-final { file-io-diff "istream_seeks-2" } }
 
 #include <istream>
 #include <sstream>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc
index b792c8bc5cc8..6dc69d57516b 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/seekg/wchar_t/fstream.cc
@@ -16,11 +16,15 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-require-fileio "" }
-
-// 27.6.1.3 unformatted input functions
+// { dg-additional-files "wistream_seeks-1.tst" }
+// { dg-additional-files "wistream_seeks-1.txt" }
+// { dg-additional-files "wistream_seeks-2.tst" }
+// Do not create wistream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "wistream_seeks-1" } }
+// { dg-final { file-io-diff "wistream_seeks-2" } }
+
+// C++98 27.6.1.3 unformatted input functions
 // NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
 
 #include <istream>
 #include <sstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc
index a1eabd6abb40..8ab130a0a718 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/char/fstream.cc
@@ -17,12 +17,16 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
 // NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
 
 // { dg-require-fileio "" }
+// { dg-additional-files "istream_seeks-1.tst" }
+// { dg-additional-files "istream_seeks-1.txt" }
+// { dg-additional-files "istream_seeks-2.tst" }
+// Do not create istream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "istream_seeks-1" } }
+// { dg-final { file-io-diff "istream_seeks-2" } }
 
 #include <istream>
 #include <sstream>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc 
b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc
index 636193af7e34..b22871f0d7de 100644
--- a/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_istream/tellg/wchar_t/fstream.cc
@@ -16,11 +16,15 @@
 // <http://www.gnu.org/licenses/>.
 
 // { dg-require-fileio "" }
+// { dg-additional-files "wistream_seeks-1.tst" }
+// { dg-additional-files "wistream_seeks-1.txt" }
+// { dg-additional-files "wistream_seeks-2.tst" }
+// Do not create wistream_seeks-2.txt, we want it to be created as empty.
+// { dg-final { file-io-diff "wistream_seeks-1" } }
+// { dg-final { file-io-diff "wistream_seeks-2" } }
 
-// 27.6.1.3 unformatted input functions
+// C++98 27.6.1.3 unformatted input functions
 // NB: ostream has a particular "seeks" category. Adopt this for istreams too.
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
 
 #include <istream>
 #include <sstream>
diff --git a/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc 
b/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc
index 45227107cbd9..a9086a595cb1 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ofstream/open/char/1.cc
@@ -17,10 +17,9 @@
 
 // C++98 27.8.1.10 ofstream member functions
 
-// { dg-additional-files "ofstream_members-1.tst" }
-// @diff@ %-*.tst %-*.txt
-
 // { dg-require-fileio "" }
+// { dg-additional-files "ofstream_members-1.tst" }
+// { dg-final { file-io-diff "ofstream_members-1" } }
 
 #include <ostream>
 #include <fstream>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/1.cc 
b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/1.cc
index 6d30d0ce94f6..86a0ee8e77d0 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/1.cc
@@ -18,11 +18,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
 
 // { dg-require-fileio "" }
+// { dg-additional-files "ostream_inserter_other-1.tst" }
+// { dg-additional-files "ostream_inserter_other-2.tst" }
+// { dg-final { file-io-diff "ostream_inserter_other-1" } }
+// { dg-final { file-io-diff "ostream_inserter_other-2" } }
 
 #include <ostream>
 #include <sstream>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/2.cc 
b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/2.cc
index 15f0d5f7b0bf..735f2e20e9c9 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/char/2.cc
@@ -18,9 +18,9 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
+
+// { dg-final { file-io-diff "ostream_inserter_other_in" 
"ostream_inserter_other_out" } }
 
 #include <ostream>
 #include <fstream>
@@ -56,6 +56,7 @@ test03(void)
   out.seekp(0, ios_base::end);
   i_read = in.tellg() - rs;
   i_wrote = out.tellp() - ws;
+  VERIFY( i_read == i_wrote );
   in.close();
   out.close();
 }
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc 
b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc
index 7692637e16d6..1aecfa4f0e90 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/1.cc
@@ -15,11 +15,13 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
 
 // { dg-require-fileio "" }
+// { dg-additional-files "wostream_inserter_other-1.tst" }
+// { dg-additional-files "wostream_inserter_other-2.tst" }
+// { dg-final { file-io-diff "wostream_inserter_other-1" } }
+// { dg-final { file-io-diff "wostream_inserter_other-2" } }
 
 #include <ostream>
 #include <sstream>
diff --git 
a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc 
b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc
index 856af56011ac..663539a5b193 100644
--- a/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc
+++ b/libstdc++-v3/testsuite/27_io/basic_ostream/inserters_other/wchar_t/2.cc
@@ -15,9 +15,9 @@
 // with this library; see the file COPYING3.  If not see
 // <http://www.gnu.org/licenses/>.
 
-// 27.6.2.5.4 basic_ostream character inserters
-// @require@ %-*.tst %-*.txt
-// @diff@ %-*.tst %-*.txt
+// C++98 27.6.2.5.3 basic_ostream inserters
+
+// { dg-final { file-io-diff "wostream_inserter_other_in.txt" 
"wostream_inserter_other_out.txt" } }
 
 #include <ostream>
 #include <fstream>
@@ -53,6 +53,7 @@ test03(void)
   out.seekp(0, ios_base::end);
   i_read = in.tellg() - rs;
   i_wrote = out.tellp() - ws;
+  VERIFY( i_read == i_wrote );
   in.close();
   out.close();
 }
diff --git a/libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc 
b/libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc
index 4f9f7c3e554a..20cbc1e08cd5 100644
--- a/libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc
+++ b/libstdc++-v3/testsuite/27_io/ios_base/sync_with_stdio/1.cc
@@ -20,8 +20,9 @@
 // <http://www.gnu.org/licenses/>.
 
 // 27.4.2.4 ios_base static members
-// @require@ %-*.tst
-// @diff@ %-*.tst %-*.txt
+
+// { dg-additional-files "ios_base_members_static-1.tst" }
+// { dg-final { file-io-diff "ios_base_members_static-1" } }
 
 #include <cstdio>
 #include <sstream>
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp 
b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 8efc6f7f0899..ef511949c7bc 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1674,3 +1674,35 @@ if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
     }
 
 }
+
+# Compare output file written by test to expected result.
+# With two arguments the comparison is done via 'diff arg1 arg2'.
+# With one argument the comparison is done via 'diff arg1.tst arg1.txt'.
+proc file-io-diff { args } {
+    set nargs [llength $args]
+    if { $nargs < 1 } {
+       error "too few arguments to file-io-diff"
+    }
+    if { $nargs > 2 } {
+       error "too many arguments to file-io-diff"
+    }
+    if { $nargs == 1 } {
+       set file1 [lindex $args 0]
+       set file2 "${file1}.txt"
+       append file1 ".tst"
+    } else {
+       set file1 [lindex $args 0]
+       set file2 [lindex $args 1]
+    }
+
+    spawn -noecho diff -u $file1 $file2
+    expect {
+      -re ".+" {
+       set msg "files differ\n"
+       append msg $expect_out(0,string)
+       fail $msg
+       exp_continue
+      }
+    }
+    return
+}

Reply via email to