From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id AeZJAbyvSGF6EgAAWB0awg (envelope-from ) for ; Mon, 20 Sep 2021 11:58:52 -0400 Received: by simark.ca (Postfix, from userid 112) id E82C11EE25; Mon, 20 Sep 2021 11:58:51 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 2B9C41EDDB for ; Mon, 20 Sep 2021 11:58:51 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7E8FA385841C for ; Mon, 20 Sep 2021 15:58:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E8FA385841C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1632153530; bh=/34U8sjRpgQfS16OThljtZr98w6V8gvT3P4sc+fHDrc=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=mKPOqhz99M+srMaNAeSW2SfZoVX3YrNXWpjbBWflibcyF/Eost4a4Tpr7bbLL18k2 Yd7Cau9WjSggtd6GLEWclewEHSlpp7Mvc5qO/NyZsb5J67MDuTHNvv9ks9mqweBCYd kwKyqn/E+jX0umu/EpjxCeDezplnfEtYFOmlYRN0= Received: from smtp.polymtl.ca (smtp.polymtl.ca [132.207.4.11]) by sourceware.org (Postfix) with ESMTPS id 07C2D3858D3C for ; Mon, 20 Sep 2021 15:58:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 07C2D3858D3C Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id 18KFwQCu020200 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Sep 2021 11:58:31 -0400 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp.polymtl.ca 18KFwQCu020200 Received: from [10.0.0.11] (192-222-157-6.qc.cable.ebox.net [192.222.157.6]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 3457C1EDDB; Mon, 20 Sep 2021 11:58:26 -0400 (EDT) Subject: Re: [PATCH][gdb] Add register_test variant with std::function arg To: Tom de Vries , gdb-patches@sourceware.org References: <20210913154000.GA3078@delia.home> Message-ID: <058c08e8-dd93-74ba-f4f4-77b5dac00c6e@polymtl.ca> Date: Mon, 20 Sep 2021 11:58:25 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210913154000.GA3078@delia.home> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Mon, 20 Sep 2021 15:58:26 +0000 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Simon Marchi via Gdb-patches Reply-To: Simon Marchi Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 2021-09-13 11:40 a.m., Tom de Vries via Gdb-patches wrote: > Hi, > > Add register_test variant with std::function arg, such that we can do: > ... > register_test (test_name, [=] () { SELF_CHECK (...); }); > ... > > Any comments? > > Thanks, > - Tom > > [gdb] Add register_test variant with std::function arg > > --- > gdbsupport/selftest.cc | 25 +++++++++++++++++++++++++ > gdbsupport/selftest.h | 3 +++ > 2 files changed, 28 insertions(+) > > diff --git a/gdbsupport/selftest.cc b/gdbsupport/selftest.cc > index d0511abe654..6d92844880f 100644 > --- a/gdbsupport/selftest.cc > +++ b/gdbsupport/selftest.cc > @@ -21,6 +21,7 @@ > #include "common-debug.h" > #include "selftest.h" > #include > +#include > > namespace selftests > { > @@ -57,6 +58,30 @@ register_test (const std::string &name, selftest *test) > tests[name] = std::unique_ptr (test); > } > > +struct lambda_selftest : public selftest > +{ > + lambda_selftest (std::function function_) > + { > + function = function_; > + } > + > + void operator() () const override > + { > + function (); > + } > + > + std::function function; > +}; > + > +/* See selftest.h. */ > + > +void > +register_test (const std::string &name, > + std::function function) > +{ > + register_test (name, new lambda_selftest (function)); > +} > + > /* See selftest.h. */ I presume this is for your other patch ([RFC][gdb/testsuite] Register test for each arch separately in register_test_foreach_arch). Since this is just for tests and we don't care about performance (at least, we care more about simplicity), I think it would be fine to just make the existing register_test take an std::function. Simon