public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Pedro Alves <pedro@palves.net>, Lancelot SIX <lsix@lancelotsix.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 1/2] gdb/testsuite: avoid creating files in gdb/testsuite directory
Date: Tue, 04 Oct 2022 10:08:08 +0100	[thread overview]
Message-ID: <87tu4kez2f.fsf@redhat.com> (raw)
In-Reply-To: <ff8f9c4a-e59b-b2c9-675c-a2d096bc48d9@palves.net>

Pedro Alves <pedro@palves.net> writes:

> On 2022-10-03 5:06 p.m., Andrew Burgess via Gdb-patches wrote:
>> Lancelot SIX <lsix@lancelotsix.com> writes:
>> 
>
>>> Just above your change, there is the following line:
>>>
>>>   set debug_str_section "${binfile}-debug-str"
>>>
>>> I believe that the original intent was to use this as output file name,
>>> but the '$' was use in the set args line.
>>>
>>> It looks to me that the change should be:
>>>
>>>   -set args "--dump-section .debug_str=debug_str_section $binfile"
>>>   +set args "--dump-section .debug_str=$debug_str_section $binfile"
>>>
>>> If you prefer your change, the `set debug_str_section` line should be
>>> removed.
>> 
>> Good spot.
>> 
>> Updated patch below.
>
> I'm glad you guys found this alternative approach.  I was going to suggest
> to see if we could avoid changing directory, the "cd" approach IMO should be
> avoided if possible.  The reason is that when you change gdb's directory to
> the test's output dir, if GDB crashes and produces a core on teardown, then that core will
> end up in the test's output directory, and thus won't be noticed by the spurious core
> detection, i.e., won't be signaled in gdb.sum.

What if I added a mechanism to lib/gdb.exp that allowed for something
like:

  with_change_gdb_directory $some_directory {
    # A set of tests here...
  }

and had the with_change_gdb_directory proc check that GDB was still
running at the end of the block.

This way, when the test script ends, and GDB is shutdown, we will always
be back in the original directory, so a crash on teardown will be
spotted (via the coredump).

And if GDB crashes during the inner block, then yes, the coredump will
be in the "wrong" place, but we should be guaranteed to see a test
failure.

Would something like this be acceptable?

My other idea is to have 'maint selftest' take an extra argument like:

  (gdb) maint selftest --temp-directory /path/to/directory

which would then be used by the individual tests when creating temporary
files.

Thoughts?

Thanks,
Andrew


  parent reply	other threads:[~2022-10-04  9:08 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 [this message]
2022-10-04 12:15           ` Pedro Alves
2022-10-02 14:43 ` [PATCH 2/2] gdb/testsuite: avoid temporary file in gdb/testsuite Andrew Burgess
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=87tu4kez2f.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=lsix@lancelotsix.com \
    --cc=pedro@palves.net \
    /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).