github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/test/e2e/run_exit_test.go (about) 1 package integration 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/hanks177/podman/v4/libpod/define" 8 . "github.com/hanks177/podman/v4/test/utils" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 . "github.com/onsi/gomega/gexec" 12 ) 13 14 var _ = Describe("Podman run exit", func() { 15 var ( 16 tempdir string 17 err error 18 podmanTest *PodmanTestIntegration 19 ) 20 21 BeforeEach(func() { 22 tempdir, err = CreateTempDirInTempDir() 23 if err != nil { 24 os.Exit(1) 25 } 26 podmanTest = PodmanTestCreate(tempdir) 27 podmanTest.Setup() 28 }) 29 30 AfterEach(func() { 31 podmanTest.Cleanup() 32 f := CurrentGinkgoTestDescription() 33 processTestResult(f) 34 35 }) 36 37 It("podman run exit define.ExecErrorCodeGeneric", func() { 38 result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"}) 39 result.WaitWithDefaultTimeout() 40 Expect(result).Should(Exit(define.ExecErrorCodeGeneric)) 41 }) 42 43 It("podman run exit ExecErrorCodeCannotInvoke", func() { 44 result := podmanTest.Podman([]string{"run", ALPINE, "/etc"}) 45 result.WaitWithDefaultTimeout() 46 Expect(result).Should(Exit(define.ExecErrorCodeCannotInvoke)) 47 }) 48 49 It("podman run exit ExecErrorCodeNotFound", func() { 50 result := podmanTest.Podman([]string{"run", ALPINE, "foobar"}) 51 result.WaitWithDefaultTimeout() 52 Expect(result).Should(Exit(define.ExecErrorCodeNotFound)) 53 }) 54 55 It("podman run exit 0", func() { 56 result := podmanTest.Podman([]string{"run", ALPINE, "ls"}) 57 result.WaitWithDefaultTimeout() 58 Expect(result).Should(Exit(0)) 59 }) 60 61 It("podman run exit 50", func() { 62 result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"}) 63 result.WaitWithDefaultTimeout() 64 Expect(result).Should(Exit(50)) 65 }) 66 67 It("podman run exit 125", func() { 68 result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", fmt.Sprintf("exit %d", define.ExecErrorCodeGeneric)}) 69 result.WaitWithDefaultTimeout() 70 Expect(result).Should(Exit(define.ExecErrorCodeGeneric)) 71 }) 72 })