summaryrefslogtreecommitdiff
path: root/gdb/testsuite/gdb.base
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2017-11-09 22:44:08 +0000
committerPedro Alves <palves@redhat.com>2017-11-09 22:45:06 +0000
commitc7a3851716f98540396b9e02be7d2fcd3bff2d29 (patch)
tree3840782860c29982490d032530ca6e946257386e /gdb/testsuite/gdb.base
parentf29f4b6ba198674096fddf2aa38fa8d028d387b2 (diff)
Fix racy output matching in gdb.base/completion.exp
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: 2017-11-09 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.
Diffstat (limited to 'gdb/testsuite/gdb.base')
-rw-r--r--gdb/testsuite/gdb.base/completion.exp86
1 files changed, 34 insertions, 52 deletions
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp
index f03bfc3ea2..9c7c17a0d1 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"