[gdb/testsuite] Don't use FOOBAR pattern in gdb_test
authorTom de Vries <tdevries@suse.de>
Thu, 19 Sep 2019 17:54:15 +0000 (19:54 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 19 Sep 2019 17:54:15 +0000 (19:54 +0200)
If gdb_test is used with fewer than five arguments, then the question_string
defaults to "^FOOBAR$":
...
    if [llength $args]==5 {
       set question_string [lindex $args 3]
       set response_string [lindex $args 4]
    } else {
       set question_string "^FOOBAR$"
    }
...

This can however match "FOOBAR", so perhaps "\$FOOBAR^" would have been a
better choice.

Eliminate the FOOBAR pattern from gdb_test by instead of defining a default
regexp, conditionally appending the regexp matching to a user_code variable.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2019-09-19  Tom de Vries  <tdevries@suse.de>

* lib/gdb.exp (gdb_test): Eliminate "^FOOBAR$" pattern.

gdb/testsuite/ChangeLog
gdb/testsuite/lib/gdb.exp

index d5a5309fdf36253ee7de99235bba6fdc63b5b6a8..e86091eee3e0cc3b90f20719522ad47f75db1f56 100644 (file)
@@ -1,3 +1,7 @@
+2019-09-19  Tom de Vries  <tdevries@suse.de>
+
+       * lib/gdb.exp (gdb_test): Eliminate "^FOOBAR$" pattern.
+
 2019-09-19  Tom de Vries  <tdevries@suse.de>
 
        * lib/gdbserver-support.exp (gdb_target_cmd): Fix argument passing.
index acbeb01376830cd0171d259ad4fbc417eb968157..3a1f053cf8a3c80f760514b6002bfa068a13ac31 100644 (file)
@@ -1083,24 +1083,28 @@ proc gdb_test { args } {
     set command [lindex $args 0]
     set pattern [lindex $args 1]
 
-    if [llength $args]==5 {
-       set question_string [lindex $args 3]
-       set response_string [lindex $args 4]
-    } else {
-       set question_string "^FOOBAR$"
-    }
-
-    return [gdb_test_multiple $command $message {
+    set user_code {}
+    lappend user_code {
        -re "\[\r\n\]*(?:$pattern)\[\r\n\]+$gdb_prompt $" {
            if ![string match "" $message] then {
                pass "$message"
             }
         }
-       -re "(${question_string})$" {
-           send_gdb "$response_string\n"
-           exp_continue
+    }
+
+    if { [llength $args] == 5 } {
+       set question_string [lindex $args 3]
+       set response_string [lindex $args 4]
+       lappend user_code {
+           -re "(${question_string})$" {
+               send_gdb "$response_string\n"
+               exp_continue
+           }
        }
-     }]
+     }
+
+    set user_code [join $user_code]
+    return [gdb_test_multiple $command $message $user_code]
 }
 
 # Return 1 if version MAJOR.MINOR is at least AT_LEAST_MAJOR.AT_LEAST_MINOR.
This page took 0.037869 seconds and 4 git commands to generate.