public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 2/2] gdb/testsuite: avoid temporary file in gdb/testsuite
Date: Sun,  2 Oct 2022 15:43:57 +0100	[thread overview]
Message-ID: <47ee286ceedb3b59347e43743ecd1e2b0c0873be.1664721741.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1664721741.git.aburgess@redhat.com>

I spotted that the gdb.gdb/unittest.exp script causes a temporary file
inserters_extractors-2.txt to be created in build/gdb/testsuite/
instead of in build/gdb/testsuite/output/gdb.gdb/unittest/.

This is because some of the 'maint selftest' tests create temporary
files in GDB's current directory, specifically, the two source files:

  gdb/unittests/basic_string_view/inserters/wchar_t/2.cc
  gdb/unittests/basic_string_view/inserters/char/2.cc

both create a temporary file called inserters_extractors-2.txt, though
we only run the second of these as part of GDB's selftests.

I propose that in the gdb.gdb/unittest.exp we change GDB's current
working directory to be the output directory for the specific test,
that way the temporary file will be created in the correct place.

After this change all the tests continue to pass, and the temporary
file is no longer left in gdb/testsuite/.
---
 gdb/testsuite/gdb.gdb/unittest.exp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp
index 2967b994cc3..a60cd70a259 100644
--- a/gdb/testsuite/gdb.gdb/unittest.exp
+++ b/gdb/testsuite/gdb.gdb/unittest.exp
@@ -40,6 +40,14 @@ proc run_selftests { binfile } {
 	clean_restart ${binfile}
     }
 
+    # Some of the selftests create temporary files in GDB's current
+    # directory.  So, while running the selftests, switch to the
+    # test's output directory to avoid leaving clutter in the
+    # gdb/testsuite root directory.
+    set dir [standard_output_file ""]
+    gdb_test "cd $dir" "Working directory $dir\\." \
+	"switch to test output directory"
+
     set enabled 1
     set test "maintenance selftest"
     gdb_test_multiple $test $test {
-- 
2.25.4


  parent reply	other threads:[~2022-10-02 14:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 14:43 [PATCH 0/2] Cleanup testsuite temporary files Andrew Burgess
2022-10-02 14:43 ` [PATCH 1/2] gdb/testsuite: avoid creating files in gdb/testsuite directory Andrew Burgess
2022-10-03 11:12   ` Lancelot SIX
2022-10-03 16:06     ` Andrew Burgess
2022-10-03 18:51       ` Pedro Alves
2022-10-04  8:55         ` Andrew Burgess
2022-10-04  9:08         ` Andrew Burgess
2022-10-04 12:15           ` Pedro Alves
2022-10-02 14:43 ` Andrew Burgess [this message]
2022-10-04 14:20 ` [PATCHv2 0/2] Cleanup testsuite temporary files Andrew Burgess
2022-10-04 14:20   ` [PATCHv2 1/2] gdb/testsuite: avoid creating files in gdb/testsuite directory Andrew Burgess
2022-10-04 14:20   ` [PATCHv2 2/2] gdb/testsuite: avoid temporary file in gdb/testsuite (unittest.exp) Andrew Burgess
2022-10-14 16:28   ` [PATCHv2 0/2] Cleanup testsuite temporary files Tom Tromey
2022-10-19 11:20     ` Andrew Burgess

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=47ee286ceedb3b59347e43743ecd1e2b0c0873be.1664721741.git.aburgess@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.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).