public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PUSHED 4/8] gdb.base/async.exp: Use prepare_for_testing.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
                   ` (5 preceding siblings ...)
  2014-03-19 15:58 ` [PUSHED 3/8] gdb.base/async.exp: Fix stepi& test Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 1/8] gdb.base/async.exp: Leave gdb_protocol alone Pedro Alves
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

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

	* gdb.base/async.exp: Use prepare_for_testing.
---
 gdb/testsuite/ChangeLog          |  4 ++++
 gdb/testsuite/gdb.base/async.exp | 17 ++++-------------
 2 files changed, 8 insertions(+), 13 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index cc8de97..bb3d559 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
+	* gdb.base/async.exp: Use prepare_for_testing.
+
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
 	* gdb.base/async.c (foo): Make 'x' volatile.  Write to it twice in
 	the same line.
 
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index d4b2b2d..02ca4d1 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -20,15 +20,6 @@
 
 standard_testfile
 
-if [get_compiler_info] {
-    return -1
-}
-
-if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
-    untested $testfile.exp
-    return -1
-}
-
 ########################################
 ##
 ## Don't do any of these tests until we reach consensus on this file.
@@ -36,10 +27,10 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
 return 0
 ########################################
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
-gdb_load ${binfile}
+if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
+    untested $testfile.exp
+    return -1
+}
 
 gdb_test_no_output "set target-async on"
 
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 1/8] gdb.base/async.exp: Leave gdb_protocol alone.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
                   ` (6 preceding siblings ...)
  2014-03-19 15:58 ` [PUSHED 4/8] gdb.base/async.exp: Use prepare_for_testing Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

Many eons ago, async was only implemented in the remote target, and
you'd activate it by doing "target async" rather than "target remote".
That's long gone now, replaced by "set target-async on".

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

	* gdb.base/async.exp: Don't frob gdb_protocol.
---
 gdb/testsuite/ChangeLog          |  4 ++++
 gdb/testsuite/gdb.base/async.exp | 18 ------------------
 2 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a7da03c..c1349b6 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
+	* gdb.base/async.exp: Don't frob gdb_protocol.
+
 2014-03-18  Doug Evans  <xdje42@gmail.com>
 
 	* gdb.base/async.exp: Whitespace fixes.  Turn on target-async.
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index 3cd7dfb..1f465a6 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -36,15 +36,6 @@ if {[build_executable $testfile.exp $testfile $srcfile debug] == -1} {
 return 0
 ########################################
 
-set board [target_info name]
-set current_target [target_info gdb_protocol]
-if { $current_target == "remote" } {
-    unset_board_info "gdb_protocol"
-    set_board_info "gdb_protocol" "async"
-} else {
-    return 0
-}
-
 gdb_exit
 gdb_start
 gdb_reinitialize_dir $srcdir/$subdir
@@ -129,12 +120,3 @@ gdb_expect {
 }
 
 gdb_test_no_output "set exec-done-display off"
-
-unset_board_info "gdb_protocol"
-set_board_info "gdb_protocol" "remote"
-
-
-
-
-
-
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 5/8] gdb.base/async.exp: Factor out test pattern to a procedure.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
                   ` (2 preceding siblings ...)
  2014-03-19 15:58 ` [PUSHED 8/8] gdb.base/async.exp: Enable it Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 7/8] gdb.base/async.exp: Make test messages unique Pedro Alves
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

All the tests here follow the same pattern (and they all have the same
problem, not fixed here yet).  Add a new procedure, factoring out the
pattern to a simple place.

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

	* gdb.base/async.exp (test_background): New procedure.
	Use it for all background execution command tests.
---
 gdb/testsuite/ChangeLog          |  5 +++
 gdb/testsuite/gdb.base/async.exp | 96 ++++++++++++++++++----------------------
 2 files changed, 47 insertions(+), 54 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index bb3d559..509472d 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
+	* gdb.base/async.exp (test_background): New procedure.
+	Use it for all background execution command tests.
+
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
 	* gdb.base/async.exp: Use prepare_for_testing.
 
 2014-03-19  Pedro Alves  <palves@redhat.com>
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index 02ca4d1..65bec4d 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -49,69 +49,57 @@ gdb_test "break baz" ".*" ""
 #
 gdb_test_no_output "set exec-done-display on"
 
