[gdb/testsuite] Fix gdb.base/batch-preserve-term-settings.exp with check-read1
authorTom de Vries <tdevries@suse.de>
Tue, 8 Jun 2021 12:50:45 +0000 (14:50 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 8 Jun 2021 12:50:45 +0000 (14:50 +0200)
With check-read1, I run into:
...
FAIL: gdb.base/batch-preserve-term-settings.exp: batch run: \
  terminal settings preserved
...

This is caused by spawn_shell matching too little output, after which
things start to go out of sync.

More specifically, the regexp:
...
       -re "PS1=\[^\r\n\]*\r\n.*$shell_prompt_re$" {
...
matches the first and part of the second line of this output:
...
PS1="gdb-subshell$ "^M
sh-4.4$ PS1="gdb-subshell$ "^M
gdb-subshell$
...
while it's supposed to match the entire output.

Fix this by splitting up the regexp into a part that skips the lines with PS1,
and one that reads the shell prompt.

Tested on x86_64-linux.

gdb/testsuite/ChangeLog:

2021-06-08  Tom de Vries  <tdevries@suse.de>

* gdb.base/batch-preserve-term-settings.exp (spawn_shell): Fix
matching of initial prompt.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/batch-preserve-term-settings.exp

index dc921257de18d32e55e5765bdcdd749f9322ece0..cd62633f35c29eb13e62568ba278064171e0439e 100644 (file)
@@ -1,3 +1,8 @@
+2021-06-08  Tom de Vries  <tdevries@suse.de>
+
+       * gdb.base/batch-preserve-term-settings.exp (spawn_shell): Fix
+       matching of initial prompt.
+
 2021-06-08  Tom de Vries  <tdevries@suse.de>
 
        * gdb.threads/multi-create-ns-info-thr.exp: Limit breakpoint regexp to
index da39485c00dc5ed7814028aded4964cd341a7fb3..1f042097a0669ae41a54a56eeab2d74201769c48 100644 (file)
@@ -44,10 +44,20 @@ proc spawn_shell {} {
 
     send_gdb "PS1=\"$shell_prompt_ps1\"\n"
 
+    # Try to match:
+    #   PS1="gdb-subshell$ "^M
+    #   $ gdb-subshell$ 
+    # or:
+    #   PS1="gdb-subshell$ "^M
+    #   sh-4.4$ PS1="gdb-subshell$ "^M
+    #   gdb-subshell$ 
     set gotit 0
     set test "spawn shell"
     gdb_expect {
-       -re "PS1=\[^\r\n\]*\r\n.*$shell_prompt_re$" {
+       -re "PS1=\"$shell_prompt_re" {
+           exp_continue
+       }
+       -re "$shell_prompt_re$" {
            pass $test
            set gotit 1
        }
This page took 0.035199 seconds and 4 git commands to generate.