|
| 1 | +From eb8f8cc1dd3875eda239612d67728d6a0b3d6795 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Kir Kolyshkin < [email protected]> |
| 3 | +Date: Fri, 29 Aug 2025 17:18:44 -0700 |
| 4 | +Subject: [PATCH] test/e2e: fix 'block all syscalls' seccomp for runc |
| 5 | + |
| 6 | +Error messages between runc and crun are not synchronized, and |
| 7 | +in some case exit codes can be different, too. |
| 8 | + |
| 9 | +Commit dd1bcabae9 ("CI: use local registry, part 2 of 3: fix tests") |
| 10 | +removed the special case handling for runc from the |
| 11 | +"podman run --seccomp-policy image (block all syscalls)" |
| 12 | +test case, and so it fails, for example, like this: |
| 13 | + |
| 14 | + Error: failed to connect to container's attach socket: /tmp/podman-e2e-2877753109/subtest-1698249469/p/root/overlay-containers/62585e98da7dc3fdb32d3b6de0980c762a8a6cde008ed35c68727fb97f5369c7/userdata/attach: no such file or directory |
| 15 | + [FAILED] Command exited with status 127 (expected 126) |
| 16 | + |
| 17 | +or this: |
| 18 | + |
| 19 | + time="2025-08-29T17:16:52-07:00" level=error msg="cannot start a container that has stopped" |
| 20 | + Error: `/usr/bin/runc start 63ce789f7037d9545cde832d29343704cab842e7288046407d0efa347d5ecb77` failed: exit status 1 |
| 21 | + [FAILED] Command exited 126 as expected, but did not emit 'OCI runtime error: runc: read from the init process' |
| 22 | + |
| 23 | +(depending on runc version, phase of the moon etc.) |
| 24 | + |
| 25 | +We can not reasonably expect a specific error message and exit code in |
| 26 | +such an unusual scenario, but let's try. |
| 27 | + |
| 28 | +With this commit, the above test passes successfully on my machine. |
| 29 | + |
| 30 | +Fixes: dd1bcabae9 ("CI: use local registry, part 2 of 3: fix tests") |
| 31 | +Reported-by: Yiqiao Pu < [email protected]> |
| 32 | +Signed-off-by: Kir Kolyshkin < [email protected]> |
| 33 | +--- |
| 34 | + test/e2e/run_seccomp_test.go | 20 ++++++++++++++++---- |
| 35 | + 1 file changed, 16 insertions(+), 4 deletions(-) |
| 36 | + |
| 37 | +diff --git a/test/e2e/run_seccomp_test.go b/test/e2e/run_seccomp_test.go |
| 38 | +index 82a7a42831..ca585b835d 100644 |
| 39 | +--- a/test/e2e/run_seccomp_test.go |
| 40 | ++++ b/test/e2e/run_seccomp_test.go |
| 41 | +@@ -4,6 +4,7 @@ package integration |
| 42 | + |
| 43 | + import ( |
| 44 | + "fmt" |
| 45 | ++ "path" |
| 46 | + |
| 47 | + . "github.com/containers/podman/v5/test/utils" |
| 48 | + . "github.com/onsi/ginkgo/v2" |
| 49 | +@@ -55,11 +56,22 @@ var _ = Describe("Podman run", func() { |
| 50 | + session := podmanTest.Podman([]string{"run", "--seccomp-policy", "image", img, "ls"}) |
| 51 | + session.WaitWithDefaultTimeout() |
| 52 | + |
| 53 | +- expect := fmt.Sprintf("OCI runtime error: %s: read from the init process", podmanTest.OCIRuntime) |
| 54 | +- if IsRemote() { |
| 55 | +- expect = fmt.Sprintf("for attach: %s: read from the init process: OCI runtime error", podmanTest.OCIRuntime) |
| 56 | ++ switch path.Base(podmanTest.OCIRuntime) { |
| 57 | ++ case "crun": |
| 58 | ++ expect := fmt.Sprintf("OCI runtime error: %s: read from the init process", podmanTest.OCIRuntime) |
| 59 | ++ if IsRemote() { |
| 60 | ++ expect = fmt.Sprintf("for attach: %s: read from the init process: OCI runtime error", podmanTest.OCIRuntime) |
| 61 | ++ } |
| 62 | ++ Expect(session).To(ExitWithError(126, expect)) |
| 63 | ++ case "runc": |
| 64 | ++ expect1 := "cannot start a container that has stopped" |
| 65 | ++ c1 := 126 |
| 66 | ++ expect2 := "failed to connect to container's attach socket" |
| 67 | ++ c2 := 127 |
| 68 | ++ Expect(session).To(Or(ExitWithError(c1, expect1), ExitWithError(c2, expect2))) |
| 69 | ++ default: |
| 70 | ++ Expect(session.ExitCode()).To(BeNumerically(">", 0), "Exit status using generic runtime") |
| 71 | + } |
| 72 | +- Expect(session).To(ExitWithError(126, expect)) |
| 73 | + }) |
| 74 | + |
| 75 | + It("podman run --seccomp-policy image (bogus profile)", func() { |
0 commit comments