From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7333C3858D1E for ; Sat, 15 Apr 2023 23:35:50 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7333C3858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681601749; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3LW03mjeEFd9z9IObpa3pbe5ypwI+90i4G20aV1O42E=; b=IV0ew8XuGgDg49slFfizywDOyIQrSEiekjyMfLa1y8/MemyHqz6Y7vFxc1ekvH/pTraWAV Cn1gWB9lBPhOK5GQqIWaOtJ7FgVVSqAjWmyu0u2b3mFkH18oU4vmbuAV/VoO91FmAZzxJm 2LzSmA6Qz/EKY4HwewS5EZs90LJhU0s= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-659-mYIAuWoRO62QjDxZLccc3A-1; Sat, 15 Apr 2023 19:35:48 -0400 X-MC-Unique: mYIAuWoRO62QjDxZLccc3A-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AE643101A531; Sat, 15 Apr 2023 23:35:47 +0000 (UTC) Received: from f37-zws-nv (unknown [10.2.16.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6A64C51FF; Sat, 15 Apr 2023 23:35:47 +0000 (UTC) Date: Sat, 15 Apr 2023 16:35:45 -0700 From: Kevin Buettner To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFC 2/5] Introduce the "critical" testsuite command Message-ID: <20230415162429.4cf48de9@f37-zws-nv> In-Reply-To: <20230415151336.4104455-3-tom@tromey.com> References: <20230415151336.4104455-1-tom@tromey.com> <20230415151336.4104455-3-tom@tromey.com> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Tom, Overall, I like this idea, but I think I found an easily fixable problem in the implementation of the "critical" command - see below. On Sat, 15 Apr 2023 09:13:33 -0600 Tom Tromey wrote: > 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" This message makes sense for ensure_gdb_index, but I don't think it makes sense for the others. Should a suitable message to print here be passed to _make_wrapper? > + 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 >