This is the mail archive of the
gdb-cvs@sourceware.org
mailing list for the GDB project.
[binutils-gdb] gdb.base/interrupt.exp: Fix race
- From: Pedro Alves <palves at sourceware dot org>
- To: gdb-cvs at sourceware dot org
- Date: 7 Apr 2015 17:31:57 -0000
- Subject: [binutils-gdb] gdb.base/interrupt.exp: Fix race
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=508a3ddf630dfc6e1fe67e2b117152bd64232226
commit 508a3ddf630dfc6e1fe67e2b117152bd64232226
Author: Pedro Alves <palves@redhat.com>
Date: Tue Apr 7 18:19:29 2015 +0100
gdb.base/interrupt.exp: Fix race
Working on splitting gdb and inferior output handling in this test, I
noticed a race that happens to be masked out today.
The test sends "a\n" to the inferior, and then inferior echoes back
"a\n".
If expect manages to read only the first "a\r\n" into its buffer, then
this matches:
-re "^a\r\n(|a\r\n)$" {
and leaves the second "a\r\n" in output.
Then the next test that processes inferior I/O sends "data\n", and expects:
-re "^(\r\n|)data\r\n(|data\r\n)$"
which fails given the anchor and given "a\r\n" is still in the buffer.
This is masked today because the test relies on inferior I/O being
done on GDB's terminal, and there are tested GDB commands in between,
which consume the "a\r\n" that was left in the output.
We don't support SunOS4 anymore, so just remove the workaround.
gdb/testsuite/ChangeLog
2015-04-07 Pedro Alves <palves@redhat.com>
* gdb.base/interrupt.exp: Don't handle the case of the inferior
output appearing once only.
Diff:
---
gdb/testsuite/ChangeLog | 5 +++++
gdb/testsuite/gdb.base/interrupt.exp | 10 ++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 94e1b5e..cce89d8 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
2015-04-07 Pedro Alves <palves@redhat.com>
+ * gdb.base/interrupt.exp: Don't handle the case of the inferior
+ output appearing once only.
+
+2015-04-07 Pedro Alves <palves@redhat.com>
+
* gdb.trace/actions.exp: Use gdb_breakpoint instead of gdb_test
that doesn't expect anything. Return early if running to main
fails.
diff --git a/gdb/testsuite/gdb.base/interrupt.exp b/gdb/testsuite/gdb.base/interrupt.exp
index 4c0fc77..82137e6 100644
--- a/gdb/testsuite/gdb.base/interrupt.exp
+++ b/gdb/testsuite/gdb.base/interrupt.exp
@@ -58,12 +58,10 @@ if ![file exists $binfile] then {
eof { fail "run (eof)" }
}
# This should appear twice, once for the echo and once for the
- # program's output. Under dejagnu (but not interactively) for
- # SunOS4, it only appears once. Don't worry about it, I imagine
- # dejagnu has just done something to the tty modes.
+ # program's output.
send_gdb "a\n"
gdb_expect {
- -re "^a\r\n(|a\r\n)$" {
+ -re "^a\r\na\r\n$" {
pass "child process ate our char"
}
timeout { fail "echo a (timeout)" }
@@ -155,7 +153,7 @@ if ![file exists $binfile] then {
# but the success is spurious. Need to provide the right reg.expr.
# here.
gdb_expect {
- -re "^(\r\n|)data\r\n(|data\r\n)$" { pass "echo data" }
+ -re "^(\r\n|)data\r\ndata\r\n$" { pass "echo data" }
-re "Undefined command.*$gdb_prompt " { fail "echo data" }
timeout { fail "echo data (timeout)" }
eof { fail "echo data (eof)" }
@@ -184,7 +182,7 @@ if ![file exists $binfile] then {
# We should be back in the loop.
send_gdb "more data\n"
gdb_expect {
- -re "^(\r\n|)more data\r\n(|more data\r\n)$" { pass "echo more data" }
+ -re "^(\r\n|)more data\r\nmore data\r\n$" { pass "echo more data" }
timeout { fail "echo more data (timeout)" }
eof { fail "echo more data (eof)" }
}