Fix gdb.linespec/explicit.exp

Message ID 1485552639-18470-1-git-send-email-lgustavo@codesourcery.com
State New, archived
Headers

Commit Message

Luis Machado Jan. 27, 2017, 9:30 p.m. UTC
  I was chasing the cause of a few timeouts in this testcase (both on my local
machine, Ubuntu 16.04 x86-64, and on a aarch64-elf board) and managed to track
it down to this particular test:

	set tst "complete unique function name"
	send_gdb "break -function mai\t"
	gdb_test_multiple "" $tst {
	    "break -function mai\\\x07n " {
		send_gdb "\n"
		gdb_test "" ".*Breakpoint \[0-9\]+.*" $tst
		gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint"
	    }
	}

FAIL: gdb.linespec/explicit.exp: complete unique function name (timeout)
FAIL: gdb.linespec/explicit.exp: complete non-unique function name (timeout)
FAIL: gdb.linespec/explicit.exp: complete non-existant function name (timeout)
FAIL: gdb.linespec/explicit.exp: complete unique file name (timeout)
FAIL: gdb.linespec/explicit.exp: complete non-unique file name (timeout)

There are 2 problems.

The first one is that i couldn't see the hex character x07 being ouput in both
of the above systems for this particular test. There is really only one
possible completion result for the main function. Maybe this character is
output in other systems?

So i started playing around with the regular expression to make x07 optional,
but no matter what pattern i used, it just didn't match.

It was then that i noticed we're missing a leading "-re" before the
gdb_test_multiple pattern to be matched, the second problem. I checked the
documentation for the command and did not find anything about the use
without "-re".

Keith, is this an oversight or did you really intend to use this construct?

In case of an oversight, i've fixed the other occurrences in
gdb.linespec/explicit.exp.

After the adjustments, i've made x07 optional like so:

"break -function mai\[\x07\]*n "

Even though the escaping is different, i checked the expect debug output to
make sure the same \u0007 character is being expected.

gdb/testsuite/ChangeLog

2017-01-27  Luis Machado  <lgustavo@codesourcery.com>

	* gdb.linespec/explicit.exp: Fix gdb_test_multiple calls missing
	the -re switch.
	Make the x07 character optional in the unique function name completion
	test.
---
 gdb/testsuite/gdb.linespec/explicit.exp | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)
  

Comments

Luis Machado Jan. 30, 2017, 8:46 p.m. UTC | #1
On 01/30/2017 02:32 PM, Keith Seitz wrote:
> On 01/27/2017 01:30 PM, Luis Machado wrote:
>>
>> Keith, is this an oversight or did you really intend to use this construct?
>>
>
> I think I remember something about this from Sandra... I spent some time
> tracking this down, and IIRC, this was attributed to some sloppy test
> writing. The hex character is "output" whenever we have multiple
> matches. On my machine, "mai" gave multiple matches. On others it did
> not. So somewhere, sometime in the past, I had a patch lying around to
> ensure that we had multiple (or unique) matches entirely within our test
> program, i.e., stopped testing main() in favor of
> "my_unique_test_function" or some such silliness.
>
> Again, all that *if* I remember correctly, and that's a might big "if"
> nowadays!
>

It sounds reasonable to assume the lack of -re was an oversight from the 
past then.

>> In case of an oversight, i've fixed the other occurrences in
>> gdb.linespec/explicit.exp.
>>
>> After the adjustments, i've made x07 optional like so:
>>
>> "break -function mai\[\x07\]*n "
>
> I would think "?" would be (minutely) more appropriate than "*," but the
> same is accomplished. In the end, that's all that really matters.

Yeah. I thought about this after submitting it.

