[binutils-gdb] [gdb/testsuite] Clean up globals saving in gdb.tui/tuiterm.exp
Tom de Vries via Gdb-cvs <[email protected]>
| Newsgroups | gmane.comp.gdb.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d285cc13c072f909591ba2f9ae3b794e1c812ff1 commit d285cc13c072f909591ba2f9ae3b794e1c812ff1 Author: Tom de Vries <[email protected]> Date: Fri Mar 20 10:13:27 2026 +0100 [gdb/testsuite] Clean up globals saving in gdb.tui/tuiterm.exp In test-case gdb.tui/tuiterm.exp, I came across this proc: ... proc setup_terminal { cols rows } { setenv TERM ansi Term::_setup $rows $cols } ... and I wondered why we're not using save_vars ::env(TERM) in here. Then I found out that this happens via run_one_test_small, which calls setup_small, which calls setup_terminal: ... proc setup_small {} { setup_terminal 8 4 ... } ... proc run_one_test_small { test_proc_name } { save_vars { env(TERM) stty_init } { setup_small $test_proc_name } } ... There are a couple of problems here: - the proc test_attrs calls setup_terminal, but doesn't do any saving/restoring - the saving/restoring in run_one_test_small doesn't work, because the variable names don't have global scope - both env(TERM) and stty_init aren't actually used in the test. Fix this by: - dropping the setting of env(TERM) - moving the saving/restoring of stty_init to setup_terminal Approved-By: Tom Tromey <[email protected]> Diff: --- gdb/testsuite/gdb.tui/tuiterm.exp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp index beab9f7a304..ccf26195ddc 100644 --- a/gdb/testsuite/gdb.tui/tuiterm.exp +++ b/gdb/testsuite/gdb.tui/tuiterm.exp @@ -55,8 +55,13 @@ proc check { test expected_contents expected_cur_col expected_cur_row } { } proc setup_terminal { cols rows } { - setenv TERM ansi - Term::_setup $rows $cols + # Proc Term::_setup sets variable stty_init. The stty_init variable is + # used by Expect to configure the pty of processes started using Expect + # command spawn. This test doesn't use the spawn command, so revert to + # the original setting ASAP. + save_vars { ::stty_init } { + Term::_setup $rows $cols + } } # Most tests are fine with a small terminal. This proc initializes the terminal @@ -843,19 +848,15 @@ proc_with_prefix test_with_tuiterm {} { # Run proc TEST_PROC_NAME with a "small" terminal. proc run_one_test_small { test_proc_name } { - save_vars { env(TERM) stty_init } { - setup_small - $test_proc_name - } + setup_small + $test_proc_name } # Run proc TEST_PROC_NAME with a "large" terminal. proc run_one_test_large { test_proc_name } { - save_vars { env(TERM) stty_init } { - setup_large - $test_proc_name - } + setup_large + $test_proc_name } foreach_with_prefix test {