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.
This commit is contained in:
parent
687dc787d7
commit
515da03a83
20 changed files with 130 additions and 56 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue