]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Clean up globals saving in gdb.tui/tuiterm.exp
authorTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:27 +0000 (10:13 +0100)
committerTom de Vries <tdevries@suse.de>
Fri, 20 Mar 2026 09:13:27 +0000 (10:13 +0100)
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 <tom@tromey.com>
gdb/testsuite/gdb.tui/tuiterm.exp

index beab9f7a304e6926c5bebd7f4124f9bd8630a715..ccf26195ddc43991afeadd11e84d144a39f51710 100644 (file)
@@ -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 {