public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: Tom Tromey <tom@tromey.com>,
	Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
Subject: [PATCH][gdb/testsuite] Add proc require in lib/gdb.exp
Date: Wed, 6 Oct 2021 09:40:24 +0200	[thread overview]
Message-ID: <5de83135-c797-d211-467a-de12d174ae67@suse.de> (raw)
In-Reply-To: <8735pfz6ax.fsf@tromey.com>

[-- Attachment #1: Type: text/plain, Size: 1189 bytes --]

[ was: Re: [committed][gdb/testsuite] Disable vgdb tests if xml not
supported ]

On 10/5/21 8:15 PM, Tom Tromey wrote:
> Tom> Or perhaps you mean more generically (which wouldn't require us to write
> Tom> a proc for each type of require):
> Tom> ...
> Tom> proc require { fn val } {
> Tom>     if { [$fn] != $val } {
> Tom>         untested "$fn != $val"
> Tom>         return -code return 0
> Tom>     }
> Tom> }
> Tom> ...
> Tom> and:
> Tom> ...
> Tom> require gdb_skip_xml_test 0
> Tom> ...
> Tom> ?
> 
> Either seems fine but this one does read nicely to me.
> Or maybe even just requiring 'fn' to return 0 would be good enough.

I've also thought about that, but decided against it:
- it does not take into account a proc support_foo that returns 1, which
  in the current form can be required using "require support_foo 1"
- it does not support the cases where we require no support for a
  feature, say "require gdb_skip_xml_test 1"

Also, I considered making the test freeform, as in gdb_assert, but
decided against it because:
- it does not enforce uniform usage
- makes it harder to do the fn+value to message matching I've added in
  this version.

Any comment?

Thanks,
- Tom

[-- Attachment #2: 0001-gdb-testsuite-Add-proc-require-in-lib-gdb.exp.patch --]
[-- Type: text/x-patch, Size: 3925 bytes --]

[gdb/testsuite] Add proc require in lib/gdb.exp

Add a new proc require in lib/gdb.exp, and use to shorten:
...
if { [gdb_skip_xml_test] } {
    # Valgrind gdbserver requires gdb with xml support.
    untested "missing xml support"
    return 0
}
...
into:
...
require gdb_skip_xml_test 0
...

Tested on x86_64-linux, both with and without a trigger patch that forces
gdb_skip_xml_test to return 1.

---
 gdb/testsuite/gdb.base/valgrind-bt.exp        |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-disp-step.exp |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-infcall-2.exp |  7 ++-----
 gdb/testsuite/gdb.base/valgrind-infcall.exp   |  7 ++-----
 gdb/testsuite/lib/gdb.exp                     | 16 ++++++++++++++++
 5 files changed, 24 insertions(+), 20 deletions(-)

diff --git a/gdb/testsuite/gdb.base/valgrind-bt.exp b/gdb/testsuite/gdb.base/valgrind-bt.exp
index 440c6e403e9..546701498b2 100644
--- a/gdb/testsuite/gdb.base/valgrind-bt.exp
+++ b/gdb/testsuite/gdb.base/valgrind-bt.exp
@@ -13,11 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/gdb.base/valgrind-disp-step.exp b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
index 88ac848ae2d..c1ed5a3e69b 100644
--- a/gdb/testsuite/gdb.base/valgrind-disp-step.exp
+++ b/gdb/testsuite/gdb.base/valgrind-disp-step.exp
@@ -18,11 +18,8 @@
 # really tests is that GDB falls back to in-line stepping
 # automatically instead of getting stuck or crashing.
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
index a368717c1e8..064cf719712 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall-2.exp
@@ -29,11 +29,8 @@
 # terminate called after throwing an instance of 'gdb_exception_error'
 # Aborted (core dumped)
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/gdb.base/valgrind-infcall.exp b/gdb/testsuite/gdb.base/valgrind-infcall.exp
index 9f49a320f52..68bc1b8e4e7 100644
--- a/gdb/testsuite/gdb.base/valgrind-infcall.exp
+++ b/gdb/testsuite/gdb.base/valgrind-infcall.exp
@@ -13,11 +13,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-if { [gdb_skip_xml_test] } {
-    # Valgrind gdbserver requires gdb with xml support.
-    untested "missing xml support"
-    return 0
-}
+# Valgrind gdbserver requires gdb with xml support.
+require gdb_skip_xml_test 0
 
 load_lib valgrind.exp
 
diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 5642db4334d..89733c59605 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -8215,5 +8215,21 @@ gdb_caching_proc have_avx {
     return $status
 }
 
+# Require [FN] to return VAL.  If not, return in the caller's context.
+
+proc require { fn val } {
+    if { [$fn] == $val } {
+	return
+    }
+
+    switch $fn-$val {
+	gdb_skip_xml_test-0 { set msg "missing xml support" }
+	default { set msg "$fn != $val" }
+    }
+
+    untested $msg
+    return -code return 0
+}
+
 # Always load compatibility stuff.
 load_lib future.exp

  reply	other threads:[~2021-10-06  7:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-29 13:55 [committed][gdb/testsuite] Disable vgdb tests if xml not supported Tom de Vries
2021-09-30 17:30 ` Tom Tromey
2021-09-30 21:41   ` Tom de Vries
2021-09-30 21:47     ` Tom de Vries
2021-10-05 18:15     ` Tom Tromey
2021-10-06  7:40       ` Tom de Vries [this message]
2021-10-07 11:00         ` [PATCH][gdb/testsuite] Prevent compilation fails with unix/-fPIE/-pie Tom de Vries
2021-10-08 14:37           ` Tom de Vries
2021-10-11 10:28         ` [PATCH][gdb/testsuite] Add proc require in lib/gdb.exp Tom de Vries

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=5de83135-c797-d211-467a-de12d174ae67@suse.de \
    --to=tdevries@suse.de \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).