This is the mail archive of the gdb-patches@sourceware.org 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: [patch 4/5] Test cases


On Thursday 17 November 2011 03:26:37, Yao Qi wrote:
> On 11/17/2011 03:04 AM, Pedro Alves wrote:
> >> > +    send_gdb "disconnect\n"
> >> > +    gdb_expect {
> >> > +       -re "warning: Pending tracepoint will not be resolved while GDB is disconnected.*Ending remote debugging.*$gdb_prompt $" {
> >> > +           pass "disconnect with pending tracepoint"
> >> > +       }
> >> > +       -re ".*$gdb_prompt $" {
> >> > +           fail "disconnect with pending tracepoint"
> >> > +       }
> >> > +    }
> > Why send_gdb/gdb_expect?
> 
> Because gdb_test_multiple doesn't match pattern in output when "Ending
> remote debugging" appeared in the output.  We have to resort to
> send_gdb/gdb_expect here.

Hmm, I'm confused.  In this new revision the test is now:

    send_gdb "disconnect\n"
    gdb_expect {
	-re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
	    pass "disconnect with pending tracepoint"

	    send_gdb "y\n"
	}
	timeout {fail "(timeout) disconnect with pending tracepoint"}
    }

No "Ending remote debugging" in sight.  GDB outputs that string
after the "detach anyway" query, so I think gdb_test_multiple
should just work.  Also, we should always make sure to eat the prompt
after the "y", so that it doesn't remain in expect's buffer and
confuse following tests.  Something like:

    set test "disconnect with pending tracepoint"
    gdb_test_multiple "disconnect" $test {
       -re "warning: Pending tracepoints will not be resolved while GDB is disconnected.*Trace is running but will stop on detach; detach anyway\\? \\(y or n\\) $" {
           pass $test

           set test "disconnected"
           gdb_test_multiple "y" $test {
             -re "$gdb_prompt $" {
                pass "$test"
             }
	       }
       }
    }

Note that "$gdb_prompt $" match takes precedence over
gdb_test_multiple's internal "Ending remote debugging.*$gdb_prompt $"
match.

Want to try that?

-- 
Pedro Alves


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