binutils-gdb/gdb/testsuite/gdb.tui
Tom de Vries 301b21e0df [gdb/testsuite] Fix check-read1 FAIL in gdb.tui/corefile-run.exp
With test-case gdb.tui/corefile-run.exp and make target check-read1, I run
into:
...
FAIL: gdb.tui/corefile-run.exp: run until the end
...

In more detail, using -v:
...
PASS: gdb.tui/corefile-run.exp: load corefile
^M+++ _ctl_0x0d
^[[17d+++ _csi_d <<<17>>>
^[[M+++ _csi_M <<<>>>
^[[24d+++ _csi_d <<<24>>>
(INSERT <<(>>
gINSERT <<g>>
dINSERT <<d>>
bINSERT <<b>>
)INSERT <<)>>
 INSERT << >>
FAIL: gdb.tui/corefile-run.exp: run until the end
...

With some debugging code added in wait_for, what happens becomes more clear:
...
	    if {[regexp -- $wait_for $prev]} {
+		verbose -log "\nwait_for: MATCHED line ($_cur_y): \"$prev\""
+		verbose -log "wait_for: AGAINST regexp: \"$wait_for\""
...

In corefile-run.exp, we execute:
...
Term::command "run"
...
and in proc Term::command, we send the command, and then call wait_for:
...
    proc command {cmd} {
        send_gdb "$cmd\n"
        wait_for [string_to_regexp $cmd]
    }
...
which first waits for the command string, and then for the prompt.

In this case however, the matching of the command string triggers on a
previous line:
...
wait_for: MATCHED line (16): \
  "(gdb) core-file corefile-run.core[New LWP 6426] <lots-of-spaces>"
wait_for: AGAINST regexp: "run"
...
and from there on things go out of sync, eventually resulting in the FAIL.

Fix this in proc command by more precisely specifying the expected pattern:
adding a ^$gdb_prompt prefix.

Add a command_no_prompt_prefix variant to use for initial terminal commands
where there's no prompt yet.

Tested gdb.tui/*.exp on x86_64-linux, with make target check and check-read1.

gdb/testsuite/ChangeLog:

2020-03-13  Tom de Vries  <tdevries@suse.de>

	* lib/tuiterm.exp (Term::command_no_prompt_prefix): New proc.
	(Term::command): Use prompt prefix.
	(Term::enter_tui): Use command_no_prompt_prefix instead of prefix.
	* gdb.tui/tui-layout-asm-short-prog.exp: Use
	command_no_prompt_prefix instead of prefix.
	* gdb.tui/tui-layout-asm.exp: Same.
2020-03-13 00:31:15 +01:00
..
basic.exp gdb/tui: Link source and assembler scrolling .... again 2020-01-09 23:11:47 +00:00
completion.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
corefile-run.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
empty.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
list-before.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
list.exp gdb: use tui_set_layout not show_layout to fix window focus 2020-01-05 21:49:05 +00:00
main.exp Make "file" clear TUI source window 2020-01-19 13:08:48 -07:00
new-layout.exp Add horizontal splitting to TUI layout 2020-02-22 11:48:33 -07:00
regs.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
resize.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
tui-disasm-long-lines.c Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
tui-disasm-long-lines.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
tui-layout-asm-short-prog.exp [gdb/testsuite] Fix check-read1 FAIL in gdb.tui/corefile-run.exp 2020-03-13 00:31:15 +01:00
tui-layout-asm-short-prog.S gdb/tui: Disassembler scrolling of very small programs 2020-01-31 00:41:06 +00:00
tui-layout-asm.exp [gdb/testsuite] Fix check-read1 FAIL in gdb.tui/corefile-run.exp 2020-03-13 00:31:15 +01:00
tui-layout.c Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
tui-layout.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
tui-missing-src.exp gdb: Catch exceptions if the source file is not found 2020-02-06 17:54:59 +01:00
tui-nl-filtered-output.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00
winheight.exp Update copyright year range in all GDB files. 2020-01-01 10:20:53 +04:00