public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: gdb-patches@sourceware.org
Subject: [pushed 2/2] [gdb/testsuite] Modernize gdb.arch/i386-biarch-core.exp
Date: Wed, 16 Nov 2022 11:20:28 +0100	[thread overview]
Message-ID: <20221116102028.18591-2-tdevries@suse.de> (raw)
In-Reply-To: <20221116102028.18591-1-tdevries@suse.de>

I noticed in test-case gdb.arch/i386-biarch-core.exp that we run into the
completion limit for "complete set gnutarget":
...
set gnutarget vms-libtxt^M
set gnutarget  *** List may be truncated, max-completions reached. ***^M
(gdb) PASS: gdb.arch/i386-biarch-core.exp: complete set gnutarget
...

Fix this by using get_set_option_choices.

Also use get_set_option_choices for "complete set architecture i386", which
required extending get_set_option_choices to accept a second argument, such
that we can do:
...
set archs [get_set_option_choices "set architecture" "i386"]
...
because this returns an empty list:
...
set archs [get_set_option_choices "set architecture i386"]
...
because it does "complete set architecture i386 ".

Also clean up the explicit gdb_exit/gdb_start and use clean_restart instead.

Tested on x86_64-linux.
---
 gdb/testsuite/gdb.arch/i386-biarch-core.exp | 29 +++++----------------
 gdb/testsuite/lib/gdb.exp                   | 18 ++++++++++---
 2 files changed, 21 insertions(+), 26 deletions(-)

diff --git a/gdb/testsuite/gdb.arch/i386-biarch-core.exp b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
index e1f65900379..95e60d0b552 100644
--- a/gdb/testsuite/gdb.arch/i386-biarch-core.exp
+++ b/gdb/testsuite/gdb.arch/i386-biarch-core.exp
@@ -28,20 +28,12 @@ if { ![istarget "i?86-*-*"] && ![istarget "x86_64-*-*"] } then {
 
 standard_testfile
 
-gdb_exit
-gdb_start
-gdb_reinitialize_dir $srcdir/$subdir
+clean_restart
 
-set test "complete set gnutarget"
-gdb_test_multiple "complete set gnutarget " $test {
-    -re "set gnutarget elf64-little\r\n(.*\r\n)?$gdb_prompt $" {
-	pass $test
-    }
-    -re "\r\n$gdb_prompt $" {
-	pass $test
-	untested ".text is readable"
-	return
-    }
+set gnutargets [get_set_option_choices "set gnutarget"]
+if { [lsearch -exact $gnutargets elf64-little] == -1 } {
+    untested ".text is readable"
+    return
 }
 
 set corebz2file ${srcdir}/${subdir}/${testfile}.core.bz2
@@ -62,15 +54,8 @@ if {$corestat(size) != 102400} {
 
 # First check if this particular GDB supports i386, otherwise we should not
 # expect the i386 core file to be loaded successfully.
-set supports_arch_i386 1
-set test "complete set architecture i386"
-gdb_test_multiple $test $test {
-    -re "\r\nset architecture i386\r\n(.*\r\n)?$gdb_prompt $" {
-    }
-    -re "\r\n$gdb_prompt $" {
-        set supports_arch_i386 0
-    }
-}
+set archs [get_set_option_choices "set architecture" "i386"]
+set supports_arch_i386 [expr [lsearch -exact $archs i386] != -1]
 
 # Wrongly built GDB complains by:
 # "..." is not a core dump: File format not recognized
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index f540770189d..042d7ade59f 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9146,13 +9146,23 @@ gdb_caching_proc has_hw_wp_support {
     return $has_hw_wp_support
 }
 
-# Return a list of all the accepted values of the set command SET_CMD.
+# Return a list of all the accepted values of the set command
+# "SET_CMD SET_ARG".
+# For example get_set_option_choices "set architecture" "i386".
 
-proc get_set_option_choices {set_cmd} {
+proc get_set_option_choices { set_cmd {set_arg ""} } {
     set values {}
 
-    set cmd "complete $set_cmd "
-    set test "complete $set_cmd"
+    if { $set_arg == "" } {
+	# Add trailing space to signal that we need completion of the choices,
+	# not of set_cmd itself.
+	set cmd "complete $set_cmd "
+    } else {
+	set cmd "complete $set_cmd $set_arg"
+    }
+
+    # Set test name without trailing space.
+    set test [string trim $cmd]
 
     with_set max-completions unlimited {
 	gdb_test_multiple $cmd $test {
-- 
2.35.3


      reply	other threads:[~2022-11-16 10:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-16 10:20 [pushed 1/2] [gdb/testsuite] Fix gdb.arch/ppc64-symtab-cordic.exp without bzip2 Tom de Vries
2022-11-16 10:20 ` Tom de Vries [this message]

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=20221116102028.18591-2-tdevries@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@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: link
Be 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).