* [PATCH] [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user
@ 2023-12-29 6:35 Tom de Vries
2023-12-30 15:47 ` Lancelot SIX
0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2023-12-29 6:35 UTC (permalink / raw)
To: gdb-patches
When running test-case gdb.base/gdb-index-err.exp in a container as root user,
I run into:
...
FAIL: gdb.base/gdb-index-err.exp: flag=: \
try to write index to a non-writable directory
FAIL: gdb.base/gdb-index-err.exp: flag=-dwarf-5: \
try to write index to a non-writable directory
...
The test-case creates a directory without write permissions:
...
$ ls -ald private
dr-xr-xr-x 2 root root 4096 Dec 29 06:26 private/
...
but apparently the root user is still able to write in it.
Fix this by making the test unsupported for the root user.
Tested on x86_64-linux.
PR testsuite/31197
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31197
---
gdb/testsuite/gdb.base/gdb-index-err.exp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/gdb/testsuite/gdb.base/gdb-index-err.exp b/gdb/testsuite/gdb.base/gdb-index-err.exp
index 31f133efbcd..cefd708f5ab 100644
--- a/gdb/testsuite/gdb.base/gdb-index-err.exp
+++ b/gdb/testsuite/gdb.base/gdb-index-err.exp
@@ -62,9 +62,15 @@ remote_exec host "chmod u-w,g-w ${non_writable_dir}"
# Try to write the index into a non-writable directory.
foreach_with_prefix flag { "" "-dwarf-5" } {
+ set test "try to write index to a non-writable directory"
+ if { [root_user] } {
+ unsupported $test
+ continue
+ }
+
gdb_test "save gdb-index ${flag} ${non_writable_dir}" \
"Error while writing index for `[string_to_regexp $binfile]': couldn't open `[string_to_regexp $non_writable_dir]/${gdb_test_file_name}.*': Permission denied\\." \
- "try to write index to a non-writable directory"
+ $test
}
# Create copies of the executable, we will add an index section to
base-commit: a6d0019eb7fcd634e12b7bcc535d5181c47fc82a
--
2.35.3
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user
2023-12-29 6:35 [PATCH] [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user Tom de Vries
@ 2023-12-30 15:47 ` Lancelot SIX
2023-12-30 19:09 ` Tom de Vries
0 siblings, 1 reply; 3+ messages in thread
From: Lancelot SIX @ 2023-12-30 15:47 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
Hi Tom,
On Fri, Dec 29, 2023 at 07:35:43AM +0100, Tom de Vries wrote:
> When running test-case gdb.base/gdb-index-err.exp in a container as root user,
> I run into:
> ...
> FAIL: gdb.base/gdb-index-err.exp: flag=: \
> try to write index to a non-writable directory
> FAIL: gdb.base/gdb-index-err.exp: flag=-dwarf-5: \
> try to write index to a non-writable directory
> ...
>
> The test-case creates a directory without write permissions:
> ...
> $ ls -ald private
> dr-xr-xr-x 2 root root 4096 Dec 29 06:26 private/
> ...
> but apparently the root user is still able to write in it.
>
> Fix this by making the test unsupported for the root user.
>
> Tested on x86_64-linux.
>
> PR testsuite/31197
> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31197
> ---
> gdb/testsuite/gdb.base/gdb-index-err.exp | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/testsuite/gdb.base/gdb-index-err.exp b/gdb/testsuite/gdb.base/gdb-index-err.exp
> index 31f133efbcd..cefd708f5ab 100644
> --- a/gdb/testsuite/gdb.base/gdb-index-err.exp
> +++ b/gdb/testsuite/gdb.base/gdb-index-err.exp
> @@ -62,9 +62,15 @@ remote_exec host "chmod u-w,g-w ${non_writable_dir}"
>
> # Try to write the index into a non-writable directory.
> foreach_with_prefix flag { "" "-dwarf-5" } {
> + set test "try to write index to a non-writable directory"
> + if { [root_user] } {
> + unsupported $test
> + continue
> + }
> +
> gdb_test "save gdb-index ${flag} ${non_writable_dir}" \
> "Error while writing index for `[string_to_regexp $binfile]': couldn't open `[string_to_regexp $non_writable_dir]/${gdb_test_file_name}.*': Permission denied\\." \
> - "try to write index to a non-writable directory"
> + $test
> }
>
> # Create copies of the executable, we will add an index section to
>
> base-commit: a6d0019eb7fcd634e12b7bcc535d5181c47fc82a
> --
> 2.35.3
>
This looks reasonable to me. Thanks for doing this.
I had a look around because the other places which use root_user
generate XFAILs and not UNSUPPORTED as you do here. I however don’t
think that gdb.base/fileio.exp could use UNSUPPORTED, and it is better
suited for the case you are addressing here, so that LGTM.
Best,
Lancelot.
Reviewed-By: Lancelot SIX <lancelot.six@amd.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user
2023-12-30 15:47 ` Lancelot SIX
@ 2023-12-30 19:09 ` Tom de Vries
0 siblings, 0 replies; 3+ messages in thread
From: Tom de Vries @ 2023-12-30 19:09 UTC (permalink / raw)
To: Lancelot SIX; +Cc: gdb-patches
On 12/30/23 16:47, Lancelot SIX wrote:
> Hi Tom,
>
> On Fri, Dec 29, 2023 at 07:35:43AM +0100, Tom de Vries wrote:
>> When running test-case gdb.base/gdb-index-err.exp in a container as root user,
>> I run into:
>> ...
>> FAIL: gdb.base/gdb-index-err.exp: flag=: \
>> try to write index to a non-writable directory
>> FAIL: gdb.base/gdb-index-err.exp: flag=-dwarf-5: \
>> try to write index to a non-writable directory
>> ...
>>
>> The test-case creates a directory without write permissions:
>> ...
>> $ ls -ald private
>> dr-xr-xr-x 2 root root 4096 Dec 29 06:26 private/
>> ...
>> but apparently the root user is still able to write in it.
>>
>> Fix this by making the test unsupported for the root user.
>>
>> Tested on x86_64-linux.
>>
>> PR testsuite/31197
>> Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31197
>> ---
>> gdb/testsuite/gdb.base/gdb-index-err.exp | 8 +++++++-
>> 1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/gdb/testsuite/gdb.base/gdb-index-err.exp b/gdb/testsuite/gdb.base/gdb-index-err.exp
>> index 31f133efbcd..cefd708f5ab 100644
>> --- a/gdb/testsuite/gdb.base/gdb-index-err.exp
>> +++ b/gdb/testsuite/gdb.base/gdb-index-err.exp
>> @@ -62,9 +62,15 @@ remote_exec host "chmod u-w,g-w ${non_writable_dir}"
>>
>> # Try to write the index into a non-writable directory.
>> foreach_with_prefix flag { "" "-dwarf-5" } {
>> + set test "try to write index to a non-writable directory"
>> + if { [root_user] } {
>> + unsupported $test
>> + continue
>> + }
>> +
>> gdb_test "save gdb-index ${flag} ${non_writable_dir}" \
>> "Error while writing index for `[string_to_regexp $binfile]': couldn't open `[string_to_regexp $non_writable_dir]/${gdb_test_file_name}.*': Permission denied\\." \
>> - "try to write index to a non-writable directory"
>> + $test
>> }
>>
>> # Create copies of the executable, we will add an index section to
>>
>> base-commit: a6d0019eb7fcd634e12b7bcc535d5181c47fc82a
>> --
>> 2.35.3
>>
>
> This looks reasonable to me. Thanks for doing this.
>
> I had a look around because the other places which use root_user
> generate XFAILs and not UNSUPPORTED as you do here. I however don’t
> think that gdb.base/fileio.exp could use UNSUPPORTED, and it is better
> suited for the case you are addressing here, so that LGTM.
>
Thanks for the review, pushed.
[ FWIW, I've looked at the case of gdb.base/fileio.exp, and I suspect it
also should use unsupported. The xfail tag is supposed to tag known
incorrect behaviour of the environment (say, a compiler bug in
generating debug info), and I don't see any there. ]
Thanks,
- Tom
> Best,
> Lancelot.
>
> Reviewed-By: Lancelot SIX <lancelot.six@amd.com>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-30 19:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29 6:35 [PATCH] [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user Tom de Vries
2023-12-30 15:47 ` Lancelot SIX
2023-12-30 19:09 ` Tom de Vries
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).