-
-send_gdb "next&\n" 
-gdb_expect {
-    -re "^next&\r\n$gdb_prompt.*z = 9.*completed\.\r\n" { pass "next &" }
-    -re "$gdb_prompt.*completed\.$" { fail "next &" }
-    timeout  { fail "(timeout) next &" }
+# Test a background execution command.  COMMAND is the command to
+# send.  BEFORE_PROMPT is the pattern expected before the GDB prompt
+# is output.  AFTER_PROMPT is the pattern expected after the prompt
+# and before "completed".  MESSAGE is optional, and is the pass/fail
+# message to br printed.  If omitted, then the command string is used
+# as message.
+proc test_background {command before_prompt after_prompt {message ""}} {
+    global gdb_prompt
+
+    if {$message eq ""} {
+        set message $command
+    }
+
+    send_gdb "$command\n"
+    gdb_expect {
+	-re "^$command\r\n${before_prompt}${gdb_prompt}${after_prompt}completed\.\r\n" {
+	    pass "$message"
+	}
+	-re "$gdb_prompt.*completed\.$" {
+	    fail "$message"
+	}
+	timeout  {
+	    fail "$message (timeout)"
+	}
+    }
 }
 
-send_gdb "step&\n" 
-gdb_expect {
-    -re "^step&\r\n$gdb_prompt.*y = foo \\(\\).*completed\.\r\n" { pass "step &" }
-    -re "$gdb_prompt.*completed\.$" { fail "step &" }
-    timeout  { fail "(timeout) step &" }
-}
+test_background "next&" "" ".*z = 9.*"
 
-send_gdb "step&\n" 
-gdb_expect {
-    -re "^step&\r\n$gdb_prompt foo \\(\\) at .*async.c.*x = 5.*completed\.\r\n" \
-	    { pass "step &" }
-    -re "$gdb_prompt.*completed\.$" { fail "step &" }
-    timeout  { fail "(timeout) step &" }
-}
+test_background "step&" "" ".*y = foo \\(\\).*"
 
-send_gdb "stepi&\n" 
-gdb_expect {
-    -re "^stepi&\r\n$gdb_prompt.*$hex.*x = 5.*completed\.\r\n" { pass "stepi &" }
-    -re "$gdb_prompt.*completed\.$" { fail "stepi &" }
-    timeout  { fail "(timeout) stepi &" }
-}
+test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*"
 
-send_gdb "nexti&\n" 
-gdb_expect {
-    -re "^nexti&\r\n$gdb_prompt.*y = 3.*completed\.\r\n" { pass "nexti &" }
-    -re "$gdb_prompt.*completed\.$" { fail "nexti &" }
-    timeout  { fail "(timeout) nexti &" }
-}
+test_background "stepi&" "" ".*$hex.*x = 5.*"
 
-send_gdb "finish&\n" 
-gdb_expect {
-    -re "^finish&\r\nRun till exit from #0  foo \\(\\) at.*async.c.*\r\n$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*completed\.\r\n" \
-	    { pass "finish &" }
-    -re "$gdb_prompt.*completed\.$" { fail "finish &" }
-    timeout  { fail "(timeout) finish &" }
-}
+test_background "nexti&" "" ".*y = 3.*"
 
-set jump_here [gdb_get_line_number "jump here"]
+test_background "finish&" \
+    "Run till exit from #0  foo \\(\\) at.*async.c.*\r\n" \
+    ".*$hex in main \\(\\) at.*async.c.*y = foo \\(\\).*Value returned is.*= 8.*"
 
-send_gdb "jump $jump_here&\n"
-gdb_expect {
-    -re "^jump $jump_here&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \
-	    { pass "jump &" }
-    -re ".*$gdb_prompt.*completed\.$" { fail "jump &" }
-    timeout  { fail "(timeout) jump &" }
-}
+set jump_here [gdb_get_line_number "jump here"]
+test_background "jump $jump_here&" \
+    ".*Continuing at $hex.*" \
+    ".*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*" \
+    "jump&"
 
 set until_here [gdb_get_line_number "until here"]
-
-send_gdb "until $until_here&\n" 
-gdb_expect {
-    -re "^until $until_here&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \
-	    { pass "until &" }
-    -re "$gdb_prompt.*completed\.$" { fail "until &" }
-    timeout  { fail "(timeout) until &" }
-}
+test_background "until $until_here&" \
+    ".*" \
+    ".*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*" \
+    "until&"
 
 gdb_test_no_output "set exec-done-display off"
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 8/8] gdb.base/async.exp: Enable it.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
  2014-03-19 15:58 ` [PUSHED 2/8] gdb.base/async.exp: Don't hardcode line numbers Pedro Alves
  2014-03-19 15:58 ` [PUSHED 6/8] gdb.base/async.exp: Fix races Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 5/8] gdb.base/async.exp: Factor out test pattern to a procedure Pedro Alves
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

