Fix racy output matching in gdb.base/cpcompletion.exp
authorPedro Alves <palves@redhat.com>
Thu, 9 Nov 2017 22:44:09 +0000 (22:44 +0000)
committerPedro Alves <palves@redhat.com>
Thu, 9 Nov 2017 22:46:06 +0000 (22:46 +0000)
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:
2017-11-09  Pedro Alves  <palves@redhat.com>

* gdb.cp/cpcompletion.exp (test_class_complete): Tighten regex to
match till end of line.

gdb/testsuite/ChangeLog
gdb/testsuite/gdb.cp/cpcompletion.exp

index ffd314c30cc6d0bb31f7f215e4317c167f71222c..c6c5260dd06bf62120b80061db16695712016ee1 100644 (file)
@@ -1,3 +1,8 @@
+2017-11-09  Pedro Alves  <palves@redhat.com>
+
+       * gdb.cp/cpcompletion.exp (test_class_complete): Tighten regex to
+       match till end of line.
+
 2017-11-09  Pedro Alves  <palves@redhat.com>
 
        * gdb.base/memattr.exp: Tighten regexes to match the end line.
index d4da1d2e3e03c00ffe7517587f470b17d734efe7..c7883ee3766b7aa5ab7e61c6b0d1dac2fdf97c8b 100644 (file)
@@ -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