mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
oci: report empty exec path as ENOENT
unify the error codes returned by runc and crun. Fix the tests to work with both runtimes, as well as the https://github.com/containers/crun/pull/1672 changes in progress for crun. Follow-up for https://github.com/containers/podman/pull/25340 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> (cherry picked from commit 4695564730abf8432102f8a07546afc9f87f855b) Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:

committed by
Paul Holzinger

parent
1a4c075a1f
commit
52deb8c76e
@ -400,17 +400,14 @@ var _ = Describe("Podman exec", func() {
|
||||
setup.WaitWithDefaultTimeout()
|
||||
Expect(setup).Should(ExitCleanly())
|
||||
|
||||
expect := "chdir to `/missing`: No such file or directory"
|
||||
if podmanTest.OCIRuntime == "runc" {
|
||||
expect = "chdir to cwd"
|
||||
}
|
||||
expect := ".*(chdir to cwd|chdir to `/missing`: No such file or directory).*"
|
||||
session := podmanTest.Podman([]string{"exec", "--workdir", "/missing", "test1", "pwd"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).To(ExitWithError(127, expect))
|
||||
Expect(session).To(ExitWithErrorRegex(127, expect))
|
||||
|
||||
session = podmanTest.Podman([]string{"exec", "-w", "/missing", "test1", "pwd"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).To(ExitWithError(127, expect))
|
||||
Expect(session).To(ExitWithErrorRegex(127, expect))
|
||||
})
|
||||
|
||||
It("podman exec cannot be invoked", func() {
|
||||
|
@ -18,7 +18,12 @@ CMD []
|
||||
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
|
||||
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(ExitWithErrorRegex(126, ".*(open executable|executable path is empty): Operation not permitted: OCI permission denied.*"))
|
||||
if session.ExitCode() == 126 {
|
||||
// special case for crun <= 1.20, remove once a new version is out
|
||||
Expect(session).Should(ExitWithError(126, "open executable: Operation not permitted: OCI permission denied"))
|
||||
return
|
||||
}
|
||||
Expect(session).Should(ExitWithErrorRegex(127, ".*(executable file not found in \\$PATH|cannot find `` in \\$PATH).*: OCI runtime attempted to invoke a command that was not found.*"))
|
||||
})
|
||||
|
||||
It("podman run entrypoint == [\"\"]", func() {
|
||||
|
@ -22,13 +22,15 @@ var _ = Describe("Podman run exit", func() {
|
||||
It("podman run exit ExecErrorCodeCannotInvoke", func() {
|
||||
result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(ExitWithErrorRegex(define.ExecErrorCodeCannotInvoke, ".*(open executable|the path `/etc` is not a regular file): Operation not permitted: OCI permission denied.*"))
|
||||
expected := ".*(exec: \"/etc\": is a directory|(open executable|the path `/etc` is not a regular file): Operation not permitted: OCI permission denied).*"
|
||||
Expect(result).Should(ExitWithErrorRegex(define.ExecErrorCodeCannotInvoke, expected))
|
||||
})
|
||||
|
||||
It("podman run exit ExecErrorCodeNotFound", func() {
|
||||
result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(ExitWithError(define.ExecErrorCodeNotFound, "executable file `foobar` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found"))
|
||||
expected := ".*(executable file not found in \\$PATH|executable file `foobar` not found in \\$PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found).*"
|
||||
Expect(result).Should(ExitWithErrorRegex(define.ExecErrorCodeNotFound, expected))
|
||||
})
|
||||
|
||||
It("podman run exit 0", func() {
|
||||
|
@ -1657,7 +1657,7 @@ search | $IMAGE |
|
||||
# runc and crun emit different diagnostics
|
||||
runtime=$(podman_runtime)
|
||||
case "$runtime" in
|
||||
crun) expect='\(executable file `` not found in $PATH: No such file or directory: OCI runtime attempted to invoke a command that was not found\|executable path is empty\)' ;;
|
||||
crun) expect='\(executable file `` not found in $PATH\|cannot find `` in $PATH\): No such file or directory: OCI runtime attempted to invoke a command that was not found' ;;
|
||||
runc) expect='runc: runc create failed: unable to start container process: exec: "": executable file not found in $PATH: OCI runtime attempted to invoke a command that was not found' ;;
|
||||
*) skip "Unknown runtime '$runtime'" ;;
|
||||
esac
|
||||
|
Reference in New Issue
Block a user