There's no reason not to enable this test anymore.

Even if the current output isn't ideal (we mess up the prompt), it's what
we have today.  We can adjust the test if the output improves.

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

	* gdb.base/async.exp: Remove early return.
---
 gdb/testsuite/ChangeLog          | 4 ++++
 gdb/testsuite/gdb.base/async.exp | 7 -------
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 7fdc810..88fd3ea 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
+	* gdb.base/async.exp: Remove early return.
+
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
 	* gdb.base/async.exp (step& tests): Pass explicit test messages.
 
 2014-03-19  Pedro Alves  <palves@redhat.com>
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index bbe8a27..f0a18e8 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -20,13 +20,6 @@
 
 standard_testfile
 
-########################################
-##
-## Don't do any of these tests until we reach consensus on this file.
-##
-return 0
-########################################
-
 if {[prepare_for_testing $testfile.exp $testfile $srcfile debug]} {
     untested $testfile.exp
     return -1
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 0/8] Fix and enable gdb.base/async.ex
@ 2014-03-19 15:58 Pedro Alves
  2014-03-19 15:58 ` [PUSHED 2/8] gdb.base/async.exp: Don't hardcode line numbers Pedro Alves
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

This series fixes up several issues with the gdb.base/async.exp test,
and then finally enables it.

Tested on x86_64 Fedora 17, native and gdbserver.

Pedro Alves (8):
  gdb.base/async.exp: Leave gdb_protocol alone.
  gdb.base/async.exp: Don't hardcode line numbers.
  gdb.base/async.exp: Fix stepi& test.
  gdb.base/async.exp: Use prepare_for_testing.
  gdb.base/async.exp: Factor out test pattern to a procedure.
  gdb.base/async.exp: Fix races.
  gdb.base/async.exp: Make test messages unique.
  gdb.base/async.exp: Enable it.

 gdb/testsuite/ChangeLog          |  40 ++++++++++++
 gdb/testsuite/gdb.base/async.c   |   9 +--
 gdb/testsuite/gdb.base/async.exp | 132 +++++++++++++--------------------------
 3 files changed, 90 insertions(+), 91 deletions(-)

-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 3/8] gdb.base/async.exp: Fix stepi& test.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
                   ` (4 preceding siblings ...)
  2014-03-19 15:58 ` [PUSHED 7/8] gdb.base/async.exp: Make test messages unique Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 4/8] gdb.base/async.exp: Use prepare_for_testing Pedro Alves
  2014-03-19 15:58 ` [PUSHED 1/8] gdb.base/async.exp: Leave gdb_protocol alone Pedro Alves
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

Currently the test assumes that "stepi" over:

 13       x = 5;

end up somewhere midline.  But, (at least) on x86, that assignment
ends up compiled as just one movl instruction, so a stepi stops at the
next line already:

 completed.
 PASS: gdb.base/async.exp: step &
 step&
 (gdb) foo () at ../../../src/gdb/testsuite/gdb.base/async.c:13
 13       x = 5;
 completed.
 PASS: gdb.base/async.exp: step &
 stepi&
 (gdb) 14         y = 3;
 completed.
 FAIL: gdb.base/async.exp: (timeout) stepi &
 nexti&
 (gdb) 16         return x + y;
 completed.
 FAIL: gdb.base/async.exp: (timeout) nexti &
 finish&
 Run till exit from #0  foo () at ../../../src/gdb/testsuite/gdb.base/async.c:16

