]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Disable CLI styling by default in Term::prepare_tui
authorTom de Vries <tdevries@suse.de>
Thu, 14 Aug 2025 13:49:20 +0000 (15:49 +0200)
committerTom de Vries <tdevries@suse.de>
Thu, 14 Aug 2025 13:49:20 +0000 (15:49 +0200)
On x86_64-freebsd, with test-case gdb.tui/main.exp, I ran into a failure to
match the output of the file command, for which I submitted a patch [1].

However, after switching to TERM=ansiw for bsd, I could no longer reproduce
the problem.

Investigation showed that the difference was caused by CLI styling.

A command:
...
(gdb) file <filename>
...
gives an output:
...
Reading symbols from <filename>...
(gdb)
...

On x86_64-linux, with CLI styling I get:
...
Reading symbols from ^[[32m/data/vries/gdb/leap-15-6/build/gdb/testsuite/outputs/gdb.tui/main/main^[[39m^[[0;10m...
...

After disabling CLI styling using "set style enabled off", I simply get:
...
Reading symbols from /data/vries/gdb/leap-15-6/build/gdb/testsuite/outputs/gdb.tui/main/main...
...
and run into the same failure as on x86_64-freebsd.

The extra csi sequence "^[[32m" causes an additional matching attempt in
Term::wait_for, and the way we're currently matching relies on this:
...
send_gdb "file [standard_output_file $testfile]\n"
gdb_assert { [Term::wait_for "Reading symbols from"] } "file command"
...

Make the TUI testsuite more stable and matching more simple by disabling CLI
styling by default, and:
- fix the resulting fallout in test-cases gdb.tui/main.exp and
  gdb.tui/new-layout.exp, and
- re-enable CLI styling in the one test-case that needs it:
  gdb.tui/tui-disasm-styling.exp.

Tested on x86_64-linux.

[1] https://sourceware.org/pipermail/gdb-patches/2025-June/218942.html

gdb/testsuite/gdb.tui/main.exp
gdb/testsuite/gdb.tui/new-layout.exp
gdb/testsuite/gdb.tui/tui-disasm-styling.exp
gdb/testsuite/lib/tuiterm.exp

index d6960c7b849cf38d939bfc4c0f69a461b4a626a8..e49da35edde57e25300bc93e73c004e075bcc7ad 100644 (file)
@@ -43,7 +43,10 @@ if {![Term::enter_tui]} {
 }
 
 send_gdb "file [standard_output_file $testfile]\n"
-gdb_assert { [Term::wait_for "Reading symbols from"] } "file command"
+# Matching the output is difficult because it may or may not wrap.  Simply
+# match the resulting prompt.
+gdb_assert { [Term::wait_for ""] } "file command"
+
 Term::check_contents "show main after file" \
     [string_to_regexp "|___[format %06d $nr]_$line"]
 
index f5179973e5b89ca2d2f2c605811f6d57193e3e78..914e10c68d626af85beb0ec242a7133e6fefe1d0 100644 (file)
@@ -150,4 +150,7 @@ Term::check_box "before cmd_only: src box in src layout" 0 0 80 15
 Term::command "layout cmd_only"
 
 Term::command "layout src"
+
+# Flush out and check the resulting src box.
+Term::command "print 1"
 Term::check_box "after cmd_only: src box in src layout" 0 0 80 15
index 513d787b4b79be40c05c6dd3101626f8990682dd..43b8ecf5fb09ae09db4637e39c746fe566c90ea8 100644 (file)
@@ -43,6 +43,9 @@ if {![Term::enter_tui]} {
     return
 }
 
+# Proc enter_tui switches off styling, re-enable it.
+Term::command "set style enabled on"
+
 Term::command "layout asm"
 Term::check_box "asm box" 0 0 80 15
 
index 7b8745ab62bb5c1bc657e7b0bf73abf56f6eba36..21640178092395b8b8d3ff087f6efe9d1c2b1aae 100644 (file)
@@ -1013,6 +1013,10 @@ namespace eval Term {
 
        gdb_test_no_output "set tui border-kind ascii"
        gdb_test_no_output "maint set tui-resize-message on"
+       # When matching GDB output using Term::wait_for, the number of
+       # matching attempts in wait_for can be influenced by CLI styling.
+       # Disable it by default to avoid this.
+       gdb_test_no_output "set style enabled off"
        return 1
     }