This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Fix racy output matching in gdb.tui/tui-completion.exp


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=584a564f366de16d1cecd1910ab0be8ca6167415

commit 584a564f366de16d1cecd1910ab0be8ca6167415
Author: Pedro Alves <palves@redhat.com>
Date:   Thu Nov 9 22:44:10 2017 +0000

    Fix racy output matching in gdb.tui/tui-completion.exp
    
    '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:
    2017-11-09  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.

Diff:
---
 gdb/testsuite/ChangeLog              |  7 +++++++
 gdb/testsuite/gdb.tui/completion.exp | 36 +++++++++++++++++-------------------
 2 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 967ef89..7db0afc 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,5 +1,12 @@
 2017-11-09  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.
+
+2017-11-09  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.
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 *"
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]