Hi Jonathan!
On 2024-07-22T17:28:38+0100, Jonathan Wakely <[email protected]> wrote:
> This adds a new dg-final action to compare two files after a test has
> run, [...]
Nice!
> --- a/libstdc++-v3/testsuite/lib/libstdc++.exp
> +++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
> +# 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
> +}
Via "deficient" GCN and nvptx target testing of my WIP C++ enablement
trees, I ran into a minor nuisance here; OK to push the attached
"Polish libstdc++ 'dg-final' action 'file-io-diff'"?
On a proper target, powerpc64le GNU/Linux, with:
$ echo yo >> libstdc++-v3/testsuite/data/istream_extractor_other-2.tst
... injected just for demonstration purposes (triggering for
'27_io/basic_istream/extractors_other/char/2.cc' one instance of
'FAIL: files differ'), my patch changes 'libstdc++.sum' as follows:
---
build-gcc/powerpc64le-unknown-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum
2024-07-29 17:11:42.333879749 +0200
+++
build-gcc/powerpc64le-unknown-linux-gnu/libstdc++-v3/testsuite/libstdc++.sum
2024-07-29 15:46:27.528214632 +0200
@@ -1,2 +1,2 @@
-Test run by tschwinge on Mon Jul 29 16:53:34 2024
+Test run by tschwinge on Mon Jul 29 15:28:20 2024
Native configuration is powerpc64le-unknown-linux-gnu
@@ -11075,2 +11075,3 @@
PASS: 27_io/basic_filebuf/close/12790-1.cc -std=gnu++17 execution test
+PASS: 27_io/basic_filebuf/close/char/1.cc -std=gnu++17 file-io-diff
filebuf_members-1
PASS: 27_io/basic_filebuf/close/char/1.cc -std=gnu++17 (test for excess
errors)
@@ -11722,2 +11723,4 @@
PASS: 27_io/basic_istream/extractors_other/char/1.cc -std=gnu++17
execution test
+PASS: 27_io/basic_istream/extractors_other/char/2.cc -std=gnu++17
file-io-diff istream_extractor_other-1
+FAIL: 27_io/basic_istream/extractors_other/char/2.cc -std=gnu++17
file-io-diff istream_extractor_other-2
PASS: 27_io/basic_istream/extractors_other/char/2.cc -std=gnu++17 (test
for excess errors)
@@ -11748,2 +11751,4 @@
PASS: 27_io/basic_istream/extractors_other/wchar_t/1.cc -std=gnu++17
execution test
+PASS: 27_io/basic_istream/extractors_other/wchar_t/2.cc -std=gnu++17
file-io-diff wistream_extractor_other-1
+PASS: 27_io/basic_istream/extractors_other/wchar_t/2.cc -std=gnu++17
file-io-diff wistream_extractor_other-2
PASS: 27_io/basic_istream/extractors_other/wchar_t/2.cc -std=gnu++17
(test for excess errors)
@@ -11772,2 +11777,3 @@
PASS: 27_io/basic_istream/get/char/1.cc -std=gnu++17 execution test
+PASS: 27_io/basic_istream/get/char/2.cc -std=gnu++17 file-io-diff
istream_unformatted-1
PASS: 27_io/basic_istream/get/char/2.cc -std=gnu++17 (test for excess
errors)
@@ -11779,2 +11785,3 @@
PASS: 27_io/basic_istream/get/wchar_t/1.cc -std=gnu++17 execution test
+PASS: 27_io/basic_istream/get/wchar_t/2.cc -std=gnu++17 file-io-diff
istream_unformatted-1
PASS: 27_io/basic_istream/get/wchar_t/2.cc -std=gnu++17 (test for excess
errors)
@@ -11812,2 +11819,3 @@
PASS: 27_io/basic_istream/ignore/char/2.cc -std=gnu++17 execution test
+PASS: 27_io/basic_istream/ignore/char/3.cc -std=gnu++17 file-io-diff
istream_unformatted-1
PASS: 27_io/basic_istream/ignore/char/3.cc -std=gnu++17 (test for excess
errors)
@@ -11828,2 +11836,3 @@
PASS: 27_io/basic_istream/ignore/wchar_t/2.cc -std=gnu++17 execution test
+PASS: 27_io/basic_istream/ignore/wchar_t/3.cc -std=gnu++17 file-io-diff
istream_unformatted-1
PASS: 27_io/basic_istream/ignore/wchar_t/3.cc -std=gnu++17 (test for
excess errors)
@@ -11844,2 +11853,3 @@
PASS: 27_io/basic_istream/peek/char/12296.cc -std=gnu++17 execution test
+PASS: 27_io/basic_istream/peek/char/6414.cc -std=gnu++17 file-io-diff
istream_seeks-1
PASS: 27_io/basic_istream/peek/char/6414.cc -std=gnu++17 (test for excess
errors)
@@ -11850,2 +11860,3 @@
PASS: 27_io/basic_istream/peek/wchar_t/12296.cc -std=gnu++17 execution
test
+PASS: 27_io/basic_istream/peek/wchar_t/6414.cc -std=gnu++17 file-io-diff
wistream_seeks-1
PASS: 27_io/basic_istream/peek/wchar_t/6414.cc -std=gnu++17 (test for
excess errors)
@@ -11893,2 +11904,4 @@
PASS: 27_io/basic_istream/seekg/char/exceptions_badbit_throw.cc
-std=gnu++17 execution test
+PASS: 27_io/basic_istream/seekg/char/fstream.cc -std=gnu++17
file-io-diff istream_seeks-1
+PASS: 27_io/basic_istream/seekg/char/fstream.cc -std=gnu++17
file-io-diff istream_seeks-2
PASS: 27_io/basic_istream/seekg/char/fstream.cc -std=gnu++17 (test for
excess errors)
@@ -11907,2 +11920,4 @@
PASS: 27_io/basic_istream/seekg/wchar_t/exceptions_badbit_throw.cc
-std=gnu++17 execution test
+PASS: 27_io/basic_istream/seekg/wchar_t/fstream.cc -std=gnu++17
file-io-diff wistream_seeks-1
+PASS: 27_io/basic_istream/seekg/wchar_t/fstream.cc -std=gnu++17
file-io-diff wistream_seeks-2
PASS: 27_io/basic_istream/seekg/wchar_t/fstream.cc -std=gnu++17 (test for
excess errors)
@@ -11941,2 +11956,4 @@
PASS: 27_io/basic_istream/tellg/char/exceptions_badbit_throw.cc
-std=gnu++17 execution test
+PASS: 27_io/basic_istream/tellg/char/fstream.cc -std=gnu++17
file-io-diff istream_seeks-1
+PASS: 27_io/basic_istream/tellg/char/fstream.cc -std=gnu++17
file-io-diff istream_seeks-2
PASS: 27_io/basic_istream/tellg/char/fstream.cc -std=gnu++17 (test for
excess errors)
@@ -11955,2 +11972,4 @@
PASS: 27_io/basic_istream/tellg/wchar_t/exceptions_badbit_throw.cc
-std=gnu++17 execution test
+PASS: 27_io/basic_istream/tellg/wchar_t/fstream.cc -std=gnu++17
file-io-diff wistream_seeks-1
+PASS: 27_io/basic_istream/tellg/wchar_t/fstream.cc -std=gnu++17
file-io-diff wistream_seeks-2
PASS: 27_io/basic_istream/tellg/wchar_t/fstream.cc -std=gnu++17 (test for
excess errors)
@@ -12026,2 +12045,3 @@
PASS: 27_io/basic_ofstream/native_handle/wchar_t/1.cc -std=gnu++26
execution test
+PASS: 27_io/basic_ofstream/open/char/1.cc -std=gnu++17 file-io-diff
ofstream_members-1
PASS: 27_io/basic_ofstream/open/char/1.cc -std=gnu++17 (test for excess
errors)
@@ -12221,4 +12241,7 @@
PASS: 27_io/basic_ostream/inserters_character/wchar_t/deleted.cc
-std=gnu++26 (test for excess errors)
+PASS: 27_io/basic_ostream/inserters_other/char/1.cc -std=gnu++17
file-io-diff ostream_inserter_other-1
+PASS: 27_io/basic_ostream/inserters_other/char/1.cc -std=gnu++17
file-io-diff ostream_inserter_other-2
PASS: 27_io/basic_ostream/inserters_other/char/1.cc -std=gnu++17 (test
for excess errors)
PASS: 27_io/basic_ostream/inserters_other/char/1.cc -std=gnu++17
execution test
+PASS: 27_io/basic_ostream/inserters_other/char/2.cc -std=gnu++17
file-io-diff ostream_inserter_other_in ostream_inserter_other_out
PASS: 27_io/basic_ostream/inserters_other/char/2.cc -std=gnu++17 (test
for excess errors)
@@ -12255,4 +12278,7 @@
PASS: 27_io/basic_ostream/inserters_other/char/volatile_ptr.cc
-std=gnu++26 execution test
+PASS: 27_io/basic_ostream/inserters_other/wchar_t/1.cc -std=gnu++17
file-io-diff wostream_inserter_other-1
+PASS: 27_io/basic_ostream/inserters_other/wchar_t/1.cc -std=gnu++17
file-io-diff wostream_inserter_other-2
PASS: 27_io/basic_ostream/inserters_other/wchar_t/1.cc -std=gnu++17 (test
for excess errors)
PASS: 27_io/basic_ostream/inserters_other/wchar_t/1.cc -std=gnu++17
execution test
+PASS: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17
file-io-diff wostream_inserter_other_in.txt wostream_inserter_other_out.txt
PASS: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 (test
for excess errors)
@@ -13103,2 +13129,3 @@
PASS: 27_io/ios_base/storage/68197.cc -std=gnu++17 execution test
+PASS: 27_io/ios_base/sync_with_stdio/1.cc -std=gnu++17 file-io-diff
ios_base_members_static-1
PASS: 27_io/ios_base/sync_with_stdio/1.cc -std=gnu++17 (test for excess
errors)
@@ -16601,3 +16628,2 @@
PASS: ext/vstring/types/23767.cc -std=gnu++17 (test for excess errors)
-FAIL: files differ
PASS: special_functions/01_assoc_laguerre/check_nan.cc -std=gnu++17 (test
for excess errors)
@@ -19501,3 +19527,3 @@
-# of expected passes 18615
+# of expected passes 18641
# of unexpected failures 1
Note several instances of 'PASS: [...] file-io-diff [...]' appear, and
the unspecific 'FAIL: files differ' (near the end) turn into specific:
FAIL: 27_io/basic_istream/extractors_other/char/2.cc -std=gnu++17
file-io-diff istream_extractor_other-2
(Again, that FAIL's injected for demonstration purposes only.)
The '*.log' and '*.sum' files also look as expected.
Grüße
Thomas
>From 5309eeb8f74a690711474679b059e52d4f6ab8ca Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <[email protected]>
Date: Mon, 29 Jul 2024 13:32:36 +0200
Subject: [PATCH] Polish libstdc++ 'dg-final' action 'file-io-diff'
Follow-up to recent commit 515da03a838db05443ebcc4c543a405bed764188
"libstdc++: Add file-io-diff to replace @diff@ markup in I/O tests".
Currently, if a 'dg-final' action 'file-io-diff' passes, we print nothing
(should: 'PASS: [...]'), but if it fails, we just print: 'FAIL: files differ',
for example ('*.log' file):
[...]
FAIL: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 (test for excess errors)
[...]
UNRESOLVED: 27_io/basic_ostream/inserters_other/wchar_t/2.cc -std=gnu++17 compilation failed to produce executable
diff: wostream_inserter_other_in.txt: No such file or directory
diff: wostream_inserter_other_out.txt: No such file or directory
FAIL: files differ
diff: wostream_inserter_other_in.txt: No such file or directory
diff: wostream_inserter_other_out.txt: No such file or directory
When later the '*.sum' files get sorted, these 'FAIL: files differ' instances
aren't grouped anymore with the other test cases' results, but they appear en
bloc, lexically sorted between ('e[...]' and 's[...]'), for example:
[...]
PASS: ext/vstring/types/23767.cc -std=gnu++17 (test for excess errors)
FAIL: files differ
FAIL: files differ
FAIL: files differ
PASS: special_functions/01_assoc_laguerre/check_nan.cc -std=gnu++17 (test for excess errors)
[...]
Also, we shouldn't emit the actual 'diff' into the '*.sum' file, but just into
the '*.log* file, and there's no need for 'spawn'/'expect', as we're not
matching any specific messages.
libstdc++-v3/
* testsuite/lib/libstdc++.exp (file-io-diff): Polish.
---
libstdc++-v3/testsuite/lib/libstdc++.exp | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index c11e752ecfb..18331c80bc2 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -1671,6 +1671,8 @@ if { [info exists env(GCC_RUNTEST_PARALLELIZE_DIR)] \
}
+# Utility functions, invoked via dg-final.
+
# 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'.
@@ -1682,6 +1684,10 @@ proc file-io-diff { args } {
if { $nargs > 2 } {
error "too many arguments to file-io-diff"
}
+
+ set testcase [testname-for-summary]
+ set description "$testcase file-io-diff $args"
+
if { $nargs == 1 } {
set file1 [lindex $args 0]
set file2 "${file1}.txt"
@@ -1691,14 +1697,11 @@ proc file-io-diff { args } {
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
- }
+ if { [catch { exec diff -u $file1 $file2 } msg] } {
+ fail $description
+ verbose -log "'diff':\n$msg"
+ } else {
+ pass $description
}
return
}
--
2.34.1