From patchwork Fri Jan 6 10:25:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 62779 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 111CA38493EC for ; Fri, 6 Jan 2023 10:26:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 111CA38493EC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673000778; bh=Y4eejOkdUfbmVdpO81F1vKrPyRnS9eT5e5C3xyIzRq8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=QmhKeN2Ctx9ak3NlCvQ0+biRv0Q1KM5CfbPE+nH1w8+NCwTcWrmcceD/KqKvpHuqM gfYXo5tLy5d/zVTogLxJ/2CMEA9OfLU9lssTwB6Zr3GFuwbhPZZ0Rhl6swGDfBnCjE KV553g1u5Pnw7cGhKYWI+J4eG65ncEHzPvpICBBs= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id EC71D3858D28 for ; Fri, 6 Jan 2023 10:25:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC71D3858D28 Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-247-13Y8DoLyNE2wN6_XnRB9fQ-1; Fri, 06 Jan 2023 05:25:50 -0500 X-MC-Unique: 13Y8DoLyNE2wN6_XnRB9fQ-1 Received: by mail-ej1-f69.google.com with SMTP id ne1-20020a1709077b8100b007c198bb8c0eso875071ejc.8 for ; Fri, 06 Jan 2023 02:25:50 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Y4eejOkdUfbmVdpO81F1vKrPyRnS9eT5e5C3xyIzRq8=; b=gSTT7obgakQQT31DyJrYH37t986XkiHp6P+AMXR+zSSVttCNVjnLpymcJQNuxUM9q7 JxSTt6kT56iqLaRoucVDNh4M80sPzbIWjWGuluMOepz+e38f7431fWUQLQq+KZGDldhp N+LL+M6Vh/54rPu+UTTXIaGPpln6kYhAYvSscFCXXZuMxS7r0xtnCTOHB/DqU/fXNjt2 EFtHwnof3VY8S0exmJvy6FSCIFajXxcPPa+jyXEkhdxfKEfApgiYbs9e4NHV08bZh7T0 kDyE0Z2yfw01ZEVOQXWjV/jMlKy/CvE9Yx7Q8LqsqvylNi76/9Iww23apSfXcud96xhx 3bqQ== X-Gm-Message-State: AFqh2kqas2gyFh+JI+IGWzFFww6vJRnNUSKiMuYmd72XDHTIxOlD/tcd h+xM1ZIhgSkJISqfOKpXr9dJZrAs/J6rOj0XhJLvL96n7+djiWhZfmihxI0ow6/CSXunQMbimz1 cbaC35fSeV6h7lQdvwkhPuRcs6Jdyv0Ljhc/mAri25hU9We1/tuvgryxPc9trwcHPRThbzDee+Q == X-Received: by 2002:a05:6402:1508:b0:489:99c1:d3cc with SMTP id f8-20020a056402150800b0048999c1d3ccmr22214379edw.24.1673000749145; Fri, 06 Jan 2023 02:25:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXsT7Pk4neftuPFOTVJl/3tQt4Ea4vPOXmj9eqas+i3K547ifD8n/8huEOfd06+o+4Q3RRJ4jw== X-Received: by 2002:a05:6402:1508:b0:489:99c1:d3cc with SMTP id f8-20020a056402150800b0048999c1d3ccmr22214367edw.24.1673000748921; Fri, 06 Jan 2023 02:25:48 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id b12-20020a05640202cc00b0046ee136fa3bsm346352edx.69.2023.01.06.02.25.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Jan 2023 02:25:48 -0800 (PST) To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 01/15] gdb/testsuite: extend gdb.tui/tui-layout.exp test script Date: Fri, 6 Jan 2023 10:25:28 +0000 Message-Id: <3adda76c2743f4b5c7c811cc68a212ec9fcf3f57.1673000632.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrew Burgess via Gdb-patches From: Andrew Burgess Reply-To: Andrew Burgess Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" In passing I noticed that the gdb.tui/tui-layout.exp test script was a little strange, it tests the layout command multiple times, but never sets up our ANSI terminal emulator, so every layout command fails with a message about the terminal lacking the required abilities. It turns out that this was caused by this commit: commit 9162a27c5f5828240b53379d735679e2a69a9f41 Date: Tue Nov 13 11:59:03 2018 -0700 Change gdb test suite's TERM setting This was when we changed the testsuite to set the TERM environment variable to "dumb" by default. After this, any tui test that didn't set the terminal mode back to 'ansi' would fail to activate tui mode. For the tui-layout.exp test it just so happens that the test patterns are generic enough that the test continued to pass, even after this change. In this commit I have updated the test so we now check the layout command both with a 'dumb' terminal and with the 'ansi' terminal. When testing with the 'ansi' terminal, I have some limited validation that GDB correctly entered tui mode. I figured that it is probably worth having at least one test in the test suite that deliberately tries to enter tui mode in a dumb terminal, it would be sad if we one day managed to break GDB such that this caused a crash, and never noticed. --- gdb/testsuite/gdb.tui/tui-layout.exp | 57 ++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 11 deletions(-) diff --git a/gdb/testsuite/gdb.tui/tui-layout.exp b/gdb/testsuite/gdb.tui/tui-layout.exp index 97734cf7b68..e69760193c5 100644 --- a/gdb/testsuite/gdb.tui/tui-layout.exp +++ b/gdb/testsuite/gdb.tui/tui-layout.exp @@ -16,6 +16,8 @@ # Minimal testcase that just checks that the various "layout $foo" # commands do not cause gdb to crash. +tuiterm_env + standard_testfile if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { @@ -26,13 +28,33 @@ if {[skip_tui_tests]} { return } -# Test one layout command. EXECUTION indicates whether to activate -# the layout with or without execution. +# Run one test of the 'layout' command, selecting LAYOUT_NAME. +# +# TERMINAL should be either 'dumb' or 'ansi'. When TERMINAL is 'dumb' +# then GDB is started in a terminal that does not support tui mode, in +# this case the layout command is expected to fail. +# +# When TERMINAL is 'ansi' then GDB is started using our emulated ANSI +# terminal, and the layout command is expected to succeed. +# +# When EXECUTION is true then a call to runto_main is used, otherwise +# this call is skipped and the inferior is left in whatever state it +# happens to be in after a call to clean_restart. -proc test_layout {layout execution} { +proc test_layout_or_focus {layout_name terminal execution} { global binfile gdb_prompt - clean_restart $binfile + set dumb_terminal [string equal $terminal "dumb"] + + if {$dumb_terminal} { + clean_restart $binfile + } else { + Term::clean_restart 24 80 $binfile + if {![Term::prepare_for_tui]} { + unsupported "TUI not supported" + return + } + } if {$execution} { if {![runto_main]} { @@ -40,16 +62,29 @@ proc test_layout {layout execution} { } } - set test "layout command" - gdb_test_multiple "layout $layout" $test { - -re "$gdb_prompt $" { - pass $test + if {$dumb_terminal} { + gdb_test "layout $layout_name" \ + "Cannot enable the TUI: terminal doesn't support cursor addressing \\\[TERM=dumb\\\]" + } else { + Term::command_no_prompt_prefix "layout $layout_name" + if {$layout_name == "asm"} { + Term::check_box "asm box" 0 0 80 15 + } elseif {$layout_name == "reg"} { + Term::check_box "reg box" 0 0 80 8 + Term::check_box "src box" 0 7 80 8 + } elseif {$layout_name == "src"} { + Term::check_box "src box" 0 0 80 15 + } elseif {$layout_name == "split"} { + Term::check_box "src box" 0 0 80 8 + Term::check_box "asm box" 0 7 80 8 } } } -foreach_with_prefix execution {0 1} { - foreach_with_prefix layout {"asm" "reg" "src" "split"} { - test_layout $layout $execution +foreach_with_prefix terminal {ansi dumb} { + foreach_with_prefix execution {false true} { + foreach_with_prefix layout {"asm" "reg" "src" "split"} { + test_layout_or_focus $layout $terminal $execution + } } }