From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 8A2953858D37 for ; Tue, 24 Oct 2023 12:33:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A2953858D37 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8A2953858D37 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698150792; cv=none; b=U8kkb3+VornRR+9gbrfNbl2TrU83SmuM5QNi4s68wzlupNMdt6Zz69v2Ity+WkiO5uY6rWjVEpGgjuebnrW4gU6WTA2b/VjkJsAKsJ0L3VgA9Zl+xQe+Hd1na9iJhYmpnDTxLseMvo8xpLyZqrao+bBC2t2tz7Mg6SlS/1M/mO8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698150792; c=relaxed/simple; bh=3HM6yOwtn3yASBkPYZfDwKnlJJ09oYEPGEoqrAO2UWA=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:MIME-Version: Subject:From:To; b=R8AOVGHExJ0atys3hIhsrDBXpWHAhgxiJNs3Eq/w8h72T3UIPGTS6utWn7KCCsYCPBjnM3Bj+C1N+tpnc4XkTNKemMNXuipWn7qm27bp+lnYla181EGhIg7iC3zvux3zKejjqKm1s4f4/gMS1BmEsErT+g/jufcy7qRB98wyHk4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AEAD821866 for ; Tue, 24 Oct 2023 12:33:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1698150789; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b0agxFZETZNIXsyrOkK+DAEocfGpubsds69iTg2keaU=; b=XZavSRE6hZnqDBJs1ypMvNmav5rLUdAgxwVPKA8ycoUz8C56PS/PzZIr+dsvrGcngndeAr /uQs0H0yuueIkjBJdLAKSIsEGgy56G7AnIUH36MGeSUNJL9W7Ga9ejYXBqFbtiqFQhnzvJ msT2lOE8ri0iiHFbts6rIqCw1vVMsZw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1698150789; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=b0agxFZETZNIXsyrOkK+DAEocfGpubsds69iTg2keaU=; b=3//luZk1q2LrTDBCYpbduqmazCy9PK5xSBqw4MHe4QLybg+IC5CafQxkR92CgxciOQDljU G+ACPwI4AYUABnDw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id A076C134F5 for ; Tue, 24 Oct 2023 12:33:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id i1UoJoW5N2XUaAAAMHmgww (envelope-from ) for ; Tue, 24 Oct 2023 12:33:09 +0000 Message-ID: <7d7720ee-f221-4981-8428-a11d5d84fb53@suse.de> Date: Tue, 24 Oct 2023 14:33:57 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 3/6] [gdb/cli] Add gnu-source-highlight selftest Content-Language: en-US From: Tom de Vries To: gdb-patches@sourceware.org References: <20231024094933.12009-1-tdevries@suse.de> <20231024094933.12009-4-tdevries@suse.de> In-Reply-To: <20231024094933.12009-4-tdevries@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -7.05 X-Spamd-Result: default: False [-7.05 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; XM_UA_NO_VERSION(0.01)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; BAYES_HAM(-2.96)[99.85%]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[gdb-patches@sourceware.org]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-3.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-1.00)[-1.000]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[] X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,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: On 10/24/23 11:49, Tom de Vries wrote: > Add a selftest gnu-source-highlight: > ... > $ gdb -q -batch -ex "maint selftest gnu-source-highlight" > Running selftest gnu-source-highlight. > Ran 1 unit tests, 0 failed > ... > I realized that this simplified version doesn't really depend on anything from the series, so ... pushed. Thanks, - Tom > Tested on x86_64-linux. > --- > gdb/source-cache.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 45 insertions(+), 1 deletion(-) > > diff --git a/gdb/source-cache.c b/gdb/source-cache.c > index 92acb100901..c955929b543 100644 > --- a/gdb/source-cache.c > +++ b/gdb/source-cache.c > @@ -22,7 +22,6 @@ > #include "source.h" > #include "cli/cli-style.h" > #include "symtab.h" > -#include "gdbsupport/selftest.h" > #include "objfiles.h" > #include "exec.h" > #include "cli/cli-cmds.h" > @@ -40,6 +39,10 @@ > #include > #endif > > +#if GDB_SELF_TEST > +#include "gdbsupport/selftest.h" > +#endif > + > /* The number of source files we'll cache. */ > > #define MAX_ENTRIES 5 > @@ -258,6 +261,43 @@ try_source_highlight (std::string &contents ATTRIBUTE_UNUSED, > #endif /* HAVE_SOURCE_HIGHLIGHT */ > } > > +#ifdef HAVE_SOURCE_HIGHLIGHT > +#if GDB_SELF_TEST > +namespace selftests > +{ > +static void gnu_source_highlight_test () > +{ > + const std::string prog > + = ("int\n" > + "foo (void)\n" > + "{\n" > + " return 0;\n" > + "}\n"); > + const std::string fullname = "test.c"; > + std::string styled_prog; > + > + bool res = false; > + bool saw_exception = false; > + styled_prog = prog; > + try > + { > + res = try_source_highlight (styled_prog, language_c, fullname); > + } > + catch (...) > + { > + saw_exception = true; > + } > + > + SELF_CHECK (!saw_exception); > + if (res) > + SELF_CHECK (prog.size () < styled_prog.size ()); > + else > + SELF_CHECK (prog == styled_prog); > +} > +} > +#endif /* GDB_SELF_TEST */ > +#endif /* HAVE_SOURCE_HIGHLIGHT */ > + > /* See source-cache.h. */ > > bool > @@ -489,5 +529,9 @@ styling to source code lines that are shown."), > > #if GDB_SELF_TEST > selftests::register_test ("source-cache", selftests::extract_lines_test); > +#ifdef HAVE_SOURCE_HIGHLIGHT > + selftests::register_test ("gnu-source-highlight", > + selftests::gnu_source_highlight_test); > +#endif > #endif > }