This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA/testsuite] Workaround timeout in default.exp


On Tue, May 18, 2004 at 02:01:47PM -0700, Joel Brobecker wrote:
> This is a problem that has been bugging me on AIX for as long as I can
> remember: default.exp on AIX was taking hours to complete. So far, I've
> just worked-around the problem by deactivating this test on that
> platform, always postponing the task of looking at the source of the
> problem for later.
> 
> Turns out we have two commands that have the gdb prompt in their
> output, and this is somehow confusing test_gdb and test_gdb_multiple
> into a timeout. I couldn't understand exactly why this was happening
> for lack of time. I'm wondering if this might be an expect or dejagnu
> bug, as it works fine on x86-linux for instance...
> 
> The attached patch works-around the problem by using the send_gdb and
> gdb_expect pair instead of test_gdb. This short-circuits the smart
> machinery behind test_gdb, and allows runtest to match the output
> from the 2 commands correctly. With this patch, the testscase completes
> successfully within a reasonable amount of time.
> 
> I added some comments explaining what was happening with test_gdb and
> why we use send_gdb and gdb_expect instead, to make it clear why I made
> this change.
> 
> 2004-05-18  J. Brobecker  <brobecker@gnat.com>
> 
> 	* gdb.base/default.exp: Rewrite a couple of tests to work-around
> 	a problem that causes this test and all the following tests to
> 	timeout.
> 
> Tested on AIX 5.1 and x86-linux. Would that be OK to apply?

Rather than adding a FIXME, let me try to explain what is going on.

The first part is a guess.  For some reason, the pattern "\(gdb\) $"
never matches on GNU/Linux but does on AIX and Solaris.  I presume this
is because of some difference in the pseudo-TTY layer or in the
standard I/O library, which causes characters to be send in smaller
batches.  So at some point on those systems, the buffer ends with the
prompt.

So the second part is how to prevent the prompt pattern from matching. 
The way to do it is use gdb_test_multiple, and add an explicit
condition for the text which comes _before_ the extra prompt.

I'm doing this from memory, so it will need some adjustment, but you
can do it sort of like this.  The "global" lines may not be necessary,
so try without them.

global saw_good_text
set saw_good_text 0

gdb_test_multiple "command" "test name" {
  -re "long\ngood\ntext\nwithout\ntrailing dot, star, or prompt" {
    global saw_good_text
    set saw_good_text 1
    exp_continue
  }
  -re "prompt is \"$gdb_prompt" {
    exp_continue
  }
  -re "$gdb_prompt $" {
    global saw_good_text
    if {$saw_good_text} {
      pass "test name"
    } else {
      fail "test name (unknown output)"
    }
  }
}

This makes sure to consume both the bad prompt and the good prompt.

-- 
Daniel Jacobowitz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]