public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org
Subject: [PATCH 14/13] libstdc++: Re-initialize static data files used by tests
Date: Tue, 12 Sep 2023 14:39:52 +0100	[thread overview]
Message-ID: <20230912134044.1993413-1-jwakely@redhat.com> (raw)
In-Reply-To: <CACb0b4=-ag4800mGjrdWm+fHR77oTH6QVnPA5Pm-FqFdhhHxEQ@mail.gmail.com>

This fixes the problem observed with some filebuf tests.

The "@require@" string seems a bit hacky, as I don't know why that
string is in the tests in the first palce ... but it is there, so this
works.

-- > 8--

Some tests rely on text files with specific content being present in the
test directory. Because the tests modify those files, running the same
test more than once in the same directory will FAIL because the content
of the file is not in the expected state.

This uses a "@require@" marker that happens to be present in those tests
to decide when we need to copy the original files into the test dir
again, so that repeated tests always see the initial file content.

libstdc++-v3/ChangeLog:

	* testsuite/lib/libstdc++.exp (v3-init-data-files): New proc.
	(libstdc++_init): Use v3-init-data-files.
	(v3-dg-runtest): Use v3-init-data-files to update test data
	files for repeated tests.
---
 libstdc++-v3/testsuite/lib/libstdc++.exp | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/libstdc++-v3/testsuite/lib/libstdc++.exp b/libstdc++-v3/testsuite/lib/libstdc++.exp
index 2c497707184..daace4c1d59 100644
--- a/libstdc++-v3/testsuite/lib/libstdc++.exp
+++ b/libstdc++-v3/testsuite/lib/libstdc++.exp
@@ -102,6 +102,12 @@ proc v3-copy-files {srcfiles} {
     }
 }
 
+proc v3-init-data-files { } {
+    global srcdir
+    v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
+    v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
+}
+
 # Called once, during runtest.exp setup.
 proc libstdc++_init { testfile } {
     global env
@@ -159,8 +165,7 @@ proc libstdc++_init { testfile } {
     set dg-do-what-default run
 
     # Copy any required data files.
-    v3-copy-files [glob -nocomplain "$srcdir/data/*.tst"]
-    v3-copy-files [glob -nocomplain "$srcdir/data/*.txt"]
+    v3-init-data-files
 
     set ld_library_path_tmp ""
 
@@ -556,11 +561,26 @@ proc v3-dg-runtest { testcases flags default-extra-flags } {
 	    set option_list { "" }
 	}
 
+	# Some tests (e.g. 27_io/basic_filebuf/seek{off,pos}/char/[12]-io.cc)
+	# rely on text files with specific data being present in the test dir.
+	# Because the tests modify those files, running the same test a second
+	# time will FAIL due to the files not being in their initial state.
+	# We rely on the fact that those files contain a "@require@" comment
+	# to trigger creating fresh copies of the files for repeated tests.
+	if [search_for $test "@require@"] {
+	    set need_fresh_data_files [llength $option_list]
+	} else {
+	    set need_fresh_data_files 0
+	}
+
 	set nshort [file tail [file dirname $test]]/[file tail $test]
 
 	foreach flags_t $option_list {
 	    verbose "Testing $nshort, $flags $flags_t" 1
 	    dg-test $test "$flags $flags_t" ${default-extra-flags}
+	    if { $need_fresh_data_files > 1 } {
+		v3-init-data-files
+	    }
 	}
     }
 }
-- 
2.41.0


  reply	other threads:[~2023-09-12 13:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-11 16:16 [PATCH 00/13] libstdc++: Add support for running tests with multiple -std options Jonathan Wakely
2023-09-11 16:16 ` [PATCH 01/13] " Jonathan Wakely
2023-09-11 16:16 ` [PATCH 02/13] libstdc++: Replace dg-options "-std=c++11" with dg-add-options strict_std Jonathan Wakely
2023-09-11 16:16 ` [PATCH 03/13] libstdc++: Replace dg-options "-std=c++17" " Jonathan Wakely
2023-09-11 16:16 ` [PATCH 04/13] libstdc++: Replace dg-options "-std=c++20" " Jonathan Wakely
2023-09-11 16:16 ` [PATCH 05/13] libstdc++: Remove dg-options "-std=c++20" from <span> and <cuchar> tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 06/13] libstdc++: Remove dg-options "-std=gnu++20" from <concepts> and <ranges> tests Jonathan Wakely
2023-09-15 20:54   ` [PATCH v2 6/13] " Jonathan Wakely
2023-09-11 16:16 ` [PATCH 07/13] libstdc++: Remove dg-options "-std=gnu++2a" from constrained algo tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 08/13] libstdc++: Remove dg-options "-std=gnu++20" from std::format tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 09/13] libstdc++: Remove dg-options "-std=gnu++20" from std::chrono tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 10/13] libstdc++: Remove dg-options "-std=gnu++23" from std::expected tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 11/13] libstdc++: Remove dg-options "-std=gnu++23" from remaining tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 12/13] libstdc++: Remove dg-options "-std=gnu++2a" from XFAIL std::span tests Jonathan Wakely
2023-09-11 16:16 ` [PATCH 13/13] libstdc++: Simplify dejagnu directives for some tests using threads Jonathan Wakely
2023-09-12 13:05 ` [PATCH 00/13] libstdc++: Add support for running tests with multiple -std options Jonathan Wakely
2023-09-12 13:39   ` Jonathan Wakely [this message]
2023-09-15 23:04 ` Jonathan Wakely

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230912134044.1993413-1-jwakely@redhat.com \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).