Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed 3/7] [gdb/testsuite] Factor out small_initial in gdb.tui/tuiterm.exp
Date: Wed, 14 Oct 2026 16:58:34 +0200	[thread overview]
Message-ID: <20261014145838.3560108-4-tdevries@suse.de> (raw)
In-Reply-To: <20261014145838.3560108-1-tdevries@suse.de>

There are many tests in gdb.tui/tuiterm.exp that check that the display hasn't
changed by comparing it to its initial state:
...
    check "backspace one" {
	"abcdefgh"
	"ijklmnop"
	"qrstuvwx"
	"yz01234 "
    } 0 2
...

Factor out a new variable small_initial, and use it 35 times.
---
 gdb/testsuite/gdb.tui/tuiterm.exp | 253 ++++++------------------------
 1 file changed, 45 insertions(+), 208 deletions(-)

diff --git a/gdb/testsuite/gdb.tui/tuiterm.exp b/gdb/testsuite/gdb.tui/tuiterm.exp
index b6330b0d6a8..f09e1514e9b 100644
--- a/gdb/testsuite/gdb.tui/tuiterm.exp
+++ b/gdb/testsuite/gdb.tui/tuiterm.exp
@@ -64,6 +64,14 @@ proc setup_terminal { cols rows } {
     }
 }
 
+# Variable that represents the state of the small terminal after setup_small.
+set small_initial {
+    "abcdefgh"
+    "ijklmnop"
+    "qrstuvwx"
+    "yz01234 "
+}
+
 # Most tests are fine with a small terminal.  This proc initializes the terminal
 # with 8 columns and 4 rows, with the following content:
 #
