From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1726) id E7D3638582A1; Wed, 25 Jan 2023 11:27:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E7D3638582A1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1674646026; bh=8PvyiD6U/i5qaQpw2j3vPctR20VXGuIrorjDQdikYAE=; h=From:To:Subject:Date:From; b=jp0C2zimtuullOhX1MJjqbRn1yB2fgYDIyYeMLaXV1H3DHQLZrrRWHXi+x2/tmtcY csW7om2ZR/atxHR6pvuHJLNQN41cjYY3X5KHFPx3owoHwgrzKrh6A94YTGkEESRZGR rpdniqNbTY1w1YaRvUYzW2sXXTgzyJHV9upBwm+Q= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Andrew Burgess To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/testsuite: extend gdb.tui/tui-layout.exp test script X-Act-Checkin: binutils-gdb X-Git-Author: Andrew Burgess X-Git-Refname: refs/heads/master X-Git-Oldrev: db8861ec34ad89f2c54ae8d51b353f0fedac3a3f X-Git-Newrev: b3b0595ff66d8597637c415f74d43dd459a18cb3 Message-Id: <20230125112706.E7D3638582A1@sourceware.org> Date: Wed, 25 Jan 2023 11:27:06 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Db3b0595ff66d= 8597637c415f74d43dd459a18cb3 commit b3b0595ff66d8597637c415f74d43dd459a18cb3 Author: Andrew Burgess Date: Fri Nov 25 18:19:16 2022 +0000 gdb/testsuite: extend gdb.tui/tui-layout.exp test script =20 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. =20 It turns out that this was caused by this commit: =20 commit 9162a27c5f5828240b53379d735679e2a69a9f41 Date: Tue Nov 13 11:59:03 2018 -0700 =20 Change gdb test suite's TERM setting =20 This was when we changed the testsuite to set the TERM environment variable to "dumb" by default. =20 After this, any tui test that didn't set the terminal mode back to 'ansi' would fail to activate tui mode. =20 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. =20 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. =20 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: --- 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/t= ui-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 @@ =20 require allow_tui_tests =20 +tuiterm_env + standard_testfile =20 if {[prepare_for_testing "failed to prepare" ${testfile} ${srcfile}]} { return -1 } =20 -# 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. =20 -proc test_layout {layout execution} { +proc test_layout_or_focus {layout_name terminal execution} { global binfile gdb_prompt =20 - 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 + } + } =20 if {$execution} { if {![runto_main]} { @@ -38,16 +60,29 @@ proc test_layout {layout execution} { } } =20 - 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=3Ddumb\\\]" + } else { + Term::command_no_prompt_prefix "layout $layout_name" + if {$layout_name =3D=3D "asm"} { + Term::check_box "asm box" 0 0 80 15 + } elseif {$layout_name =3D=3D "reg"} { + Term::check_box "reg box" 0 0 80 8 + Term::check_box "src box" 0 7 80 8 + } elseif {$layout_name =3D=3D "src"} { + Term::check_box "src box" 0 0 80 15 + } elseif {$layout_name =3D=3D "split"} { + Term::check_box "src box" 0 0 80 8 + Term::check_box "asm box" 0 7 80 8 } } } =20 -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 + } } }