]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
gdb/testsuite: fix completion tests when using READ1
authorGuinevere Larsen <blarsen@redhat.com>
Wed, 26 Jul 2023 08:08:10 +0000 (10:08 +0200)
committerGuinevere Larsen <blarsen@redhat.com>
Fri, 1 Dec 2023 12:29:40 +0000 (13:29 +0100)
commitfbd9e35c5436108732575e82e78cc42be5ba52f5
treeeba10f758b97399d7e8340a4ae97767374891418
parentd7ac0027a4419b85cd6db4c6fc84d287e34f84a9
gdb/testsuite: fix completion tests when using READ1

The commit a3da2e7e550c4fe79128b5e532dbb90df4d4f418 has introduced
regressions when testing using the READ1 mechanism. The reason for that
is the new failure path in proc test_gdb_complete_tab_unique, which
looks for GDB suggesting more than what the test inputted, but not the
correct answer, followed by a white space. Consider the following case:

int foo(int bar, int baz);

Sending the command "break foo<tab>" to GDB will return

break foo(int, int)

which easily fits the buffer in normal testing, so everything works, but
when reading one character at a time, the test will find the partial
"break foo(int, " and assume that there was a mistake, so we get a
spurious FAIL.

That change was added because we wanted to avoid forcing a completion
failure to fail through timeout, which it had to do because there is no
way to verify that the output is done, mostly because when I was trying
to solve a different problem I kept getting reading errors and testing
completion was frustrating.

This commit implements a better way to avoid that frustration, by first
testing gdb's complete command and only if that passes we will test tab
completion. The difference is that when testing with the complete
command, we can tell when the output is over when we receive the GDB
prompt again, so we don't need to rely on timeouts. With this, the
change to test_gdb_complete_tab_unique has been removed as that test
will only be run and fail in the very unlikely scenario that tab
completion is different than command completion.

Approved-By: Andrew Burgess <aburgess@redhat.com>
gdb/testsuite/lib/completion-support.exp