@@ -79,17 +87,11 @@ proc setup_terminal { cols rows } {
 proc setup_small {} {
     setup_terminal 8 4
 
-    Term::_insert "abcdefgh"
-    Term::_insert "ijklmnop"
-    Term::_insert "qrstuvwx"
-    Term::_insert "yz01234"
+    foreach line $::small_initial {
+	Term::_insert [string trim $line]
+    }
 
-    check "check after setup" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 7 3
+    check "check after setup" $::small_initial 7 3
 }
 
 # Some tests require a larger terminal.  This proc initializes the terminal with
@@ -108,41 +110,21 @@ proc test_backspace {} {
     Term::_move_cursor 1 2
 
     Term::_ctl_0x08 0
-    check "backspace one" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "backspace one" $::small_initial 0 2
 
     # Cursor should not move if it is already at column 0.
     Term::_ctl_0x08 0
-    check "backspace 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "backspace 2" $::small_initial 0 2
 
     # Cursor should wrap to previous line.
     Term::_ctl_0x08 1
-    check "backspace 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 7 1
+    check "backspace 3" $::small_initial 7 1
 }
 
 proc test_linefeed { } {
     Term::_move_cursor 1 2
     Term::_ctl_0x0a
-    check "linefeed" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 1 3
+    check "linefeed" $::small_initial 1 3
 }
 
 proc test_linefeed_scroll { } {
@@ -160,20 +142,10 @@ proc test_linefeed_scroll { } {
 proc test_carriage_return { } {
     Term::_move_cursor 1 2
     Term::_ctl_0x0d
-    check "carriage return 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "carriage return 1" $::small_initial 0 2
 
     Term::_ctl_0x0d
-    check "carriage return 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "carriage return 2" $::small_initial 0 2
 }
 
 proc test_insert_characters { } {
@@ -263,228 +235,108 @@ proc test_cursor_up { } {
     Term::_move_cursor 2 3
 
     Term::_csi_A
-    check "cursor up 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 2 2
+    check "cursor up 1" $::small_initial 2 2
 
     Term::_csi_A 2
-    check "cursor up 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 2 0
+    check "cursor up 2" $::small_initial 2 0
 
     Term::_csi_A 1
-    check "cursor up 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 2 0
+    check "cursor up 3" $::small_initial 2 0
 }
 
 proc test_cursor_down { } {
     Term::_move_cursor 1 0
 
     Term::_csi_B
-    check "cursor down 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 1 1
+    check "cursor down 1" $::small_initial 1 1
 
     Term::_csi_B 2
-    check "cursor down 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 1 3
+    check "cursor down 2" $::small_initial 1 3
 
     Term::_csi_B 1
-    check "cursor down 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 1 3
+    check "cursor down 3" $::small_initial 1 3
 }
 
 proc test_cursor_forward { } {
     Term::_move_cursor 0 1
 
     Term::_csi_C
-    check "cursor forward 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 1 1
+    check "cursor forward 1" $::small_initial 1 1
 
     Term::_csi_C 6
-    check "cursor forward 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 7 1
+    check "cursor forward 2" $::small_initial 7 1
 
     Term::_csi_C 1
-    check "cursor forward 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 7 1
+    check "cursor forward 3" $::small_initial 7 1
 }
 
 proc test_cursor_backward { } {
     Term::_move_cursor 7 1
 
     Term::_csi_D
-    check "cursor backward 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 6 1
+    check "cursor backward 1" $::small_initial 6 1
 
     Term::_csi_D 6
-    check "cursor backward 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 1
+    check "cursor backward 2" $::small_initial 0 1
 
     Term::_csi_D 1
-    check "cursor backward 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 1
+    check "cursor backward 3" $::small_initial 0 1
 }
 
 proc test_cursor_next_line { } {
     Term::_move_cursor 2 0
 
     Term::_csi_E
-    check "cursor next line 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 1
+    check "cursor next line 1" $::small_initial 0 1
 
     Term::_move_cursor 2 1
     Term::_csi_E 2
-    check "cursor next line 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 3
+    check "cursor next line 2" $::small_initial 0 3
 
     Term::_move_cursor 2 3
     Term::_csi_E 1
-    check "cursor next line 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 3
+    check "cursor next line 3" $::small_initial 0 3
 }
 
 proc test_cursor_previous_line { } {
     Term::_move_cursor 2 3
 
     Term::_csi_F
-    check "cursor previous line 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "cursor previous line 1" $::small_initial 0 2
 
     Term::_move_cursor 2 2
     Term::_csi_F 2
-    check "cursor previous line 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 0
+    check "cursor previous line 2" $::small_initial 0 0
 
     Term::_move_cursor 2 0
     Term::_csi_F 1
-    check "cursor previous line 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 0
+    check "cursor previous line 3" $::small_initial 0 0
 }
 
 proc test_horizontal_absolute { } {
     Term::_move_cursor 2 2
     Term::_csi_G
-    check "cursor horizontal absolute 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "cursor horizontal absolute 1" $::small_initial 0 2
 
     Term::_move_cursor 2 2
     Term::_csi_G 4
-    check "cursor horizontal absolute 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 3 2
+    check "cursor horizontal absolute 2" $::small_initial 3 2
 
     Term::_csi_G 8
-    check "cursor horizontal absolute 3" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 7 2
+    check "cursor horizontal absolute 3" $::small_initial 7 2
 
     Term::_csi_G 9
-    check "cursor horizontal absolute 4" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 7 2
+    check "cursor horizontal absolute 4" $::small_initial 7 2
 
     Term::_csi_`
-    check "horizontal position absolute 1" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 0 2
+    check "horizontal position absolute 1" $::small_initial 0 2
 }
 
 proc test_cursor_position { } {
     Term::_move_cursor 1 1
 
     Term::_csi_H 3 5
-    check "cursor horizontal absolute 2" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 4 2
+    check "cursor horizontal absolute 2" $::small_initial 4 2
 }
 
 proc test_cursor_horizontal_forward_tabulation { } {
@@ -682,28 +534,13 @@ proc test_vertical_line_position_absolute { } {
     Term::_move_cursor 2 1
 
     Term::_csi_d
-    check "default param" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 2 0
+    check "default param" $::small_initial 2 0
 
     Term::_csi_d 3
-    check "explicit param" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 2 2
+    check "explicit param" $::small_initial 2 2
 
     Term::_csi_d 100
-    check "try to move off-display" {
-	"abcdefgh"
-	"ijklmnop"
-	"qrstuvwx"
-	"yz01234 "
-    } 2 3
+    check "try to move off-display" $::small_initial 2 3
 }
 
 proc test_insert_line { } {
-- 
2.51.0


  parent reply	other threads:[~2026-10-14 14:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-14 14:58 [pushed 0/7] [gdb/testsuite] Tuiterm maintenance Tom de Vries
2026-10-14 14:58 ` [pushed 1/7] [gdb/testsuite] Remove unused declarations in lib/tuiterm.exp Tom de Vries
2026-10-14 14:58 ` [pushed 2/7] [gdb/testsuite] Factor out Term::_copy_line Tom de Vries
2026-10-14 14:58 ` Tom de Vries [this message]
2026-10-14 14:58 ` [pushed 4/7] [gdb/testsuite] Add Term::check_size Tom de Vries
2026-10-14 14:58 ` [pushed 5/7] [gdb/testsuite] Work around namespace problem in tclint plugin Tom de Vries
2026-10-14 14:58 ` [pushed 6/7] [gdb/testsuite] Fix typo in tclint-plugin.py Tom de Vries
2026-10-14 14:58 ` [pushed 7/7] [gdb/testsuite] Fix test names in gdb.tui/tuiterm.exp Tom de Vries

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261014145838.3560108-4-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox