* [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
` (4 preceding siblings ...)
2017-10-26 17:42 ` [PATCH 4/6] Fix racy output matching in gdb.base/cpcompletion.exp Pedro Alves
@ 2017-10-26 17:42 ` Pedro Alves
2017-11-15 16:09 ` Simon Marchi
2017-11-09 22:50 ` [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
6 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
'make check-read1 TESTS="gdb.tui/tui-completion.exp"' exposes this test race:
(gdb) PASS: gdb.tui/completion.exp: set max-completions unlimited
layout ^G
asm next prev regs split src
(gdb) FAIL: gdb.tui/completion.exp: completion of layout names: tab completion
Quit
(gdb) PASS: gdb.tui/completion.exp: completion of layout names: quit command input
focus ^G
cmd next prev src
(gdb) FAIL: gdb.tui/completion.exp: completion of focus command: tab completion
Quit
This is caused by expecting "$gdb_prompt layout $".
gdb_test_multiple's internal prompt regexp can match first if expect's
internal buffer is filled with partial output. Fix that by splitting
the gdb_test_multiple in question in two. Since the same problem/code
appears twice in the file, factor out a common procedure.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.tui/tui-completion.exp (test_tab_completion): New procedure,
factored out from ...
(top level): ... here, and adjusted to avoid expecting beyond the
prompt in a single gdb_test_multiple.
---
gdb/testsuite/gdb.tui/completion.exp | 36 +++++++++++++++++-------------------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp
index ac5d5f2..f53a244 100644
--- a/gdb/testsuite/gdb.tui/completion.exp
+++ b/gdb/testsuite/gdb.tui/completion.exp
@@ -22,12 +22,20 @@ if {[skip_tui_tests] || [target_info exists gdb,nointerrupts]} {
gdb_test_no_output "set max-completions unlimited"
-with_test_prefix "completion of layout names" {
+# TAB-complete INPUT_LINE, and expect EXPECTED_RE as completion match
+# output.
+proc test_tab_completion {input_line expected_re} {
+ global gdb_prompt
+
set test "tab completion"
- send_gdb "layout\t\t\t"
+ send_gdb "$input_line\t\t\t"
gdb_test_multiple "" "$test" {
- -re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" {
- pass "$test"
+ -re "$expected_re\r\n$gdb_prompt " {
+ gdb_test_multiple "" "$test" {
+ -re "^$input_line$" {
+ pass "$test"
+ }
+ }
}
}
send_gdb "\003"
@@ -39,20 +47,10 @@ with_test_prefix "completion of layout names" {
}
}
-with_test_prefix "completion of focus command" {
- set test "tab completion"
- send_gdb "focus \t\t"
- gdb_test_multiple "" "$test" {
- -re "cmd *next *prev *src *\r\n$gdb_prompt focus $" {
- pass "$test"
- }
- }
+with_test_prefix "completion of layout names" {
+ test_tab_completion "layout" "asm *next *prev *regs *split *src *"
+}
- send_gdb "\003"
- set test "quit command input"
- gdb_test_multiple "" "$test" {
- -re "$gdb_prompt $" {
- pass "$test"
- }
- }
+with_test_prefix "completion of focus command" {
+ test_tab_completion "focus" "cmd *next *prev *src *"
}
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 5/6] Fix racy output matching in gdb.base/multi-attach.exp, gdb.server/ext-{attach, restart, ext-run}.exp
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
2017-10-26 17:42 ` [PATCH 3/6] Fix racy output matching in gdb.base/memattr.exp Pedro Alves
@ 2017-10-26 17:42 ` Pedro Alves
2017-10-26 17:42 ` [PATCH 2/6] Fix racy output matching in gdb.base/completion.exp Pedro Alves
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
This commit fixes this same problem in several places:
(gdb) PASS: gdb.multi/multi-attach.exp: backtrace 2
kill
Kill the program being debugged? (y or n) y
(gdb) FAIL: gdb.multi/multi-attach.exp: kill inferior 2 (got interactive prompt)
This is just another case of the gdb_test_multiple's internal "got
interactive prompt" pattern matching because the testcase misses
matching enough.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.multi/multi-attach.exp ("kill" test): Match the whole query
output.
* gdb.server/ext-attach.exp ("kill" test): Likewise.
* gdb.server/ext-restart.exp ("kill" test): Likewise.
* gdb.server/ext-run.exp ("kill" test): Likewise.
* gdb.server/ext-wrapper.exp ("kill" test): Likewise.
---
gdb/testsuite/gdb.multi/multi-attach.exp | 4 ++--
gdb/testsuite/gdb.server/ext-attach.exp | 2 +-
gdb/testsuite/gdb.server/ext-restart.exp | 2 +-
gdb/testsuite/gdb.server/ext-run.exp | 2 +-
gdb/testsuite/gdb.server/ext-wrapper.exp | 2 +-
5 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.multi/multi-attach.exp b/gdb/testsuite/gdb.multi/multi-attach.exp
index 4240ff7..9397f85 100644
--- a/gdb/testsuite/gdb.multi/multi-attach.exp
+++ b/gdb/testsuite/gdb.multi/multi-attach.exp
@@ -51,9 +51,9 @@ gdb_test "attach $testpid2" \
"attach to program 2"
gdb_test "backtrace" ".*main.*" "backtrace 2"
-gdb_test "kill" "" "kill inferior 2" "Kill the program being debugged.*" "y"
+gdb_test "kill" "" "kill inferior 2" "Kill the program being debugged. .y or n. " "y"
gdb_test "inferior 1" ".*Switching to inferior 1.*"
-gdb_test "kill" "" "kill inferior 1" "Kill the program being debugged.*" "y"
+gdb_test "kill" "" "kill inferior 1" "Kill the program being debugged. .y or n. " "y"
kill_wait_spawned_process $test_spawn_id1
kill_wait_spawned_process $test_spawn_id2
diff --git a/gdb/testsuite/gdb.server/ext-attach.exp b/gdb/testsuite/gdb.server/ext-attach.exp
index f3e992a..881c636 100644
--- a/gdb/testsuite/gdb.server/ext-attach.exp
+++ b/gdb/testsuite/gdb.server/ext-attach.exp
@@ -68,7 +68,7 @@ gdb_test "attach $testpid" \
"attach to remote program 2"
gdb_test "backtrace" ".*main.*" "backtrace 2"
-gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y"
+gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
gdb_test_no_output "monitor exit"
kill_wait_spawned_process $test_spawn_id
diff --git a/gdb/testsuite/gdb.server/ext-restart.exp b/gdb/testsuite/gdb.server/ext-restart.exp
index 44c9b1f..d28ce47 100644
--- a/gdb/testsuite/gdb.server/ext-restart.exp
+++ b/gdb/testsuite/gdb.server/ext-restart.exp
@@ -60,6 +60,6 @@ with_test_prefix "restart" {
}
}
-gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y"
+gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
gdb_test_no_output "monitor exit"
diff --git a/gdb/testsuite/gdb.server/ext-run.exp b/gdb/testsuite/gdb.server/ext-run.exp
index cdb1695..d8b3e92 100644
--- a/gdb/testsuite/gdb.server/ext-run.exp
+++ b/gdb/testsuite/gdb.server/ext-run.exp
@@ -61,7 +61,7 @@ if { [istarget *-*-linux*] } {
}
}
-gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y"
+gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
gdb_load $binfile
gdb_test "monitor help" "The following monitor commands.*" \
diff --git a/gdb/testsuite/gdb.server/ext-wrapper.exp b/gdb/testsuite/gdb.server/ext-wrapper.exp
index 8b1af7b..b195ae7 100644
--- a/gdb/testsuite/gdb.server/ext-wrapper.exp
+++ b/gdb/testsuite/gdb.server/ext-wrapper.exp
@@ -65,6 +65,6 @@ with_test_prefix "restart" {
gdb_test "print d" "\\$${decimal} = ${hex} \"1\".*"
}
-gdb_test "kill" "" "kill" "Kill the program being debugged.*" "y"
+gdb_test "kill" "" "kill" "Kill the program being debugged. .y or n. " "y"
gdb_test_no_output "monitor exit"
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 4/6] Fix racy output matching in gdb.base/cpcompletion.exp
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
` (3 preceding siblings ...)
2017-10-26 17:42 ` [PATCH 1/6] Fix racy output matching in gdb.asm/asm-source.exp Pedro Alves
@ 2017-10-26 17:42 ` Pedro Alves
2017-10-26 17:42 ` [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp Pedro Alves
2017-11-09 22:50 ` [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
6 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
With:
$ make check-read1 TESTS="gdb.cp/cpcompletion.exp"
we get (from gdb.log):
(gdb) complete break Foo::
break Foo::Foo()
break Foo::Foofoo()
break Foo::get_foo()
break Foo::set_foo(int)
break Foo::~Foo()
(gdb) FAIL: gdb.cp/cpcompletion.exp: complete class methods (Foo not found)
The problem is that the
"break ${class}::\[A-Za-z0-9_~\]+"
regexp patches partial input, like:
break Foo::F
break Foo::Fo
break Foo::Foo
etc.
Fix that by expecting each whole line.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.cp/cpcompletion.exp (test_class_complete): Tighten regex to
match till end of line.
---
gdb/testsuite/gdb.cp/cpcompletion.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.cp/cpcompletion.exp b/gdb/testsuite/gdb.cp/cpcompletion.exp
index d4da1d2..c7883ee 100644
--- a/gdb/testsuite/gdb.cp/cpcompletion.exp
+++ b/gdb/testsuite/gdb.cp/cpcompletion.exp
@@ -26,7 +26,7 @@ proc test_class_complete {class expr name matches} {
gdb_test_multiple $cmd $name {
"break ${class}::main" { fail "$name (saw global symbol)" }
$cmd { exp_continue }
- -re "break ${class}::\[A-Za-z0-9_~\]+" {
+ -re "break ${class}::\[^\r\n\]*\r\n" {
set str $expect_out(0,string)
scan $str "break ${class}::%\[^(\]" method
lappend seen $method
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/6] Fix racy output matching in gdb.asm/asm-source.exp
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
` (2 preceding siblings ...)
2017-10-26 17:42 ` [PATCH 2/6] Fix racy output matching in gdb.base/completion.exp Pedro Alves
@ 2017-10-26 17:42 ` Pedro Alves
2017-10-26 17:42 ` [PATCH 4/6] Fix racy output matching in gdb.base/cpcompletion.exp Pedro Alves
` (2 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
Testing with:
$ make check-read1 TESTS="gdb.asm/asm-source.exp"
Exposes a testcase bug that can result in racy fails:
(gdb) PASS: gdb.asm/asm-source.exp: next over foo3
return
Make selected stack frame return now? (y or n) y
n
#0 main () at /home/pedro/gdb/mygit/src/gdb/testsuite/gdb.asm/asmsrc1.s:53
53 gdbasm_exit0
(gdb) FAIL: gdb.asm/asm-source.exp: return from foo2 (got interactive prompt)
n
The problem is that the "return now\?.*" regex can match partial
output like this:
"Make selected stack frame return no"
and then we send the 'y' too early, and then the next time around we
hit gdb_test_multiple's internal "got interactive prompt" regex.
Also, note we match "return no" instead of "return now" because the
regex is missing one quote level.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.asm/asm-source.exp ("kill" test): Match the whole query
output. Fix '?' match.
---
gdb/testsuite/gdb.asm/asm-source.exp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.asm/asm-source.exp b/gdb/testsuite/gdb.asm/asm-source.exp
index 138609a..47717a2 100644
--- a/gdb/testsuite/gdb.asm/asm-source.exp
+++ b/gdb/testsuite/gdb.asm/asm-source.exp
@@ -435,7 +435,7 @@ gdb_test "next" "$line_foo2_leave\[ \t\]+gdbasm_leave" "next over foo3"
# Like "finish", "return" command also can return to the caller
# line again or the statement after, depending on the architecture.
gdb_test_multiple "return" "return from foo2" {
- -re "Make (foo2|selected stack frame) return now\?.*" {
+ -re "Make (foo2|selected stack frame) return now\\? .y or n. " {
send_gdb "y\n"
exp_continue
}
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 2/6] Fix racy output matching in gdb.base/completion.exp
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
2017-10-26 17:42 ` [PATCH 3/6] Fix racy output matching in gdb.base/memattr.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 5/6] Fix racy output matching in gdb.base/multi-attach.exp, gdb.server/ext-{attach, restart, ext-run}.exp Pedro Alves
@ 2017-10-26 17:42 ` Pedro Alves
2017-10-26 17:42 ` [PATCH 1/6] Fix racy output matching in gdb.asm/asm-source.exp Pedro Alves
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
Testing with:
$ make check-read1 TESTS="gdb.base/completion.exp"
Exposes a testcase bug that can result in racy fails:
FAIL: gdb.base/completion.exp: command-name completion limiting using tab character
ERROR: Undefined command "".
FAIL: gdb.base/completion.exp: symbol-name completion limiting using tab character
FAIL: gdb.base/completion.exp: symbol-name completion limiting using complete command
testsuite/gdb.log shows:
(gdb) PASS: gdb.base/completion.exp: set max-completions 5
p^G
passcount path print print-object printf
*** List may be truncated, max-completions reached. ***
(gdb) FAIL: gdb.base/completion.exp: command-name completion limiting using tab character
pcomplete p
Undefined command: "pcomplete". Try "help".
(gdb) ERROR: Undefined command "".
The problem is that the expect buffer can get filled with partial
output that ends in the gdb prompt, and so the default FAIL inside
gdb_test_multiple matches.
Fix that by splitting the gdb_test_multiple in two stages. Since that
is done in more than one place in the testcase, move the otherwise
duplicate code to helper procedures.
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.base/completion.exp (ignore_and_resync, test_tab_complete):
New procedures, factored out from ...
(top level): ... here, and adjusted to avoid expecting beyond the
prompt in one go.
---
gdb/testsuite/gdb.base/completion.exp | 86 ++++++++++++++---------------------
1 file changed, 34 insertions(+), 52 deletions(-)
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index f03bfc3e..9c7c17a 100644
--- a/gdb/testsuite/gdb.base/completion.exp
+++ b/gdb/testsuite/gdb.base/completion.exp
@@ -863,36 +863,45 @@ gdb_test "complete break $srcfile:ma" "break\.c:main"
gdb_test_no_output "set max-completions 5"
-set test "command-name completion limiting using tab character"
-send_gdb "p\t"
-gdb_test_multiple "" "$test" {
- -re "^p\\\x07$" {
- send_gdb "\t"
- gdb_test_multiple "" "$test" {
- -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt p$" {
- # Complete the command and ignore the output to resync
- # gdb for the next test.
- send_gdb "\n"
- gdb_test_multiple "" "$test" {
- -re "$gdb_prompt $" {
- pass "$test"
- }
+proc ignore_and_resync {cmd result test} {
+ global gdb_prompt
+
+ gdb_test_multiple "" "$test" {
+ -re "^${cmd}$" {
+ # Complete the command and ignore the output
+ # to resync gdb for the next test.
+ send_gdb "\n"
+ gdb_test_multiple "" "$test" {
+ -re "$gdb_prompt $" {
+ $result $test
}
}
- -re "$gdb_prompt p$" {
- # Complete the command and ignore the output to resync
- # gdb for the next test.
- send_gdb "\n"
- gdb_test_multiple "" "$test" {
- -re "$gdb_prompt $" {
- fail "$test"
- }
+ }
+ }
+}
+
+proc test_tab_complete {cmd test} {
+ global gdb_prompt
+
+ send_gdb "${cmd}\t"
+ gdb_test_multiple "" "$test" {
+ -re "^${cmd}\\\x07$" {
+ send_gdb "\t"
+ gdb_test_multiple "" "$test" {
+ -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt " {
+ ignore_and_resync $cmd pass $test
+ }
+ -re "$gdb_prompt " {
+ ignore_and_resync $cmd fail $test
}
}
- }
+ }
}
}
+test_tab_complete "p" \
+ "command-name completion limiting using tab character"
+
set test "command-name completion limiting using complete command"
send_gdb "complete p\n"
gdb_test_multiple "" "$test" {
@@ -903,35 +912,8 @@ gdb_test_multiple "" "$test" {
gdb_test_no_output "set max-completions 3"
-set test "symbol-name completion limiting using tab character"
-send_gdb "p marker\t"
-gdb_test_multiple "" "$test" {
- -re "^p marker\\\x07$" {
- send_gdb "\t"
- gdb_test_multiple "" "$test" {
- -re "List may be truncated, max-completions reached.*\r\n$gdb_prompt p marker$" {
- # Complete the command and ignore the output to resync
- # gdb for the next test.
- send_gdb "\n"
- gdb_test_multiple "" "$test" {
- -re "$gdb_prompt $" {
- pass "$test"
- }
- }
- }
- -re "$gdb_prompt p marker$" {
- # Complete the command and ignore the output to resync
- # gdb for the next test.
- send_gdb "\n"
- gdb_test_multiple "" "$test" {
- -re "$gdb_prompt $" {
- fail "$test"
- }
- }
- }
- }
- }
-}
+test_tab_complete "p marker" \
+ "symbol-name completion limiting using tab character"
set test "symbol-name completion limiting using complete command"
send_gdb "complete p mark\n"
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 0/6] Fix several cases of racy output matching
@ 2017-10-26 17:42 Pedro Alves
2017-10-26 17:42 ` [PATCH 3/6] Fix racy output matching in gdb.base/memattr.exp Pedro Alves
` (6 more replies)
0 siblings, 7 replies; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
After <https://sourceware.org/ml/gdb-patches/2017-10/msg00751.html>, I
had the bright idea of running the whole testsuite with "make
check-read1", and that exposed a number of problems.
This fixes a good chunk of those. (There are more in at least gdb.mi/
and gdb.python/.)
Pedro Alves (6):
Fix racy output matching in gdb.asm/asm-source.exp
Fix racy output matching in gdb.base/completion.exp
Fix racy output matching in gdb.base/memattr.exp
Fix racy output matching in gdb.base/cpcompletion.exp
Fix racy output matching in gdb.base/multi-attach.exp,
gdb.server/ext-{attach, restart, ext-run}.exp
Fix racy output matching in gdb.tui/tui-completion.exp
gdb/testsuite/gdb.asm/asm-source.exp | 2 +-
gdb/testsuite/gdb.base/completion.exp | 86 +++++++++++++-------------------
gdb/testsuite/gdb.base/memattr.exp | 12 ++---
gdb/testsuite/gdb.cp/cpcompletion.exp | 2 +-
gdb/testsuite/gdb.multi/multi-attach.exp | 4 +-
gdb/testsuite/gdb.server/ext-attach.exp | 2 +-
gdb/testsuite/gdb.server/ext-restart.exp | 2 +-
gdb/testsuite/gdb.server/ext-run.exp | 2 +-
gdb/testsuite/gdb.server/ext-wrapper.exp | 2 +-
gdb/testsuite/gdb.tui/completion.exp | 36 +++++++------
10 files changed, 65 insertions(+), 85 deletions(-)
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 3/6] Fix racy output matching in gdb.base/memattr.exp
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
@ 2017-10-26 17:42 ` Pedro Alves
2017-10-26 17:42 ` [PATCH 5/6] Fix racy output matching in gdb.base/multi-attach.exp, gdb.server/ext-{attach, restart, ext-run}.exp Pedro Alves
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-10-26 17:42 UTC (permalink / raw)
To: gdb-patches
Testing with:
$ make check-read1 TESTS="gdb.base/memattr.exp"
Exposes a testcase bug that can result in racy fails:
info mem
Using user-defined memory regions.
Num Enb Low Addr High Addr Attrs
1 y 0x0000000000601060 0x0000000000601160 wo nocache
2 y 0x0000000000601180 0x0000000000601280 ro nocache
4 y 0x0000000000601280 0x0000000000601380 rw nocache
3 y 0x0000000000601380 0x0000000000601480 rw nocache
5 y 0x0000000000601480 0x0000000000601580 rw nocache
(gdb) FAIL: gdb.base/memattr.exp: info mem (1)
The problem is that:
"Attrs\[^\n\r]*.."
matches:
"Attrs \r"
when the output buffer is filled with partial output like this:
"info mem\r\nUsing user-defined memory regions.\r\nNum Enb Low Addr High Addr Attrs \r"
gdb/testsuite/ChangeLog:
yyyy-mm-dd Pedro Alves <palves@redhat.com>
* gdb.base/memattr.exp: Tighten regexes to match the end line.
---
gdb/testsuite/gdb.base/memattr.exp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/gdb/testsuite/gdb.base/memattr.exp b/gdb/testsuite/gdb.base/memattr.exp
index 48f0496..88eb51c 100644
--- a/gdb/testsuite/gdb.base/memattr.exp
+++ b/gdb/testsuite/gdb.base/memattr.exp
@@ -114,30 +114,30 @@ set see4 0
set see5 0
set info_mem_header_pattern \
- "info mem.*Num\[ \t\]+Enb\[ \t\]+Low\[ \t\]+Addr\[ \t\]+High\[ \t\]+Addr\[ \t\]+Attrs\[^\n\r]*.."
+ "info mem.*Num\[ \t\]+Enb\[ \t\]+Low\[ \t\]+Addr\[ \t\]+High\[ \t\]+Addr\[ \t\]+Attrs\[^\r\n\]*\r\n"
gdb_test_multiple "info mem" "info mem(1)" {
-re ${info_mem_header_pattern} {
# Discard the header.
exp_continue
}
- -re "^1 y \[ \t\]+$hex $hex wo nocache \[^\r\n\]*.." {
+ -re "^1 y \[ \t\]+$hex $hex wo nocache \[^\r\n\]*\r\n" {
set see1 1
exp_continue
}
- -re "^2 y \[ \t\]+$hex $hex ro nocache \[^\r\n\]*.." {
+ -re "^2 y \[ \t\]+$hex $hex ro nocache \[^\r\n\]*\r\n" {
set see2 1
exp_continue
}
- -re "^3 y \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
+ -re "^3 y \[ \t\]+$hex $hex rw nocache \[^\r\n\]*\r\n" {
set see3 1
exp_continue
}
- -re "^4 y \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
+ -re "^4 y \[ \t\]+$hex $hex rw nocache \[^\r\n\]*\r\n" {
set see4 1
exp_continue
}
- -re "^5 y \[ \t\]+$hex $hex rw nocache \[^\r\n\]*.." {
+ -re "^5 y \[ \t\]+$hex $hex rw nocache \[^\r\n\]*\r\n" {
set see5 1
exp_continue
}
--
2.5.5
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 0/6] Fix several cases of racy output matching
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
` (5 preceding siblings ...)
2017-10-26 17:42 ` [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp Pedro Alves
@ 2017-11-09 22:50 ` Pedro Alves
6 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-11-09 22:50 UTC (permalink / raw)
To: gdb-patches
On 10/26/2017 06:42 PM, Pedro Alves wrote:
> After <https://sourceware.org/ml/gdb-patches/2017-10/msg00751.html>, I
> had the bright idea of running the whole testsuite with "make
> check-read1", and that exposed a number of problems.
>
> This fixes a good chunk of those. (There are more in at least gdb.mi/
> and gdb.python/.)
>
> Pedro Alves (6):
> Fix racy output matching in gdb.asm/asm-source.exp
> Fix racy output matching in gdb.base/completion.exp
> Fix racy output matching in gdb.base/memattr.exp
> Fix racy output matching in gdb.base/cpcompletion.exp
> Fix racy output matching in gdb.base/multi-attach.exp,
> gdb.server/ext-{attach, restart, ext-run}.exp
> Fix racy output matching in gdb.tui/tui-completion.exp
I've pushed these in now.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp
2017-10-26 17:42 ` [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp Pedro Alves
@ 2017-11-15 16:09 ` Simon Marchi
2017-11-15 16:16 ` Pedro Alves
0 siblings, 1 reply; 10+ messages in thread
From: Simon Marchi @ 2017-11-15 16:09 UTC (permalink / raw)
To: Pedro Alves, gdb-patches
On 2017-10-26 01:42 PM, Pedro Alves wrote:
> 'make check-read1 TESTS="gdb.tui/tui-completion.exp"' exposes this test race:
>
> (gdb) PASS: gdb.tui/completion.exp: set max-completions unlimited
> layout ^G
> asm next prev regs split src
> (gdb) FAIL: gdb.tui/completion.exp: completion of layout names: tab completion
> Quit
> (gdb) PASS: gdb.tui/completion.exp: completion of layout names: quit command input
> focus ^G
> cmd next prev src
> (gdb) FAIL: gdb.tui/completion.exp: completion of focus command: tab completion
> Quit
>
> This is caused by expecting "$gdb_prompt layout $".
> gdb_test_multiple's internal prompt regexp can match first if expect's
> internal buffer is filled with partial output. Fix that by splitting
> the gdb_test_multiple in question in two. Since the same problem/code
> appears twice in the file, factor out a common procedure.
>
> gdb/testsuite/ChangeLog:
> yyyy-mm-dd Pedro Alves <palves@redhat.com>
>
> * gdb.tui/tui-completion.exp (test_tab_completion): New procedure,
> factored out from ...
> (top level): ... here, and adjusted to avoid expecting beyond the
> prompt in a single gdb_test_multiple.
> ---
> gdb/testsuite/gdb.tui/completion.exp | 36 +++++++++++++++++-------------------
> 1 file changed, 17 insertions(+), 19 deletions(-)
>
> diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp
> index ac5d5f2..f53a244 100644
> --- a/gdb/testsuite/gdb.tui/completion.exp
> +++ b/gdb/testsuite/gdb.tui/completion.exp
> @@ -22,12 +22,20 @@ if {[skip_tui_tests] || [target_info exists gdb,nointerrupts]} {
>
> gdb_test_no_output "set max-completions unlimited"
>
> -with_test_prefix "completion of layout names" {
> +# TAB-complete INPUT_LINE, and expect EXPECTED_RE as completion match
> +# output.
> +proc test_tab_completion {input_line expected_re} {
> + global gdb_prompt
> +
> set test "tab completion"
> - send_gdb "layout\t\t\t"
> + send_gdb "$input_line\t\t\t"
> gdb_test_multiple "" "$test" {
> - -re "asm *next *prev *regs *split *src *\r\n$gdb_prompt layout $" {
> - pass "$test"
> + -re "$expected_re\r\n$gdb_prompt " {
> + gdb_test_multiple "" "$test" {
> + -re "^$input_line$" {
> + pass "$test"
> + }
> + }
> }
> }
> send_gdb "\003"
> @@ -39,20 +47,10 @@ with_test_prefix "completion of layout names" {
> }
> }
>
> -with_test_prefix "completion of focus command" {
> - set test "tab completion"
> - send_gdb "focus \t\t"
> - gdb_test_multiple "" "$test" {
> - -re "cmd *next *prev *src *\r\n$gdb_prompt focus $" {
> - pass "$test"
> - }
> - }
> +with_test_prefix "completion of layout names" {
> + test_tab_completion "layout" "asm *next *prev *regs *split *src *"
> +}
>
> - send_gdb "\003"
> - set test "quit command input"
> - gdb_test_multiple "" "$test" {
> - -re "$gdb_prompt $" {
> - pass "$test"
> - }
> - }
> +with_test_prefix "completion of focus command" {
> + test_tab_completion "focus" "cmd *next *prev *src *"
> }
>
Hi Pedro,
I am seeing a failure in this test (gdb.tui/completion.exp), I pushed
this patch to fix it.
commit 71774bc994e3f2a09c3b1988dbf2e99b86f53e2e
Author: Simon Marchi <simon.marchi@ericsson.com>
Date: Wed Nov 15 11:07:02 2017 -0500
Fix gdb.tui/completion.exp test
When I run it locally, the test gdb.tui/completion.exp test fails
because of a timeout:
Running /home/emaisin/src/binutils-gdb/gdb/testsuite/gdb.tui/completion.exp ...
FAIL: gdb.tui/completion.exp: completion of layout names: tab completion (timeout)
The problem seems to be this regex, which confirms that after doing
layout<TAB>, "layout" is printed again after the gdb prompt:
-re "^$input_line$"
The problem is that there's a trailing space in the output after
"layout". Since the regex has an anchored end (the $), it doesn't
match. Adding a space fixes the test.
gdb/testsuite/ChangeLog:
* gdb.tui/completionn.exp (test_tab_completion): Add space in
regex.
diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8c57179..bb8dd79 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,8 @@
+2017-11-15 Simon Marchi <simon.marchi@ericsson.com>
+
+ * gdb.tui/completionn.exp (test_tab_completion): Add space in
+ regex.
+
2017-11-13 Simon Marchi <simon.marchi@polymtl.ca>
* gdb.opt/inline-locals.exp: Remove trailing parentheses from
diff --git a/gdb/testsuite/gdb.tui/completion.exp b/gdb/testsuite/gdb.tui/completion.exp
index f53a244..426b6bf 100644
--- a/gdb/testsuite/gdb.tui/completion.exp
+++ b/gdb/testsuite/gdb.tui/completion.exp
@@ -32,7 +32,7 @@ proc test_tab_completion {input_line expected_re} {
gdb_test_multiple "" "$test" {
-re "$expected_re\r\n$gdb_prompt " {
gdb_test_multiple "" "$test" {
- -re "^$input_line$" {
+ -re "^$input_line $" {
pass "$test"
}
}
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp
2017-11-15 16:09 ` Simon Marchi
@ 2017-11-15 16:16 ` Pedro Alves
0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2017-11-15 16:16 UTC (permalink / raw)
To: Simon Marchi, gdb-patches
On 11/15/2017 04:08 PM, Simon Marchi wrote:
> Hi Pedro,
>
> I am seeing a failure in this test (gdb.tui/completion.exp), I pushed
> this patch to fix it.
>
Thanks. Guess I only tested with "make check-read1", which masks
this problem, because the regex matches as soon at the 't' in
"layout" is consumed. Kind of ironic. :-P
Sorry about that.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2017-11-15 16:16 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-26 17:42 [PATCH 0/6] Fix several cases of racy output matching Pedro Alves
2017-10-26 17:42 ` [PATCH 3/6] Fix racy output matching in gdb.base/memattr.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 5/6] Fix racy output matching in gdb.base/multi-attach.exp, gdb.server/ext-{attach, restart, ext-run}.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 2/6] Fix racy output matching in gdb.base/completion.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 1/6] Fix racy output matching in gdb.asm/asm-source.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 4/6] Fix racy output matching in gdb.base/cpcompletion.exp Pedro Alves
2017-10-26 17:42 ` [PATCH 6/6] Fix racy output matching in gdb.tui/tui-completion.exp Pedro Alves
2017-11-15 16:09 ` Simon Marchi
2017-11-15 16:16 ` Pedro Alves
2017-11-09 22:50 ` [PATCH 0/6] Fix several cases of racy output matching 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).