From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 1zJmMtMH+V+CPwAAWB0awg (envelope-from ) for ; Fri, 08 Jan 2021 20:33:07 -0500 Received: by simark.ca (Postfix, from userid 112) id C0C7D1E99A; Fri, 8 Jan 2021 20:33:07 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.2 Received: from sourceware.org (server2.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 0CD7D1E940 for ; Fri, 8 Jan 2021 20:33:07 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 42C593985457; Sat, 9 Jan 2021 01:33:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 42C593985457 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610155986; bh=S4XNVdk3RuXNTQM1/3O26i3By7HQZj3G6HmVCX4tzcI=; h=Subject:To:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=nX0QqYEJfivVS1oAG0DMmVJbLJv/cedtc1ZM/akYVH2TDNFCfG3u5qblMvxqBoFG8 LSdwcgL5yXFKb72UkYGIe+M/9xZFmdvftzLEKppsn98wbq9+VM8jIZQD9yVsJGg2Dc wPZfutXRhTakRveAUCNySqGcCLknVtJ7/jbHuIik= Received: from beryx.lancelotsix.com (beryx.lancelotsix.com [164.132.98.193]) by sourceware.org (Postfix) with ESMTPS id B37EF3842439 for ; Sat, 9 Jan 2021 01:33:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B37EF3842439 Received: from [IPv6:2a02:390:8443:0:849f:8222:20a9:b85b] (unknown [IPv6:2a02:390:8443:0:849f:8222:20a9:b85b]) by beryx.lancelotsix.com (Postfix) with ESMTPSA id D79C52E070; Sat, 9 Jan 2021 02:33:01 +0100 (CET) Subject: Re: [PATCH] Improve gdb_tilde_expand logic To: Simon Marchi , Andrew Burgess References: <20210108001337.29164-1-lsix@lancelotsix.com> <20210108093058.GR2945@embecosm.com> <58a88de1-6c5d-98ec-62d2-860f9ad7a8a8@polymtl.ca> Message-ID: <8fdb8080-ae0b-70ae-20ab-e84329590bea@lancelotsix.com> Date: Sat, 9 Jan 2021 01:33:00 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: <58a88de1-6c5d-98ec-62d2-860f9ad7a8a8@polymtl.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.11 (beryx.lancelotsix.com [0.0.0.0]); Sat, 09 Jan 2021 02:33:02 +0100 (CET) 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: Lancelot SIX via Gdb-patches Reply-To: Lancelot SIX Cc: gdb-patches@sourceware.org Errors-To: gdb-patches-bounces@sourceware.org Sender: "Gdb-patches" On 08/01/2021 15:59, Simon Marchi wrote: > On 2021-01-08 4:30 a.m., Andrew Burgess wrote: >> There's only very limited unit testing within GDB. You should write a >> test in gdb/testsuite/.... that triggers this behaviour and check the >> functionality that way. > It might be difficult to write a .exp test that specifically targets this > function... I think a selftest for this could be useful (in addition to > something in a .exp file, if this ends up used for the index-cache > directory, as discussed). > > The selftest could just call gdb_tilde_expand with > "~/a/non/existent/directory" and make some simple assertions with the > result. That selftest could probably be written directly in > gdbsupport/gdb_tilde_expand.cc. That would be the first time a > selftest is put in a gdbsupport file, but I don't think that will > cause a problem. That test will be available in both GDB and GDBserver. > > You can check the test for gdb_realpath in gdb/utils.c if you want > an example. > > Simon The option I have in mind is inspired by gdb.gdb/selftest.exp (if I understand it correctly): once I have a gdb session debugging gdb, I can have something like: gdb_test {print gdb_tilde_expand ("~/most/probably/non/existing").c_str ()} \ {= .*"/.*/most/probably/non/existing"} or something similar. If I go for something like that, can it be added directly in selftest.expr (under gdb.gdb) or do it require an entire new testcase (probably in gdb.base)?  It might be an overkill approach to unit-testing, but it should work. Lancelot.