From 8e2233c36a0f8ae98e7607de9822c1bc4284fa1e Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Sat, 27 Sep 2025 01:13:16 +0200 Subject: [PATCH] [gdb/testsuite] Remove wait in gdb.tui/pr30056.exp In test-case gdb.tui/pr30056.exp, we have: ... # Send arrow-right. send_gdb "\033\[C" # We need the arrow-right to be processed by readline, before we # send the following ^C. Waiting 1 ms seems to do that. after 1 ... Waiting for an effect by sleeping is fragile. The reason we're doing so is that we're waiting for an effect that is not visible: the arrow-right is meant to horizontally scroll the source window, but since there's no source, nothing happens. Fix this by using an executable in the test-case, with a source file containing a comment long enough to make horizontal scrolling possible. Fixing this means we no longer run into PR33371, so that PR will need its own test-case. Tested on x86_64-linux. Approved-By: Tom Tromey --- gdb/testsuite/gdb.tui/pr30056.exp | 15 ++++++++++----- gdb/testsuite/gdb.tui/tui-long-line.c | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 gdb/testsuite/gdb.tui/tui-long-line.c diff --git a/gdb/testsuite/gdb.tui/pr30056.exp b/gdb/testsuite/gdb.tui/pr30056.exp index dd3b25ce7d8..742115c918a 100644 --- a/gdb/testsuite/gdb.tui/pr30056.exp +++ b/gdb/testsuite/gdb.tui/pr30056.exp @@ -22,11 +22,17 @@ require {have_host_locale C.UTF-8} tuiterm_env +standard_testfile tui-long-line.c + +if { [build_executable "failed to prepare" $testfile $srcfile] == -1 } { + return +} + save_vars { env(LC_ALL) } { setenv LC_ALL C.UTF-8 # Start terminal. - Term::clean_restart 24 80 + Term::clean_restart 24 80 $testfile # Start TUI. if {![Term::enter_tui]} { @@ -46,10 +52,9 @@ save_vars { env(LC_ALL) } { # Send arrow-right. send_gdb "\033\[C" - - # We need to the arrow-right to be processed by readline, before we - # send the following ^C. Waiting 1 ms seems to do that. - after 1 + # Wait for arrow-right effect. + gdb_assert { [Term::wait_for_region_contents 1 5 78 1 \ + [string_to_regexp " ain (void)"]] } "arrow right" # Send ^C. send_gdb "\003" diff --git a/gdb/testsuite/gdb.tui/tui-long-line.c b/gdb/testsuite/gdb.tui/tui-long-line.c new file mode 100644 index 00000000000..8f1d6eb4869 --- /dev/null +++ b/gdb/testsuite/gdb.tui/tui-long-line.c @@ -0,0 +1,24 @@ +/* This testcase is part of GDB, the GNU debugger. + + Copyright 2025 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + + +int +main (void) +{ + /* This is a comment that is meant to be longer than the usual 80 characters width of a tuiterm. */ + return 0; +} -- 2.47.3