public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFC 2/5] Introduce the "critical" testsuite command
Date: Sat, 15 Apr 2023 09:13:33 -0600	[thread overview]
Message-ID: <20230415151336.4104455-3-tom@tromey.com> (raw)
In-Reply-To: <20230415151336.4104455-1-tom@tromey.com>

This patch introduces a new "critical" command for the test suite.
Unlike require, "critical" can handle multiple arguments and a variety
of return value conventions.  It is implemented as a Tcl namespace
ensemble for this reason.

This version of the patch provides a few such subcommands.  Currently
these are all implemented via a helper proc, but there's no
requirement that this always be true.
---
 gdb/testsuite/lib/gdb.exp | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index a1808c699e9..0ae40bceba2 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -9287,6 +9287,34 @@ proc require { args } {
     }
 }
 
+#
+# The "critical" command is used to invoke some code that must
+# succeed.  If the code in question fails, "unsupported" is logged and
+# the command's caller will return.
+#
+# This is implemented as an ensemble namespace so that individual
+# sub-commands can handle varying return values correctly.
+#
+namespace eval critical {
+    proc _make_wrapper {name bad_result} {
+	proc $name {args} [format {
+	    set result [uplevel [list %s {*}$args]]
+	    if {$result == %s} {
+		unsupported "error adding gdb index"
+		return -code return 0
+	    }
+	} $name $bad_result]
+	namespace export $name
+    }
+
+    _make_wrapper ensure_gdb_index -1
+    _make_wrapper prepare_for_testing_full -1
+    _make_wrapper prepare_for_testing -1
+    _make_wrapper runto 0
+
+    namespace ensemble create
+}
+
 # Wait up to ::TIMEOUT seconds for file PATH to exist on the target system.
 # Return 1 if it does exist, 0 otherwise.
 
-- 
2.39.2


  parent reply	other threads:[~2023-04-15 15:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-15 15:13 [RFC 0/5] Add new "critical" command to test suite Tom Tromey
2023-04-15 15:13 ` [RFC 1/5] Bug fix in prepare_for_testing Tom Tromey
2023-04-15 15:13 ` Tom Tromey [this message]
2023-04-15 23:35   ` [RFC 2/5] Introduce the "critical" testsuite command Kevin Buettner
2023-04-15 15:13 ` [RFC 3/5] Use "critical ensure_gdb_index" in gdb.rust Tom Tromey
2023-04-15 15:13 ` [RFC 4/5] Use "critical prepare_for_testing" " Tom Tromey
2023-04-15 15:13 ` [RFC 5/5] Use "critical runto" " Tom Tromey

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=20230415151336.4104455-3-tom@tromey.com \
    --to=tom@tromey.com \
    --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).