From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691749301; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Q7oW9IYhDdtIY+t3wgLaOhONWrlfPMfhQbiGFFXVvPI=; b=V6gqMKF7kQeSPUZGg8s4HS7r1nIg1feX4m6DEMpU0/ioOOCl/SLDc0geW/Ko3Fg6Okq50H w2ujbVEXwqKoTSjJ1gd+sMPkqktIMCPaLFIYgq8nJXGoFPO40Vjdv0A3NTV0kovevIVs9h 8Icjbg+hnxq8BWEujjhoDlntYlBVHvo= 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) From: Guinevere Larsen 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 List-Id: 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