mirror of
https://github.com/containers/podman.git
synced 2025-07-02 00:30:00 +08:00
Merge pull request #23087 from edsantiago/exitwitherror-more
ExitWithError(): continued
This commit is contained in:
@ -16,7 +16,7 @@ var _ = Describe("Podman restart", func() {
|
||||
It("podman restart bogus container", func() {
|
||||
session := podmanTest.Podman([]string{"start", "123"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(125))
|
||||
Expect(session).Should(ExitWithError(125, `no container with name or ID "123" found: no such container`))
|
||||
})
|
||||
|
||||
It("podman restart stopped container by name", func() {
|
||||
@ -283,20 +283,19 @@ var _ = Describe("Podman restart", func() {
|
||||
SkipIfRemote("--latest flag n/a")
|
||||
result := podmanTest.Podman([]string{"restart", "--cidfile", "foobar", "--latest"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together"))
|
||||
|
||||
result = podmanTest.Podman([]string{"restart", "--cidfile", "foobar", "--all"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together"))
|
||||
|
||||
result = podmanTest.Podman([]string{"restart", "--cidfile", "foobar", "--all", "--latest"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together"))
|
||||
|
||||
result = podmanTest.Podman([]string{"restart", "--latest", "--all"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all and --latest cannot be used together"))
|
||||
})
|
||||
|
||||
It("podman restart --filter", func() {
|
||||
@ -318,7 +317,7 @@ var _ = Describe("Podman restart", func() {
|
||||
|
||||
session1 = podmanTest.Podman([]string{"restart", cid1, "-f", "status=test"})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(125))
|
||||
Expect(session1).Should(ExitWithError(125, "--filter takes no arguments"))
|
||||
|
||||
session1 = podmanTest.Podman([]string{"restart", "-a", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
. "github.com/containers/podman/v5/test/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
var _ = Describe("Podman rm", func() {
|
||||
@ -29,8 +28,7 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
result := podmanTest.Podman([]string{"rm", cid})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(2))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("containers cannot be removed without force"))
|
||||
Expect(result).Should(ExitWithError(2, "containers cannot be removed without force"))
|
||||
})
|
||||
|
||||
It("podman rm created container", func() {
|
||||
@ -169,23 +167,19 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
result := podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--latest"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("--all, --latest, and --cidfile cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together"))
|
||||
|
||||
result = podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--all"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("--all, --latest, and --cidfile cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together"))
|
||||
|
||||
result = podmanTest.Podman([]string{"rm", "--cidfile", "foobar", "--all", "--latest"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("--all, --latest, and --cidfile cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all, --latest, and --cidfile cannot be used together"))
|
||||
|
||||
result = podmanTest.Podman([]string{"rm", "--latest", "--all"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(125))
|
||||
Expect(result.ErrorToString()).To(ContainSubstring("--all and --latest cannot be used together"))
|
||||
Expect(result).Should(ExitWithError(125, "--all and --latest cannot be used together"))
|
||||
})
|
||||
|
||||
It("podman rm --all", func() {
|
||||
@ -214,8 +208,7 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "bogus", cid})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container"))
|
||||
Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`))
|
||||
if IsRemote() {
|
||||
Expect(session.OutputToString()).To(BeEquivalentTo(cid))
|
||||
}
|
||||
@ -232,8 +225,7 @@ var _ = Describe("Podman rm", func() {
|
||||
It("podman rm bogus container", func() {
|
||||
session := podmanTest.Podman([]string{"rm", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container"))
|
||||
Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`))
|
||||
})
|
||||
|
||||
It("podman rm bogus container and a running container", func() {
|
||||
@ -243,13 +235,11 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "bogus", "test1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container"))
|
||||
Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`))
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "test1", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("\"bogus\" found: no such container"))
|
||||
Expect(session).Should(ExitWithError(1, `no container with ID or name "bogus" found: no such container`))
|
||||
})
|
||||
|
||||
It("podman rm --ignore bogus container and a running container", func() {
|
||||
@ -259,8 +249,7 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "--ignore", "test1", "bogus"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(2))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("containers cannot be removed without force"))
|
||||
Expect(session).Should(ExitWithError(2, "containers cannot be removed without force"))
|
||||
|
||||
session = podmanTest.Podman([]string{"rm", "-t", "0", "--force", "--ignore", "bogus", "test1"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
@ -292,8 +281,7 @@ var _ = Describe("Podman rm", func() {
|
||||
|
||||
session1 = podmanTest.Podman([]string{"rm", cid1, "-f", "--filter", "status=running"})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
Expect(session1).Should(Exit(125))
|
||||
Expect(session1.ErrorToString()).To(ContainSubstring("--filter takes no arguments"))
|
||||
Expect(session1).Should(ExitWithError(125, "--filter takes no arguments"))
|
||||
|
||||
session1 = podmanTest.Podman([]string{"rm", "-a", "-f", "--filter", fmt.Sprintf("id=%swrongid", shortCid3)})
|
||||
session1.WaitWithDefaultTimeout()
|
||||
|
@ -9,7 +9,6 @@ import (
|
||||
. "github.com/containers/podman/v5/test/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
func createContainersConfFileWithDevices(pTest *PodmanTestIntegration, devices string) {
|
||||
@ -95,7 +94,7 @@ var _ = Describe("Podman run device", func() {
|
||||
// verify --privileged is required
|
||||
session2 := podmanTest.Podman([]string{"run", ALPINE, "test", "-c", "/dev/kmsg"})
|
||||
session2.WaitWithDefaultTimeout()
|
||||
Expect(session2).Should(Exit(1))
|
||||
Expect(session2).Should(ExitWithError(1, ""))
|
||||
Expect(session2.OutputToString()).To(BeEmpty())
|
||||
})
|
||||
|
||||
|
@ -6,7 +6,6 @@ import (
|
||||
. "github.com/containers/podman/v5/test/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
var _ = Describe("Podman run", func() {
|
||||
@ -54,7 +53,7 @@ var _ = Describe("Podman run", func() {
|
||||
session = podmanTest.Podman([]string{"run", "--rm", "--env", "FOO", ALPINE, "printenv", "FOO"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session.OutputToString()).To(BeEmpty())
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session).Should(ExitWithError(1, ""))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--rm", ALPINE, "printenv"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
@ -90,8 +89,7 @@ ENV hello=world
|
||||
session.WaitWithDefaultTimeout()
|
||||
if IsRemote() {
|
||||
// podman-remote does not support --env-host
|
||||
Expect(session).Should(Exit(125))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("unknown flag: --env-host"))
|
||||
Expect(session).Should(ExitWithError(125, "unknown flag: --env-host"))
|
||||
return
|
||||
}
|
||||
Expect(session).Should(ExitCleanly())
|
||||
@ -125,7 +123,7 @@ ENV hello=world
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--http-proxy=false", ALPINE, "printenv", "http_proxy"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(1))
|
||||
Expect(session).Should(ExitWithError(1, ""))
|
||||
Expect(session.OutputToString()).To(Equal(""))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--env", "http_proxy=5.6.7.8", ALPINE, "printenv", "http_proxy"})
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
. "github.com/containers/podman/v5/test/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
var _ = Describe("Podman run exit", func() {
|
||||
@ -15,19 +14,19 @@ var _ = Describe("Podman run exit", func() {
|
||||
It("podman run exit define.ExecErrorCodeGeneric", func() {
|
||||
result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
|
||||
Expect(result).Should(ExitWithError(define.ExecErrorCodeGeneric, "unknown flag: --foobar"))
|
||||
})
|
||||
|
||||
It("podman run exit ExecErrorCodeCannotInvoke", func() {
|
||||
result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(define.ExecErrorCodeCannotInvoke))
|
||||
Expect(result).Should(ExitWithError(define.ExecErrorCodeCannotInvoke, "open executable: Operation not permitted: OCI permission denied"))
|
||||
})
|
||||
|
||||
It("podman run exit ExecErrorCodeNotFound", func() {
|
||||
result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(define.ExecErrorCodeNotFound))
|
||||
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"))
|
||||
})
|
||||
|
||||
It("podman run exit 0", func() {
|
||||
@ -39,12 +38,12 @@ var _ = Describe("Podman run exit", func() {
|
||||
It("podman run exit 50", func() {
|
||||
result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(50))
|
||||
Expect(result).Should(ExitWithError(50, ""))
|
||||
})
|
||||
|
||||
It("podman run exit 125", func() {
|
||||
result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", fmt.Sprintf("exit %d", define.ExecErrorCodeGeneric)})
|
||||
result.WaitWithDefaultTimeout()
|
||||
Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
|
||||
Expect(result).Should(ExitWithError(define.ExecErrorCodeGeneric, ""))
|
||||
})
|
||||
})
|
||||
|
@ -7,7 +7,6 @@ import (
|
||||
. "github.com/containers/podman/v5/test/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
"github.com/opencontainers/selinux/go-selinux"
|
||||
)
|
||||
|
||||
@ -124,7 +123,7 @@ var _ = Describe("Podman run", func() {
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--security-opt", "label=type:spc_t", "--security-opt", "label=filetype:foobar", fedoraMinimal, "ls", "-Z", "/dev"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(126))
|
||||
Expect(session).Should(ExitWithError(126, "invalid argument"))
|
||||
})
|
||||
|
||||
It("podman exec selinux check", func() {
|
||||
|
@ -12,7 +12,6 @@ import (
|
||||
"github.com/containers/storage"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
func createContainersConfFileWithCustomUserns(pTest *PodmanTestIntegration, userns string) {
|
||||
@ -371,13 +370,11 @@ var _ = Describe("Podman UserNS support", func() {
|
||||
It("podman --userns= conflicts with ui[dg]map and sub[ug]idname", func() {
|
||||
session := podmanTest.Podman([]string{"run", "--userns=host", "--uidmap=0:1:500", "alpine", "true"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(125))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive"))
|
||||
Expect(session).Should(ExitWithError(125, "--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive"))
|
||||
|
||||
session = podmanTest.Podman([]string{"run", "--userns=host", "--gidmap=0:200:5000", "alpine", "true"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(125))
|
||||
Expect(session.ErrorToString()).To(ContainSubstring("--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive"))
|
||||
Expect(session).Should(ExitWithError(125, "--userns and --uidmap/--gidmap/--subuidname/--subgidname are mutually exclusive"))
|
||||
|
||||
// with sub[ug]idname we don't check for the error output since the error message could be different, depending on the
|
||||
// system configuration since the specified user could not be defined and cause a different earlier error.
|
||||
|
@ -132,7 +132,7 @@ var _ = Describe("Podman run with volumes", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
session := podmanTest.Podman([]string{"run", "-v", mountPath + ":" + dest, "-v", "/tmp" + ":" + dest, ALPINE, "ls"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(125))
|
||||
Expect(session).Should(ExitWithError(125, fmt.Sprintf("%s: duplicate mount destination", dest)))
|
||||
})
|
||||
|
||||
It("podman run with conflict between image volume and user mount succeeds", func() {
|
||||
@ -430,7 +430,7 @@ var _ = Describe("Podman run with volumes", func() {
|
||||
|
||||
noCopySession := podmanTest.Podman([]string{"run", "--rm", "-v", "testvol4:/etc/apk:nocopy", ALPINE, "stat", "-c", "%h", "/etc/apk/arch"})
|
||||
noCopySession.WaitWithDefaultTimeout()
|
||||
Expect(noCopySession).Should(Exit(1))
|
||||
Expect(noCopySession).Should(ExitWithError(1, "stat: can't stat '/etc/apk/arch': No such file or directory"))
|
||||
})
|
||||
|
||||
It("podman named volume copyup symlink", func() {
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
. "github.com/containers/podman/v5/test/utils"
|
||||
. "github.com/onsi/ginkgo/v2"
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
)
|
||||
|
||||
var _ = Describe("Podman run", func() {
|
||||
@ -23,7 +22,7 @@ var _ = Describe("Podman run", func() {
|
||||
It("podman run a container using non existing --workdir", func() {
|
||||
session := podmanTest.Podman([]string{"run", "--workdir", "/home/foobar", ALPINE, "pwd"})
|
||||
session.WaitWithDefaultTimeout()
|
||||
Expect(session).Should(Exit(126))
|
||||
Expect(session).Should(ExitWithError(126, `workdir "/home/foobar" does not exist on container `))
|
||||
})
|
||||
|
||||
It("podman run a container using a --workdir under a bind mount", func() {
|
||||
|
Reference in New Issue
Block a user