From: Tom de Vries Date: Sat, 30 Dec 2023 19:04:10 +0000 (+0100) Subject: [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user X-Git-Tag: binutils-2_42~332 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=11e73fe731c553171f09b48636dfc347cb3ac266;p=thirdparty%2Fbinutils-gdb.git [gdb/testsuite] Fix gdb.base/gdb-index-err.exp for root user 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. Reviewed-By: Lancelot SIX PR testsuite/31197 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=31197 --- 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