public inbox for gdb-cvs@sourceware.org help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@sourceware.org> To: gdb-cvs@sourceware.org Subject: [binutils-gdb] gdb/tui/testsuite: refactor new-layout.exp test Date: Sun, 3 Apr 2022 14:43:18 +0000 (GMT) [thread overview] Message-ID: <20220403144318.B698F385842B@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=80b2eb3c34c06bbd139216ad534e91e36a7eff10 commit 80b2eb3c34c06bbd139216ad534e91e36a7eff10 Author: Andrew Burgess <aburgess@redhat.com> Date: Tue Feb 1 13:36:58 2022 +0000 gdb/tui/testsuite: refactor new-layout.exp test This commit changes the gdb.tui/new-layout.exp test to make use of a list of test descriptions, and a loop to check each description in turn. There's no change to what is actually tested after this commit. In future commits I plan to add additional tests to this file, and this will be easier now that all I have to do is add a new test description to the list. Diff: --- gdb/testsuite/gdb.tui/new-layout.exp | 83 ++++++++++++++++++++++++------------ 1 file changed, 56 insertions(+), 27 deletions(-) diff --git a/gdb/testsuite/gdb.tui/new-layout.exp b/gdb/testsuite/gdb.tui/new-layout.exp index 2b5e07db612..d3d34af7439 100644 --- a/gdb/testsuite/gdb.tui/new-layout.exp +++ b/gdb/testsuite/gdb.tui/new-layout.exp @@ -55,20 +55,39 @@ if { [tcl_version_at_least 8 6] } { "Missing '\}' in layout specification" } -gdb_test_no_output "tui new-layout example asm 1 status 0 cmd 1" - -gdb_test "help layout example" \ - "Apply the \"example\" layout.*tui new-layout example asm 1 status 0 cmd 1" - -gdb_test_no_output "tui new-layout example2 {asm 1 status 0} 1 cmd 1" - -gdb_test "help layout example2" \ - "Apply the \"example2\" layout.*tui new-layout example2 {asm 1 status 0} 1 cmd 1" - -gdb_test_no_output "tui new-layout h {-horizontal asm 1 src 1} 1 status 0 cmd 1" +# Each entry of this list describes a layout, and some associated +# tests. The items within each entry are: +# 1. layout name, +# 2. a string used to create the layout, +# 3. a list of boxes to check for once the layout is selected, +# 4. a regexp to match against the whole screen contents, this +# can be empty to skip this check. +set layouts \ + [list \ + [list example "asm 1 status 0 cmd 1" \ + {{0 0 80 15}} "$hex <main>"] \ + [list example2 "{asm 1 status 0} 1 cmd 1" \ + {{0 0 80 15}} ""] \ + [list h "{-horizontal asm 1 src 1} 1 status 0 cmd 1" \ + {{0 0 40 15} {39 0 41 15}} \ + "$hex <main>.*21.*return 0"]] + +# Helper function to verify a list of boxes. +proc check_boxes {boxes} { + set boxno 1 + foreach box $boxes { + eval Term::check_box [list "box $boxno"] $box + incr boxno + } +} -gdb_test "help layout h" \ - "Apply the \"h\" layout.*tui new-layout h {-horizontal asm 1 src 1} 1 status 0 cmd 1" +# Now create the layouts. +foreach layout $layouts { + lassign $layout name desc + gdb_test_no_output "tui new-layout $name $desc" + gdb_test "help layout $name" \ + "Apply the \"$name\" layout.*tui new-layout $name $desc" +} if {![Term::enter_tui]} { unsupported "TUI not supported" @@ -79,20 +98,30 @@ set text [Term::get_all_lines] gdb_assert {![string match "No Source Available" $text]} \ "initial source listing" -Term::command "layout example" -Term::check_contents "example layout shows assembly" \ - "$hex <main>" +foreach_with_prefix layout $layouts { + lassign $layout name desc boxes content_pattern + + # Reset the layout to a known starting configuration. + Term::command "layout src" + Term::command "winheight cmd 8" + + # Apply our test layout. + Term::command "layout $name" + check_boxes $boxes -Term::command "layout h" -Term::check_box "left window box" 0 0 40 15 -Term::check_box "right window box" 39 0 41 15 -Term::check_contents "horizontal display" \ - "$hex <main>.*21.*return 0" + if {$content_pattern != ""} { + Term::check_contents "contents in layout $name" \ + "${content_pattern}" + } -Term::command "winheight src - 5" -Term::check_box "left window box after shrink" 0 0 40 10 -Term::check_box "right window box after shrink" 39 0 41 10 + # Some additional tests for the 'h' layout. + if {$name == "h"} { + Term::command "winheight src - 5" + Term::check_box "left window box after shrink" 0 0 40 10 + Term::check_box "right window box after shrink" 39 0 41 10 -Term::command "winheight src + 5" -Term::check_box "left window box after grow" 0 0 40 15 -Term::check_box "right window box after grow" 39 0 41 15 + Term::command "winheight src + 5" + Term::check_box "left window box after grow" 0 0 40 15 + Term::check_box "right window box after grow" 39 0 41 15 + } +}
reply other threads:[~2022-04-03 14:43 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220403144318.B698F385842B@sourceware.org \ --to=aburgess@sourceware.org \ --cc=gdb-cvs@sourceware.org \ /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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).