Need help adding a test in commands.exp
Daniel Jacobowitz
drow@mvista.com
Mon Jul 29 12:55:00 GMT 2002
On Sat, Jul 27, 2002 at 11:26:21PM -0700, Joel Brobecker wrote:
> I found a bug in GDB, and I have fixed this bug without causing new
> regressions. But I want to add a new test in the commands.exp testcase.
> Here is the output I get from GDB when I run the test manually:
>
> (gdb) b factorial
> Breakpoint 1 at 0x8048506: file ./gdb.base/run.c, line 77.
> (gdb) commands
> Type commands for when breakpoint 1 is hit, one per line.
> End with a line saying just "end".
> >silent
> >printf "factorial command-list executed\n"
> >clear factorial
> >cont
> >end
> (gdb) run 1
> Starting program: [...]/gdb.base/run 1
> factorial command-list executed
> 1
>
> Program exited normally.
> (gdb)
>
> I am attaching a patch to commands.exp. When I run the test using
> "runtest gdb.base/commands.exp", I get all passes except the last one:
>
> PASS: breakpoint in bp_deleted_in_command_test
> PASS: begin commands in bp_deleted_in_command_test
> PASS: add silent command
> PASS: add printf command
> PASS: add clear command
> PASS: add cont command
> PASS: end commands
> FAIL: run factorial until breakpoint (no output)
>
> I don't undestand why I don't get any output from the "run 1" command
> that I sent to GDB. I tried running runtest with "-v", but did not find
> any useful information there. It must be something pretty silly, but
> I am not very familiar with dejagnu nor tcl.
>
> Any idea?
Welcome to the wonderful world of expect.
I recommend using "exp_internal 1" right before the problematic test;
this will tell you what sort of matching expect is doing.
"exp_internal 0" can turn it off again.
The particular problem here is:
> + send_gdb "run 1\n"
> + gdb_expect {
> + -re ".*factorial command-list executed.*1.*Program exited normally.*" {
> + pass "run factorial until breakpoint"
> + }
> + -re "" { fail "run factorial until breakpoint (no output)" }
> + timeout { fail "(timeout) run factorial until breakpoint" }
> + }
"" matches immediately, before the output has been produced. You
should explicitly match $gdb_prompt (which requires declaring it
global).
There's some other problems here; you can't just send a "run" in the
testsuite, and you can't require that the program accept arguments.
Look for gdb_continue (I think) and a flag in the board description
which describes whether argument passing works.
--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
More information about the Gdb-patches
mailing list