From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 1DD023858D39 for ; Wed, 25 Jan 2023 11:29:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1DD023858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674646150; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=6wEbG8+UWYWxdpAJpazL6WkBVRnF7P6tNXrVBsTcpfI=; b=iYQsMM4kZW+FVYvTlfcnqa1FcslFPLtTXX0a+gTOy8d67OtW78UxTHsKXkN0vfwUAo+KHT 61BKNSY8g3J54bsyAMnN5XxrQpqEjAmh5S6amflB8u4rmD7UjQeNOiVnN4OKmJcicjdWmK wC8XXPbF/ZjiK4+OPZjeImWydb9bR/A= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-665-u5Q2EGiuMqmx5sPDetvlPg-1; Wed, 25 Jan 2023 06:29:09 -0500 X-MC-Unique: u5Q2EGiuMqmx5sPDetvlPg-1 Received: by mail-qt1-f199.google.com with SMTP id i1-20020ac87641000000b003b7fa8c92bcso1344533qtr.15 for ; Wed, 25 Jan 2023 03:29:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:message-id:date:references:in-reply-to:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6wEbG8+UWYWxdpAJpazL6WkBVRnF7P6tNXrVBsTcpfI=; b=zwnpyg06DBelZASQQwTnc+H7Wd008onCQPzeyB7j5+5Bx/4YO7Qj4p+oO327bAJwbH Fs9RObTnKtuZ2yo1gtTCmduvcuws6zbxs8JKpYEiKZG1qzCOXA18BLqZSvO41+MEkoLU hOp20jhCc3ouMyYn5RD4c5cTA9GV17KAvlHkDy6La60Y6r4Untk4Hb3vGveEWsonGTOF 5rteRzJO3oSNXeI+828g13e7mAsee+0pF2fl/O6QOcnq2mlpBStDSdLhtsBU7y230B4T j9z1IO4G1anIRn5YGeQuNxWx7JvTVc7EGePieZrCB6+d133lYUgDacsF+Kc97evWY+25 V7Qg== X-Gm-Message-State: AFqh2kqWYs4AIa5bYssNoE9k/t3NDZ9xKuolKD9XD4Y/GmndWcfdAdP8 AribG4ZCRtY1C87vQuvsR+H+sqcXqppji0M9vorQm3f67YtpynAZ3sIRAXKxN5S4f1VxM0++9uX F3T9luEc/pYsPKPk037P6STeC4oyTVhiC/nuEtpBD3lv94C5nqYk9oMEaFJAAAPMuJHfq1hfetA == X-Received: by 2002:ac8:5454:0:b0:3a8:45f:a47f with SMTP id d20-20020ac85454000000b003a8045fa47fmr46769732qtq.49.1674646148902; Wed, 25 Jan 2023 03:29:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXuJTh+J4Dra+G7GYbzzoqAJnbTl2MnP+Tdo7mczJfnPVYWdigvPBBUhiMuQpDY9/3TI+6js/w== X-Received: by 2002:ac8:5454:0:b0:3a8:45f:a47f with SMTP id d20-20020ac85454000000b003a8045fa47fmr46769702qtq.49.1674646148436; Wed, 25 Jan 2023 03:29:08 -0800 (PST) Received: from localhost (95.72.115.87.dyn.plus.net. [87.115.72.95]) by smtp.gmail.com with ESMTPSA id o18-20020a05620a15d200b0070531c5d655sm3262316qkm.90.2023.01.25.03.29.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Jan 2023 03:29:08 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Subject: Re: [PATCH 01/15] gdb/testsuite: extend gdb.tui/tui-layout.exp test script In-Reply-To: <3adda76c2743f4b5c7c811cc68a212ec9fcf3f57.1673000632.git.aburgess@redhat.com> References: <3adda76c2743f4b5c7c811cc68a212ec9fcf3f57.1673000632.git.aburgess@redhat.com> Date: Wed, 25 Jan 2023 11:29:06 +0000 Message-ID: <87pmb2x37h.fsf@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.8 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 List-Id: Andrew Burgess writes: > 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. I've gone ahead and pushed this patch. The final version I pushed is included below. Thanks, Andrew --- commit b3b0595ff66d8597637c415f74d43dd459a18cb3 Author: Andrew Burgess Date: Fri Nov 25 18:19:16 2022 +0000 gdb/testsuite: extend gdb.tui/tui-layout.exp test script 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. diff --git a/gdb/testsuite/gdb.tui/tui-layout.exp b/gdb/testsuite/gdb.tui/tui-layout.exp index 2c502191d11..c7fdb1b0c0a 100644 --- a/gdb/testsuite/gdb.tui/tui-layout.exp +++ b/gdb/testsuite/gdb.tui/tui-layout.exp @@ -18,19 +18,41 @@ require allow_tui_tests +tuiterm_env + standard_testfile if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { return -1 } -# 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]} { @@ -38,16 +60,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 + } } }