From patchwork Tue Jan 7 11:52:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 37236 Received: (qmail 22756 invoked by alias); 7 Jan 2020 11:52:31 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 22667 invoked by uid 89); 7 Jan 2020 11:52:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=xx, yy, HX-Languages-Length:2017, screen X-HELO: mail-wr1-f44.google.com Received: from mail-wr1-f44.google.com (HELO mail-wr1-f44.google.com) (209.85.221.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 07 Jan 2020 11:52:30 +0000 Received: by mail-wr1-f44.google.com with SMTP id q10so14654528wrm.11 for ; Tue, 07 Jan 2020 03:52:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=RI3JDq8POshEtzGEwAf0xcywT/huf25BGHPRMW9vpCY=; b=TnJl09EpAChiZwfGix7aLA11s2SE1ZBAN+HQ9Dn0prNMP8XIjUrOJBqkQHMOx0c+um H+aAKtiJv36r9mSp6by1NwqfUwRIS3XfIM45ipwJVLhU0SwFdezYpNka/ZYRvOeVuKms tTZfvpqqqi6hbJKKbRf07+Yfs92cSqA2CdFjz5t8dv+qEkQdTABeyaiWKgguZpRsZhwu M+Ts0krHK5RuPu5EO93eH+N3MLPG3Zc/lbEhhbrLdbRLAJJzbcxsTg5ZcNajmcf3H8AD 7G2mO50YLPyMT40DQz0LvD/5LxbHnR5DGifyCOX19q4cmzmz1DABqduu0OcHRZ6gQSz3 UYhg== Return-Path: Received: from localhost (host86-186-80-236.range86-186.btcentralplus.com. [86.186.80.236]) by smtp.gmail.com with ESMTPSA id i8sm76336553wro.47.2020.01.07.03.52.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jan 2020 03:52:26 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Tom Tromey , Hannes Domani , Andrew Burgess Subject: [PATCH 3/6] gdb/testsuite/tui: Introduce check_box_contents Date: Tue, 7 Jan 2020 11:52:16 +0000 Message-Id: In-Reply-To: References: In-Reply-To: References: <874kxrc3ha.fsf@tromey.com> X-IsSubscribed: yes 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 {} {