Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[gdb/testsuite] Fix prompt parsing in capture_command_output
I noticed in capture_command_output that the output of a single command is matched using two gdb_test_multiples: - the first one matching the echoed command and skipping an optional prefix, - the second one matching the output and the prompt. This is error-prone, because the first gdb_test_multiple has implicit clauses which may consume the prompt. The problem is easy to spot with an example. First consider: ... set output [capture_command_output "print 1" "\\\$1 = "] gdb_assert { [string equal $output "1"] } ... for which we get: ... PASS: [string equal $output "1"] ... If we change the prefix string to a no-match, say "1 = ", and update the output string match accordingly, we get instead: ... FAIL: capture_command_output for print 1 FAIL: [string equal $output "\$1 = 1"] ... The first FAIL is produced by the first gdb_test_multiple, consuming the prompt. The second gdb_test_multiple then silently times out waiting for another prompt, after which the second FAIL is produced. Note that the timeout is silent because the gdb_test_multiple is called with an empty message argument. The second FAIL is because capture_command_output returns "", given that all the command output was consumed by the first gdb_test_multiple. Fix this by rewriting capture_command_output to use only a single gdb_test_multiple. Tested on x86_64-linux.
- Loading branch information