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 392F03858D35 for ; Tue, 26 Sep 2023 13:21:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 392F03858D35 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-out1.suse.de (Postfix) with ESMTPS id 35A2B21857; Tue, 26 Sep 2023 13:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1695734516; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kTKuL7EUeQy7GbosQzjAkya+yyL0yBKRqOyuF/rEODo=; b=KeCGifzFyY2LvnR6w/xBWtESnLQF1sEg+Bq3l24QbwrvDXJezPRPpgxPUnccJ12J2NI2+s q3vqqKBUe7QuEylg/gO/wc1gU1s8tKg7vnQBOZJjH6hydM8YcfOvmaEqZkkFG+jnC0GoVm oi0vNuRadjNC3mEXhbr/IjRsRuho1zY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1695734516; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kTKuL7EUeQy7GbosQzjAkya+yyL0yBKRqOyuF/rEODo=; b=1h6csiMvGj/6KqQcwwgUMfDinA+rkb4nw6Lnz5jUmZkdeu36Z9lGkvEbhqbofPCUXnNI2X KvAs0nEdkiR6KfAA== 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 1DD0413434; Tue, 26 Sep 2023 13:21:56 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Lbw0BvTaEmV/NAAAMHmgww (envelope-from ); Tue, 26 Sep 2023 13:21:56 +0000 Message-ID: <94c0586a-14c4-480d-bf74-af50ba1c0a7f@suse.de> Date: Tue, 26 Sep 2023 15:21:58 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2] gdb/testsuite: XFAIL some gdb.base/fileio.exp To: Guinevere Larsen , gdb-patches@sourceware.org Cc: lsix@lancelotsix.com References: <20230811102134.2796842-1-blarsen@redhat.com> <20230814102449.203616-2-blarsen@redhat.com> Content-Language: en-US From: Tom de Vries In-Reply-To: <20230814102449.203616-2-blarsen@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 8/14/23 12:24, Guinevere Larsen via Gdb-patches wrote: > Some gdb.base/fileio.exp tests expect the inferior to not have write > access to some files. If the test is being run as root, this is never > possible. This commit adds a way to identify if the user is root and > xfails the tests that expect no write access. Hi, thanks for working on this problem. I also ran into this while running the gdb testsuite as root inside a container. > --- > > Changes for v2: > * root_user now uses remote_exec instead of exec to see the uid of the > inferior > > --- > gdb/testsuite/gdb.base/fileio.exp | 9 ++++++++- > gdb/testsuite/lib/gdb.exp | 11 +++++++++++ > 2 files changed, 19 insertions(+), 1 deletion(-) > > diff --git a/gdb/testsuite/gdb.base/fileio.exp b/gdb/testsuite/gdb.base/fileio.exp > index 33c88d064c4..e1c7a7f955e 100644 > --- a/gdb/testsuite/gdb.base/fileio.exp > +++ b/gdb/testsuite/gdb.base/fileio.exp > @@ -17,7 +17,6 @@ > > require {!target_info exists gdb,nofileio} > > - > standard_testfile > > if {[is_remote host]} { > @@ -75,6 +74,10 @@ gdb_test "continue" ".*" "" > > catch "system \"chmod -f -w [standard_output_file nowrt.fileio.test]\"" > > +# If the user is root, we will always have write permission Dot at end-of-line missing. > +if { [root_user] } { > + setup_xfail *-* > +} This also works, but the usual idiom seems to be '*-*-*', so maybe we should also use that here. Just a suggestion though. > gdb_test continue \ > "Continuing\\..*open 5:.*EACCES$stop_msg" \ > "Open for write but no write permission returns EACCES" > @@ -240,6 +243,10 @@ gdb_test continue \ > if [ishost *cygwin*] { > setup_xfail "*-*-*" > } > +# If the user is root, we will always have write permission Dot at end-of-line missing. > +if { [root_user] } { > + setup_xfail *-* > +} > gdb_test continue \ > "Continuing\\..*unlink 2:.*EACCES$stop_msg" \ > "Unlinking a file in a directory w/o write access returns EACCES" > diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp > index 36bf738c667..d7947e0dcf4 100644 > --- a/gdb/testsuite/lib/gdb.exp > +++ b/gdb/testsuite/lib/gdb.exp > @@ -9952,5 +9952,16 @@ proc have_host_locale { locale } { > return [expr $idx != -1] > } > > +# Return 1 if the test is being run as root, 0 otherwise Dot at end-of-line missing. > + > +gdb_caching_proc root_user {} { > + # ID outputs to stdout, we have to use exec to capture it here > + set user [remote_exec id] This should be "[remote_exec target id]". > + > + regexp -all ".*uid=(\[0-9\]+).*" $user user uid remote_exec returns a list of exit val and output. The usual thing to do is to break that apart and handle the exit val != 0 explicitly, and do the grepping in the output part. For now I think it's ok to return 0 for the exit val != 0 case, but at some point we may want to return -1, to be able to check that the user is not root by checking that { [root_user] == 0 }. Thanks, - Tom