From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Cm7XIBPbEmWPdx0AWB0awg (envelope-from ) for ; Tue, 26 Sep 2023 09:22:27 -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=lzLOirPN; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7D3AB1E0C3; Tue, 26 Sep 2023 09:22:27 -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 6C2281E092 for ; Tue, 26 Sep 2023 09:22:25 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 67B3F3858C2A for ; Tue, 26 Sep 2023 13:22:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 67B3F3858C2A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1695734544; bh=kTKuL7EUeQy7GbosQzjAkya+yyL0yBKRqOyuF/rEODo=; h=Date:Subject:To:Cc:References:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=lzLOirPNVHVXBSFX/4FsYEByUq4/WFdXZyQWRTMCVaLKCWXKD9TOTxTqmMp4SgFNG fqbe/xQlkfZqatMZ3Uk6SBObBiencb08N8KDX1GGCHbzX1wwnS9CV8VIGUIApc3U76 U6lHp5+WEL5whvHuoy3leFeI4v8LWEnGDJ7IgFEI= 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 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) 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 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 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 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