This patch fixes it, by making sure there's more than one instruction
in that line.

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

	* gdb.base/async.c (foo): Make 'x' volatile.  Write to it twice in
	the same line.
---
 gdb/testsuite/ChangeLog        | 5 +++++
 gdb/testsuite/gdb.base/async.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index fa7b282..cc8de97 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
+	* gdb.base/async.c (foo): Make 'x' volatile.  Write to it twice in
+	the same line.
+
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
 	* gdb.base/async.c (main): Add "jump here" and "until here" line
 	marker comments.
 	* gdb.base/async.exp (jump_here): New global.
diff --git a/gdb/testsuite/gdb.base/async.c b/gdb/testsuite/gdb.base/async.c
index fb53082..76ce8be 100644
--- a/gdb/testsuite/gdb.base/async.c
+++ b/gdb/testsuite/gdb.base/async.c
@@ -8,9 +8,10 @@ int
 foo ()
 #endif
 {
- int x, y;
+ int y;
+ volatile int x;
 
- x = 5;
+ x = 5; x = 5;
  y = 3;
 
  return x + y;
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 7/8] gdb.base/async.exp: Make test messages unique.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
                   ` (3 preceding siblings ...)
  2014-03-19 15:58 ` [PUSHED 5/8] gdb.base/async.exp: Factor out test pattern to a procedure Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 3/8] gdb.base/async.exp: Fix stepi& test Pedro Alves
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

 $ cat gdb.sum| grep PASS| sort | uniq -c |sort -n
       1 PASS: gdb.base/async.exp: finish&
       1 PASS: gdb.base/async.exp: jump&
       1 PASS: gdb.base/async.exp: next&
       1 PASS: gdb.base/async.exp: nexti&
       1 PASS: gdb.base/async.exp: set exec-done-display off
       1 PASS: gdb.base/async.exp: set exec-done-display on
       1 PASS: gdb.base/async.exp: set target-async on
       1 PASS: gdb.base/async.exp: stepi&
       1 PASS: gdb.base/async.exp: until&
       2 PASS: gdb.base/async.exp: step&

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

	* gdb.base/async.exp (step& tests): Pass explicit test messages.
---
 gdb/testsuite/ChangeLog          | 4 ++++
 gdb/testsuite/gdb.base/async.exp | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index a7237d2..7fdc810 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,9 @@
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
+	* gdb.base/async.exp (step& tests): Pass explicit test messages.
+
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
 	* gdb.base/async.exp (test_background): Expect \r\n after
 	"completed." in the fail pattern.
 
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index a1c821c..bbe8a27 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -78,9 +78,9 @@ proc test_background {command before_prompt after_prompt {message ""}} {
 
 test_background "next&" "" ".*z = 9.*"
 
-test_background "step&" "" ".*y = foo \\(\\).*"
+test_background "step&" "" ".*y = foo \\(\\).*" "step& #1"
 
-test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*"
+test_background "step&" "" " foo \\(\\) at .*async.c.*x = 5.*" "step& #2"
 
 test_background "stepi&" "" ".*$hex.*x = 5.*"
 
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 2/8] gdb.base/async.exp: Don't hardcode line numbers.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 6/8] gdb.base/async.exp: Fix races Pedro Alves
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

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

	* gdb.base/async.c (main): Add "jump here" and "until here" line
	marker comments.
	* gdb.base/async.exp (jump_here): New global.
	(jump& test): Use it.
	(until_here): New global.
	(until& test): Use it.
---
 gdb/testsuite/ChangeLog          |  9 +++++++++
 gdb/testsuite/gdb.base/async.c   |  4 ++--
 gdb/testsuite/gdb.base/async.exp | 12 ++++++++----
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index c1349b6..fa7b282 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,14 @@
 2014-03-19  Pedro Alves  <palves@redhat.com>
 
+	* gdb.base/async.c (main): Add "jump here" and "until here" line
+	marker comments.
+	* gdb.base/async.exp (jump_here): New global.
+	(jump& test): Use it.
+	(until_here): New global.
+	(until& test): Use it.
+
+2014-03-19  Pedro Alves  <palves@redhat.com>
+
 	* gdb.base/async.exp: Don't frob gdb_protocol.
 
 2014-03-18  Doug Evans  <xdje42@gmail.com>
