From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id gRX0IMwL1mT4yj0AWB0awg (envelope-from ) for ; Fri, 11 Aug 2023 06:22:04 -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=Yy+q76XM; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 7DD821E0BB; Fri, 11 Aug 2023 06:22:04 -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 6C4F11E00F for ; Fri, 11 Aug 2023 06:22:02 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AF1653857354 for ; Fri, 11 Aug 2023 10:22:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AF1653857354 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1691749321; bh=Q7oW9IYhDdtIY+t3wgLaOhONWrlfPMfhQbiGFFXVvPI=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=Yy+q76XMHsuA/tuQAxLzS8tSHGAuaWVdV8vuaYivSxu3obRGlO349q4DbyAs/INN5 T8g/yJKjkNLqT0RwKrnTiEnFciH9Ij0HbA1LX3d6ELdYnvUiUKeKJwB+sEFOECN/k2 Ryof+jGkVCFIUOvyZdNcNDKCOj4c/61DeoH7gbsQ= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1430D3857C44 for ; Fri, 11 Aug 2023 10:21:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1430D3857C44 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-327-K-Bx9NYxPL-6oQJ7NWUupA-1; Fri, 11 Aug 2023 06:21:40 -0400 X-MC-Unique: K-Bx9NYxPL-6oQJ7NWUupA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 269D8817077 for ; Fri, 11 Aug 2023 10:21:40 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.224.77]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A17D12026FFE; Fri, 11 Aug 2023 10:21:39 +0000 (UTC) To: gdb-patches@sourceware.org Cc: Guinevere Larsen Subject: [PATCH] gdb/testsuite: XFAIL some gdb.base/fileio.exp Date: Fri, 11 Aug 2023 12:21:34 +0200 Message-ID: <20230811102134.2796842-1-blarsen@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Guinevere Larsen via Gdb-patches Reply-To: Guinevere Larsen Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" 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. --- 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 +if { [root_user] } { + setup_xfail *-* +} 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 +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..de98f8bb2ac 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 + +gdb_caching_proc root_user {} { + # ID outputs to stdout, we have to use exec to capture it here + set user [exec id] + + regexp -all ".*uid=(\[0-9\]+).*" $user user uid + + return [expr $uid == 0] +} + # Always load compatibility stuff. load_lib future.exp -- 2.41.0