Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>,	Hannes Domani <ssbssa@yahoo.de>,
	Andrew Burgess <andrew.burgess@embecosm.com>
Subject: [PATCH 3/6] gdb/testsuite/tui: Introduce check_box_contents
Date: Tue, 07 Jan 2020 11:52:00 -0000	[thread overview]
Message-ID: <ad70447feec4d02cda9b98b2f1f644515b75e47c.1578397591.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1578397591.git.andrew.burgess@embecosm.com>
In-Reply-To: <cover.1578397591.git.andrew.burgess@embecosm.com>

A new test procedure for matching the contents of one screen box
against a regexp.  This can be used to match the contents of one TUI
window against a regexp without any of the borders, or other windows
being included in the matched output (as is currently the case with
check_contents).

This will be used in a later commit.

gdb/testsuite/ChangeLog:

	* lib/tuiterm.exp (Term::check_box_contents): New proc.

Change-Id: Icf795bf38dd9295e282a34eecc318a9cdbc73926
---
 gdb/testsuite/ChangeLog       |  4 ++++
 gdb/testsuite/lib/tuiterm.exp | 31 +++++++++++++++++++++++++++++++
 2 files changed, 35 insertions(+)

diff --git a/gdb/testsuite/lib/tuiterm.exp b/gdb/testsuite/lib/tuiterm.exp
index 9ac599b6f2d..0307745d879 100644
--- a/gdb/testsuite/lib/tuiterm.exp
+++ b/gdb/testsuite/lib/tuiterm.exp
@@ -600,6 +600,37 @@ namespace eval Term {
 	}
     }
 
+    # Check the contents of a box on the screen.  This is a little
+    # like check_contents, but doens't check the whole screen
+    # contents, only the contents of a single box.  This procedure
+    # includes (effectively) a call to check_box to ensure there is a
+    # box where expected, if there is then the contents of the box are
+    # matched against REGEXP.
+    proc check_box_contents {test_name x y width height regexp} {
+	variable _chars
+
+	set why [_check_box $x $y $width $height]
+	if {$why != ""} {
+	    dump_screen
+	    fail "$test_name (box check: $why)"
+	    return
+	}
+
+	# Now grab the contents of the box, join each line together
+	# with a newline character and match against REGEXP.
+	set result ""
+	for {set yy [expr {$y + 1}]} {$yy < [expr {$y + $height - 1}]} {incr yy} {
+	    for {set xx [expr {$x + 1}]} {$xx < [expr {$x + $width - 1}]} {incr xx} {
+		append result [lindex $_chars($xx,$yy) 0]
+	    }
+	    append result "\n"
+	}
+
+	if {![gdb_assert {[regexp -- $regexp $result]} $test_name]} {
+	    dump_screen
+	}
+    }
+
     # A debugging function to dump the current screen, with line
     # numbers.
     proc dump_screen {} {
-- 
2.14.5


  parent reply	other threads:[~2020-01-07 11:52 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20191221153325.6961-1-ssbssa.ref@yahoo.de>
2019-12-21 15:34 ` [RFC][PATCH] Call tui_before_prompt in do_scroll_vertical Hannes Domani via gdb-patches
2019-12-22  0:58   ` Andrew Burgess
2019-12-22  1:25     ` Hannes Domani via gdb-patches
2019-12-23  0:03     ` Tom Tromey
2019-12-23  0:19       ` Hannes Domani via gdb-patches
2019-12-23  1:23       ` Andrew Burgess
2020-01-07 11:52       ` [PATCH 2/6] gdb/testsuite/tui: Split enter_tui into two procs Andrew Burgess
2020-01-07 19:19         ` Tom Tromey
2020-01-07 11:52       ` [PATCH 5/6] gdb: Fix scrolling in TUI Andrew Burgess
2020-01-07 19:36         ` Tom Tromey
2020-01-07 11:52       ` [PATCH 4/6] gdb/tui: Fix 'layout asm' before the inferior has started Andrew Burgess
2020-01-07 19:31         ` Tom Tromey
2020-01-07 11:52       ` [PATCH 6/6] gdb/tui: Link source and assembler scrolling .... again Andrew Burgess
2020-01-07 19:37         ` Tom Tromey
2020-01-07 11:52       ` Andrew Burgess [this message]
2020-01-07 19:30         ` [PATCH 3/6] gdb/testsuite/tui: Introduce check_box_contents Tom Tromey
2020-01-07 11:52       ` [PATCH 0/6] Vertical scrolling and another small bug fix Andrew Burgess
2020-01-07 19:38         ` Tom Tromey
2020-01-09 23:28           ` Andrew Burgess
2020-01-07 11:52       ` [PATCH 1/6] gdb/testsuite/tui: Always dump_screen when asked Andrew Burgess
2020-01-07 18:54         ` Tom Tromey

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=ad70447feec4d02cda9b98b2f1f644515b75e47c.1578397591.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    --cc=ssbssa@yahoo.de \
    --cc=tom@tromey.com \
    /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