Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: Jan Kratochvil <jan.kratochvil@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [patch] testsuite: Fix a racy FAIL on gdb.base/multi-forks.exp
Date: Fri, 13 Mar 2009 16:47:00 -0000	[thread overview]
Message-ID: <20090313161423.GF8368@adacore.com> (raw)
In-Reply-To: <20090313152723.GA13673@host0.dyn.jankratochvil.net>

I am not very familiar with this testcase, so please consider this
as an informal review. I started looking at this just because I was
actually wondering about the availability of "close"....

> Instead of the output suppression by `close (1)' some sleep would also fix it
> if close (1) is not compatible enough.

As far as I can tell, "close" is POSIX, so should be fairly portable.
I'm not entirely sure about Windows, but I do think it's available.
The symbol name might be _close, though.

That being said, I see later in the same testcase that this problem
is already handled a different way. Basically, we know that the
inferiors are going to print a bunch of traces, so we just wait
for all of them to be printed before we do the next test:

    # The output from the child processes can be interleaved arbitrarily
    # with the output from GDB and the parent process.  If we don't
    # consume it all now, it can confuse later interactions.
    set seen_done 0
    set seen_break 0
    set seen_prompt 0
    set seen_timeout 0
    while { ($seen_done < 16 || ! $seen_prompt) && ! $seen_timeout } {
        # We don't know what order the interesting things will arrive in.
        # Using a pattern of the form 'x|y|z' instead of -re x ... -re y
        # ... -re z ensures that expect always chooses the match that
        # occurs leftmost in the input, and not the pattern appearing
        # first in the script that occurs anywhere in the input, so that
        # we don't skip anything.
        gdb_expect {
            -re "($decimal done)|(Breakpoint)|($gdb_prompt)" {
                if {[info exists expect_out(1,string)]} {
                    incr seen_done
                } elseif {[info exists expect_out(2,string)]} {
                    set seen_break 1
                } elseif {[info exists expect_out(3,string)]} {
                    set seen_prompt 1
                }
                array unset expect_out
            }
            timeout { set seen_timeout 1 }
        }
    }

Would it make sense to do the same in the case where we follow
the child?

On a side note, I try to avoid delays such as "sleep" like the plague.
A one or two second delay on its own is not that bad, but they tend
to add-up pretty quickly. Since our testsuite is sequential, it's time
wasted doing nothing. So I only use them if I don't have any other choice.

-- 
Joel



  reply	other threads:[~2009-03-13 16:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-13 16:01 Jan Kratochvil
2009-03-13 16:47 ` Joel Brobecker [this message]
2009-03-13 21:02   ` Jan Kratochvil
2009-03-13 23:11     ` Joel Brobecker
2009-03-14 21:45       ` Jan Kratochvil
2009-03-14 12:32   ` Eli Zaretskii

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=20090313161423.GF8368@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jan.kratochvil@redhat.com \
    /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