about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2021-08-13 15:29:11 +0200
committerGitHub <noreply@github.com>2021-08-13 15:29:11 +0200
commitfc3a90dc7435d3d2378cc558e06a4600d79e4115 (patch)
tree23ed6179372472243b2695486b8a74f4e264ff29
parent717f9e37696703670108f47c5dff261ca9d4d834 (diff)
parent7a7d2d1779d47cba5686136047e591346ca9f097 (diff)
downloadrust-fc3a90dc7435d3d2378cc558e06a4600d79e4115.tar.gz
rust-fc3a90dc7435d3d2378cc558e06a4600d79e4115.zip
Rollup merge of #87966 - pietroalbini:fix-pidfd-test, r=m-ou-se
Fix `command-create-pidfd` test inside unprivileged Docker containers

In `src/test/ui/command/command-create-pidfd.rs` (added #81825), the detection code to skip the test on unsupported platforms doesn't account for unprivileged Docker containers (CI uses privileged containers), which leads to a test failure as you can't call the `clone3` syscall in that environment. This PR enhances the detection code to also consider unprivileged containers.
-rw-r--r--src/test/ui/command/command-create-pidfd.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/test/ui/command/command-create-pidfd.rs b/src/test/ui/command/command-create-pidfd.rs
index 93321ac536a..4df443c66d6 100644
--- a/src/test/ui/command/command-create-pidfd.rs
+++ b/src/test/ui/command/command-create-pidfd.rs
@@ -15,7 +15,18 @@ fn has_clone3() -> bool {
     let err = (res == -1)
         .then(|| Error::last_os_error())
         .expect("probe syscall should not succeed");
-    err.raw_os_error() != Some(libc::ENOSYS)
+
+    // If the `clone3` syscall is not implemented in the current kernel version it should return an
+    // `ENOSYS` error. Docker also blocks the whole syscall inside unprivileged containers, and
+    // returns `EPERM` (instead of `ENOSYS`) when a program tries to invoke the syscall. Because of
+    // that we need to check for *both* `ENOSYS` and `EPERM`.
+    //
+    // Note that Docker's behavior is breaking other projects (notably glibc), so they're planning
+    // to update their filtering to return `ENOSYS` in a future release:
+    //
+    //     https://github.com/moby/moby/issues/42680
+    //
+    err.raw_os_error() != Some(libc::ENOSYS) && err.raw_os_error() != Some(libc::EPERM)
 }
 
 fn main() {