>
> I've tried this patch locally, and there is a problem on my local machine:
>
> break -function mai^GnFAIL: gdb.linespec/explicit.exp: complete unique
> function name (timeout)
>
> I'm not 100% sure what's going on, but the following revision fixes this:
>
> diff --git a/gdb/testsuite/gdb.linespec/explicit.exp
> b/gdb/testsuite/gdb.linespec/explicit.exp
> index 6a44bd1..e680a2e 100644
> --- a/gdb/testsuite/gdb.linespec/explicit.exp
> +++ b/gdb/testsuite/gdb.linespec/explicit.exp
> @@ -187,7 +187,7 @@ namespace eval $testfile {
>  	set tst "complete unique function name"
>  	send_gdb "break -function mai\t"
>  	gdb_test_multiple "" $tst {
> -	    -re "break -function mai\[\x07\]*n " {
> +	    -re "break -function mai(\\\x07)?n" {
>  		send_gdb "\n"
>  		gdb_test "" ".*Breakpoint \[0-9\]+.*" $tst
>  		gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint"
>
> Seems like the trailing whitespace that I see when running this manually
> isn't liked by the automated test suite run. For some reason. Yikes.

Thanks for the feedback. I've now adjusted the regular expression to 
match the above. I get full passes as well.

I'll send an updated version soon.
  

Patch

diff --git a/gdb/testsuite/gdb.linespec/explicit.exp b/gdb/testsuite/gdb.linespec/explicit.exp
index 637f476..6a44bd1 100644
--- a/gdb/testsuite/gdb.linespec/explicit.exp
+++ b/gdb/testsuite/gdb.linespec/explicit.exp
@@ -154,7 +154,7 @@  namespace eval $testfile {
 	    set tst "complete 'break -$abbrev'"
 	    send_gdb "break -${abbrev}\t"
 	    gdb_test_multiple "" $tst {
-		"break -$full " {
+		-re "break -$full " {
 		    send_gdb "\n"
 		    gdb_test_multiple "" $tst {
 			-re "missing argument for \"-$full\".*$gdb_prompt " {
@@ -187,7 +187,7 @@  namespace eval $testfile {
 	set tst "complete unique function name"
 	send_gdb "break -function mai\t"
 	gdb_test_multiple "" $tst {
-	    "break -function mai\\\x07n" {
+	    -re "break -function mai\[\x07\]*n " {
 		send_gdb "\n"
 		gdb_test "" ".*Breakpoint \[0-9\]+.*" $tst
 		gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint"
@@ -197,7 +197,7 @@  namespace eval $testfile {
 	set tst "complete non-unique function name"
 	send_gdb "break -function myfunc\t"
 	gdb_test_multiple "" $tst {
-	    "break -function myfunc\\\x07tion" {
+	    -re "break -function myfunc\\\x07tion" {
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
 		    -re "\\\x07\r\nmyfunction\[ \t\]+myfunction2\[ \t\]+myfunction3\[ \t\]+myfunction4\[ \t\]+\r\n$gdb_prompt " {
@@ -211,7 +211,7 @@  namespace eval $testfile {
 	set tst "complete non-existant function name"
 	send_gdb "break -function foo\t"
 	gdb_test_multiple "" $tst {
-	    "break -function foo\\\x07" {
+	    -re "break -function foo\\\x07" {
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
 		    -re "\\\x07\\\x07" {
@@ -225,7 +225,7 @@  namespace eval $testfile {
 	set tst "complete unique file name"
 	send_gdb "break -source 3ex\t"
 	gdb_test_multiple "" $tst {
-	    "break -source 3explicit.c " {
+	    -re "break -source 3explicit.c " {
 		send_gdb "\n"
 		gdb_test "" \
 		    {Source filename requires function, label, or line offset.} $tst
@@ -235,7 +235,7 @@  namespace eval $testfile {
 	set tst "complete non-unique file name"
 	send_gdb "break -source exp\t"
 	gdb_test_multiple "" $tst {
-	    "break -source exp\\\x07licit" {
+	    -re "break -source exp\\\x07licit" {
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
 		    -re "\\\x07\r\nexplicit.c\[ \t\]+explicit2.c\[ \t\]+\r\n$gdb_prompt" {
@@ -247,7 +247,7 @@  namespace eval $testfile {
 		}
 	    }
 
-	    "break -source exp\\\x07l" {
+	    -re "break -source exp\\\x07l" {
 		# This pattern may occur when glibc debuginfo is installed.
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
@@ -264,10 +264,10 @@  namespace eval $testfile {
 	set tst "complete non-existant file name"
 	send_gdb "break -source foo\t"
 	gdb_test_multiple "" $tst {
-	    "break -source foo" {
+	    -re "break -source foo" {
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
-		    "\\\x07\\\x07" {
+		    -re "\\\x07\\\x07" {
 			send_gdb "\n"
 			gdb_test "" \
 			    {Source filename requires function, label, or line offset.} \
@@ -280,7 +280,7 @@  namespace eval $testfile {
 	set tst "complete filename and unique function name"
 	send_gdb "break -source explicit.c -function ma\t"
 	gdb_test_multiple "" $tst {
-	    "break -source explicit.c -function main " {
+	    -re "break -source explicit.c -function main " {
 		send_gdb "\n"
 		gdb_test "" ".*Breakpoint .*" $tst
 		gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint"
@@ -290,7 +290,7 @@  namespace eval $testfile {
 	set tst "complete filename and non-unique function name"
 	send_gdb "break -so 3explicit.c -func myfunc\t"
 	gdb_test_multiple "" $tst {
-	    "break -so 3explicit.c -func myfunc\\\x07tion" {
+	    -re "break -so 3explicit.c -func myfunc\\\x07tion" {
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
 		    -re "\\\x07\r\nmyfunction3\[ \t\]+myfunction4\[ \t\]+\r\n$gdb_prompt " {
@@ -304,10 +304,10 @@  namespace eval $testfile {
 	set tst "complete filename and non-existant function name"
 	send_gdb "break -sou 3explicit.c -fun foo\t"
 	gdb_test_multiple "" $tst {
-	    "break -sou 3explicit.c -fun foo\\\x07" {
+	    -re "break -sou 3explicit.c -fun foo\\\x07" {
 		send_gdb "\t\t"
 		gdb_test_multiple "" $tst {
-		    "\\\x07\\\x07" {
+		    -re "\\\x07\\\x07" {
 			send_gdb "\n"
 			gdb_test "" \
 			    {Function "foo" not defined in "3explicit.c".} $tst
@@ -319,7 +319,7 @@  namespace eval $testfile {
 	set tst "complete filename and function reversed"
 	send_gdb "break -func myfunction4 -source 3ex\t"
 	gdb_test_multiple "" $tst {
-	    "break -func myfunction4 -source 3explicit.c " {
+	    -re "break -func myfunction4 -source 3explicit.c " {
 		send_gdb "\n"
 		gdb_test "" "Breakpoint \[0-9\]+.*" $tst
 		gdb_test_no_output "delete \$bpnum" "delete $tst breakpoint"