aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Burgess <aburgess@redhat.com>2025-06-25 11:24:30 +0100
committerAndrew Burgess <aburgess@redhat.com>2025-06-26 13:39:24 +0100
commitb95b15404f2ddd2136bf2997c47c88b6001fa5f2 (patch)
tree0cdf8821fdf7f7a4e1d48df737457b6e3aecb83d
parent5fe70629ceafc157d896adec7799a8888d51dd6b (diff)
downloadbinutils-b95b15404f2ddd2136bf2997c47c88b6001fa5f2.zip
binutils-b95b15404f2ddd2136bf2997c47c88b6001fa5f2.tar.gz
binutils-b95b15404f2ddd2136bf2997c47c88b6001fa5f2.tar.bz2
gdb/testsuite: handle failure to start process for later attach test
Commit: commit b23903836007d1acaf7f8c059ab000ee83fcebfa Date: Tue Mar 21 13:01:26 2023 +0100 gdb: linux-namespaces: enter user namespace when appropriate added a new test gdb.base/user-namespace-attach.exp. It has been reported that this test will sometimes fail, like this: (gdb) attach 184732 Attaching to process 184732 warning: process 184732 is a zombie - the process has already terminated ptrace: Operation not permitted. (gdb) FAIL: gdb.base/user-namespace-attach.exp: flags=--mount --map-root-user: attach to inferior the test tries to run the 'unshare' application. Sometimes though, the application is present, but the set of flags used is not supported (maybe due to restrictions on the local machine), so we see behaviour like this: $ unshare --mount --map-root-user /bin/true; echo $? unshare: unshare failed: Operation not permitted 1 Handle this case by first running 'unshare' with the same flags, but using '/bin/true', if this fails then assume the flags are not supported, and skip the test. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33108
-rw-r--r--gdb/testsuite/gdb.base/user-namespace-attach.exp14
1 files changed, 13 insertions, 1 deletions
diff --git a/gdb/testsuite/gdb.base/user-namespace-attach.exp b/gdb/testsuite/gdb.base/user-namespace-attach.exp
index 9936bb9..741093c 100644
--- a/gdb/testsuite/gdb.base/user-namespace-attach.exp
+++ b/gdb/testsuite/gdb.base/user-namespace-attach.exp
@@ -56,10 +56,22 @@ proc run_test { flags } {
set prefix ""
}
+ set unshare_cmd "unshare $flags"
+ # Run '/bin/true' using UNSHARE_CMD. If the flags in UNSHARE_CMD
+ # aren't supported then this will fail, this means we shouldn't
+ # spawn the command with our test executable and try attaching.
+ #
+ # This will also fail if /bin/true isn't present, or doesn't work
+ # as we expect. But this should be fine for many targets.
+ set res [remote_exec target "$unshare_cmd /bin/true"]
+ if { [lindex $res 0] != 0 } {
+ unsupported "unshare flags not supported"
+ return
+ }
set inferior_spawn_id \
- [spawn_wait_for_attach [list "unshare $flags $::binfile"]]
+ [spawn_wait_for_attach [list "$unshare_cmd $::binfile"]]
if { $inferior_spawn_id == -1 } {
unsupported "failed to spawn for attach"
return