gdb.base/async.exp: Fix races.
authorPedro Alves <palves@redhat.com>
Wed, 19 Mar 2014 15:22:45 +0000 (15:22 +0000)
committerPedro Alves <palves@redhat.com>
Wed, 19 Mar 2014 15:53:00 +0000 (15:53 +0000)
This test is currently racy:

 PASS: gdb.base/async.exp: step&
 stepi&
 (gdb) 0x0000000000400547        14       x = 5; x = 5;
 completed.
 PASS: gdb.base/async.exp: stepi&
 nexti&
 (gdb) 15         y = 3;
 completed.FAIL: gdb.base/async.exp: nexti&

The problem is here:

  -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
      pass "$command"
  }
-re "$gdb_prompt.*completed\.$" {
      fail "$command"
}

Note how the fail pattern is a subset of the pass pattern.  If the
expect buffer happens to end up with:

  "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\."

that is, the final "\r\n" has't reached the expect buffer yet, but
"completed." has, then the fail pattern matches...

gdb/testsuite/
2014-03-19  Pedro Alves  <palves@redhat.com>

* gdb.base/async.exp (test_background): Expect \r\n after
"completed." in the fail pattern.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/async.exp

index 509472d9ba9214f5a17fd6c90b6208a9defdd446..a7237d2e5bde867455879cb0473a0d6838010a98 100644 (file)
@@ -1,3 +1,8 @@
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
+       * gdb.base/async.exp (test_background): Expect \r\n after
+       "completed." in the fail pattern.
+
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/async.exp (test_background): New procedure.
index 65bec4da3fbc73f4995e7c80e79fbba4e50d3912..a1c821cfaf795e5de5f2c3c1b7273db0e4b0b648 100644 (file)
@@ -67,7 +67,7 @@ proc test_background {command before_prompt after_prompt {message ""}} {
        -re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
            pass "$message"
        }
-       -re "$gdb_prompt.*completed\.$" {
+       -re "$gdb_prompt.*completed\.\r\n" {
            fail "$message"
        }
        timeout  {