From: Tom de Vries <tdevries@suse.de>
To: Guinevere Larsen <blarsen@redhat.com>, gdb-patches@sourceware.org
Cc: lsix@lancelotsix.com
Subject: Re: [PATCH v2] gdb/testsuite: XFAIL some gdb.base/fileio.exp
Date: Tue, 26 Sep 2023 15:21:58 +0200 [thread overview]
Message-ID: <94c0586a-14c4-480d-bf74-af50ba1c0a7f@suse.de> (raw)
In-Reply-To: <20230814102449.203616-2-blarsen@redhat.com>
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
next prev parent reply other threads:[~2023-09-26 13:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 10:21 [PATCH] " Guinevere Larsen
2023-08-11 13:19 ` Lancelot SIX
2023-08-11 14:26 ` Guinevere Larsen
2023-08-14 10:24 ` [PATCH v2] " Guinevere Larsen
2023-09-14 13:12 ` [PING][PATCH " Guinevere Larsen
2023-09-26 13:21 ` Tom de Vries [this message]
2023-10-04 14:02 ` [PATCH v3] " Guinevere Larsen
2023-10-04 15:33 ` Tom de Vries
2023-10-04 15:47 ` Guinevere Larsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=94c0586a-14c4-480d-bf74-af50ba1c0a7f@suse.de \
--to=tdevries@suse.de \
--cc=blarsen@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=lsix@lancelotsix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).