From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id LcvXHteFHWVwxyQAWB0awg (envelope-from ) for ; Wed, 04 Oct 2023 11:33:43 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=u9QzOdlU; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 70DD51E0C3; Wed, 4 Oct 2023 11:33:43 -0400 (EDT) Received: from server2.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 ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5DF551E092 for ; Wed, 4 Oct 2023 11:33:41 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CD0E8385C6DE for ; Wed, 4 Oct 2023 15:33:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CD0E8385C6DE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1696433620; bh=l7H+cu9iziO7QJnPjZpPQc3hJzpVqYOeSIIrNr3QB3o=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=u9QzOdlUcZxzJIw/rJPGBPU5M7KR9CcD3IWoMC+2QIn6Puw3jow6k1Dep6alDMeir 7xAnDb51lSMl+efpNLf4ezmg4adP4LmksXHrjEzUZGcq0f81kA23Ff2XX0I2jjRaHF JQZLcNzWMkB23fz4uDFP+N7GmPVoONIN/F3c9vYk= Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 046F4385841B for ; Wed, 4 Oct 2023 15:33:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 046F4385841B 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-out2.suse.de (Postfix) with ESMTPS id 161E31F86A; Wed, 4 Oct 2023 15:33:08 +0000 (UTC) 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 055D413A2E; Wed, 4 Oct 2023 15:33:08 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id f55TALSFHWV5IAAAMHmgww (envelope-from ); Wed, 04 Oct 2023 15:33:08 +0000 Message-ID: Date: Wed, 4 Oct 2023 17:33:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v3] gdb/testsuite: XFAIL some gdb.base/fileio.exp Content-Language: en-US To: Guinevere Larsen , gdb-patches@sourceware.org References: <20230814102449.203616-2-blarsen@redhat.com> <20231004140247.16091-2-blarsen@redhat.com> In-Reply-To: <20231004140247.16091-2-blarsen@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Tom de Vries via Gdb-patches Reply-To: Tom de Vries Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 10/4/23 16:02, Guinevere Larsen via Gdb-patches wrote: > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index de22da8d8a8..5b90b8af3b8 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -9981,5 +9981,25 @@ gdb_caching_proc have_system_header { file } { > return [gdb_can_simple_compile have_system_header_$name $src object] > } > > +# Return 1 if the test is being run as root, 0 otherwise. > + > +gdb_caching_proc root_user {} { > + # ID outputs to stdout, we have to use exec to capture it here. > + set user [remote_exec target id] > + > + regexp -all "(-?\[0-9\]+).*" $user user ret_val I can see that this works, but it's a bit unusual (and hard to parse for me) to use regexp to pick apart a list. The usual way is using lindex. > + > + # If ret_val is not 0, we couldn't run `id` on the target for some > + # reason. Return that we are not root, so problems are easier to > + # spot. > + if {[expr $ret_val != 0]} { The expr is not necessary here. > + return 0 > + } > + > + regexp -all ".*uid=(\[0-9\]+).*" $user user uid > + Also, the 'user' variable is used as dummy, better make that explicit. So, please do: ... set res [remote_exec target id] set ret_val [lindex $res 0] set output [lindex $res 1] # If ret_val is not 0, we couldn't run `id` on the target for some # reason. Return that we are not root, so problems are easier to # spot. if { $ret_val != 0 } { return 0 } regexp -all ".*uid=(\[0-9\]+).*" $output dummy uid return [expr $uid == 0] ... Approved with that change. Approved-By: Tom de Vries Thanks, - Tom > + return [expr $uid == 0] > +} > + > # Always load compatibility stuff. > load_lib future.exp