4
. "github.com/containers/podman/v5/test/utils"
5
. "github.com/onsi/ginkgo/v2"
6
. "github.com/onsi/gomega"
7
. "github.com/onsi/gomega/gexec"
10
var _ = Describe("Podman run entrypoint", func() {
12
It("podman run no command, entrypoint, or cmd", func() {
13
dockerfile := `FROM quay.io/libpod/alpine:latest
17
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
18
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
19
session.WaitWithDefaultTimeout()
20
Expect(session).Should(Or(Exit(126), Exit(127)))
23
It("podman run entrypoint == [\"\"]", func() {
24
dockerfile := `FROM quay.io/libpod/alpine:latest
28
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
29
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest", "echo", "hello"})
30
session.WaitWithDefaultTimeout()
31
Expect(session).Should(ExitCleanly())
32
Expect(session.OutputToString()).To(Equal("hello"))
35
It("podman run entrypoint", func() {
36
dockerfile := `FROM quay.io/libpod/alpine:latest
37
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
39
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
40
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
41
session.WaitWithDefaultTimeout()
42
Expect(session).Should(ExitCleanly())
43
Expect(session.OutputToStringArray()).To(HaveLen(2))
46
It("podman run entrypoint with cmd", func() {
47
dockerfile := `FROM quay.io/libpod/alpine:latest
49
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
51
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
52
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest"})
53
session.WaitWithDefaultTimeout()
54
Expect(session).Should(ExitCleanly())
55
Expect(session.OutputToStringArray()).To(HaveLen(4))
58
It("podman run entrypoint with user cmd overrides image cmd", func() {
59
dockerfile := `FROM quay.io/libpod/alpine:latest
61
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
63
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
64
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest", "-i"})
65
session.WaitWithDefaultTimeout()
66
Expect(session).Should(ExitCleanly())
67
Expect(session.OutputToStringArray()).To(HaveLen(5))
70
It("podman run entrypoint with user cmd no image cmd", func() {
71
dockerfile := `FROM quay.io/libpod/alpine:latest
72
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
74
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
75
session := podmanTest.Podman([]string{"run", "foobar.com/entrypoint:latest", "-i"})
76
session.WaitWithDefaultTimeout()
77
Expect(session).Should(ExitCleanly())
78
Expect(session.OutputToStringArray()).To(HaveLen(5))
81
It("podman run user entrypoint overrides image entrypoint and image cmd", func() {
82
dockerfile := `FROM quay.io/libpod/alpine:latest
84
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
86
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
87
session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest"})
88
session.WaitWithDefaultTimeout()
89
Expect(session).Should(ExitCleanly())
90
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("Linux")))
92
session = podmanTest.Podman([]string{"run", "--entrypoint", "", "foobar.com/entrypoint:latest", "uname"})
93
session.WaitWithDefaultTimeout()
94
Expect(session).Should(ExitCleanly())
95
Expect(session.OutputToStringArray()).To(ContainElement(HavePrefix("Linux")))
98
It("podman run user entrypoint with command overrides image entrypoint and image cmd", func() {
99
dockerfile := `FROM quay.io/libpod/alpine:latest
101
ENTRYPOINT ["grep", "Alpine", "/etc/os-release"]
103
podmanTest.BuildImage(dockerfile, "foobar.com/entrypoint:latest", "false")
104
session := podmanTest.Podman([]string{"run", "--entrypoint=uname", "foobar.com/entrypoint:latest", "-r"})
105
session.WaitWithDefaultTimeout()
106
Expect(session).Should(ExitCleanly())
107
Expect(session.OutputToStringArray()).To(Not(ContainElement(HavePrefix("Linux"))))