From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1696433588; 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=l7H+cu9iziO7QJnPjZpPQc3hJzpVqYOeSIIrNr3QB3o=; b=Nr8yx//2YoEp1e3uLIlreig93e8TpA8xr9uDKVROUaoI+Ucx90QDis5CakjKGLmVBHeMiX X7nOM4SZR4GFIBYkZMCKkqa5CnpwDFy//PPpDUpyB3RCIZ8OpYKa53OPg3OOEypAAYoaW4 GWzEpSEfB+bi2gON0TCvOGrTtaCsYTk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1696433588; 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=l7H+cu9iziO7QJnPjZpPQc3hJzpVqYOeSIIrNr3QB3o=; b=MAJvk9tt20Jd1wnFjNNiihPmIgWL8EKS0RGDN0pGw79YkuCUd3MJRPuRa5OOWBa88QvnND HDAp8qJrNoe1O1CQ== 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> From: Tom de Vries 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 List-Id: 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