diff --git a/gdb/testsuite/gdb.base/async.c b/gdb/testsuite/gdb.base/async.c
index 0d9c875..fb53082 100644
--- a/gdb/testsuite/gdb.base/async.c
+++ b/gdb/testsuite/gdb.base/async.c
@@ -30,9 +30,9 @@ main ()
  z = 9;
  y = foo ();
  z = y;
- y = y + 2;
+ y = y + 2; /* jump here */
  y = baz ();
- return 0;
+ return 0; /* until here */
 }
 
 
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index 1f465a6..d4b2b2d 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -103,17 +103,21 @@ gdb_expect {
     timeout  { fail "(timeout) finish &" }
 }
 
-send_gdb "jump 33&\n" 
+set jump_here [gdb_get_line_number "jump here"]
+
+send_gdb "jump $jump_here&\n"
 gdb_expect {
-    -re "^jump 33&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \
+    -re "^jump $jump_here&.*Continuing at $hex.*$gdb_prompt.*Breakpoint 2, baz \\(\\) at.*async.c.*return 5.*completed\.\r\n" \
 	    { pass "jump &" }
     -re ".*$gdb_prompt.*completed\.$" { fail "jump &" }
     timeout  { fail "(timeout) jump &" }
 }
 
-send_gdb "until 35&\n" 
+set until_here [gdb_get_line_number "until here"]
+
+send_gdb "until $until_here&\n" 
 gdb_expect {
-    -re "^until 35&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \
+    -re "^until $until_here&.*$gdb_prompt.*$hex in main \\(\\) at.*async.c.*y = baz \\(\\).*completed\.\r\n" \
 	    { pass "until &" }
     -re "$gdb_prompt.*completed\.$" { fail "until &" }
     timeout  { fail "(timeout) until &" }
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PUSHED 6/8] gdb.base/async.exp: Fix races.
  2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
  2014-03-19 15:58 ` [PUSHED 2/8] gdb.base/async.exp: Don't hardcode line numbers Pedro Alves
@ 2014-03-19 15:58 ` Pedro Alves
  2014-03-19 15:58 ` [PUSHED 8/8] gdb.base/async.exp: Enable it Pedro Alves
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Pedro Alves @ 2014-03-19 15:58 UTC (permalink / raw)
  To: gdb-patches

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          | 5 +++++
 gdb/testsuite/gdb.base/async.exp | 2 +-
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 509472d..a7237d2 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,10 @@
 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.
 	Use it for all background execution command tests.
 
diff --git a/gdb/testsuite/gdb.base/async.exp b/gdb/testsuite/gdb.base/async.exp
index 65bec4d..a1c821c 100644
--- a/gdb/testsuite/gdb.base/async.exp
+++ b/gdb/testsuite/gdb.base/async.exp
@@ -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  {
-- 
1.7.11.7

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-19 15:58 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-19 15:58 [PUSHED 0/8] Fix and enable gdb.base/async.ex Pedro Alves
2014-03-19 15:58 ` [PUSHED 2/8] gdb.base/async.exp: Don't hardcode line numbers Pedro Alves
2014-03-19 15:58 ` [PUSHED 6/8] gdb.base/async.exp: Fix races Pedro Alves
2014-03-19 15:58 ` [PUSHED 8/8] gdb.base/async.exp: Enable it Pedro Alves
2014-03-19 15:58 ` [PUSHED 5/8] gdb.base/async.exp: Factor out test pattern to a procedure Pedro Alves
2014-03-19 15:58 ` [PUSHED 7/8] gdb.base/async.exp: Make test messages unique Pedro Alves
2014-03-19 15:58 ` [PUSHED 3/8] gdb.base/async.exp: Fix stepi& test Pedro Alves
2014-03-19 15:58 ` [PUSHED 4/8] gdb.base/async.exp: Use prepare_for_testing Pedro Alves
2014-03-19 15:58 ` [PUSHED 1/8] gdb.base/async.exp: Leave gdb_protocol alone Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).