github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/run_exit_test.go (about) 1 package integration 2 3 import ( 4 "os" 5 6 "github.com/containers/libpod/libpod/define" 7 . "github.com/containers/libpod/test/utils" 8 . "github.com/onsi/ginkgo" 9 . "github.com/onsi/gomega" 10 ) 11 12 var _ = Describe("Podman run exit", func() { 13 var ( 14 tempdir string 15 err error 16 podmanTest *PodmanTestIntegration 17 ) 18 19 BeforeEach(func() { 20 tempdir, err = CreateTempDirInTempDir() 21 if err != nil { 22 os.Exit(1) 23 } 24 podmanTest = PodmanTestCreate(tempdir) 25 podmanTest.Setup() 26 podmanTest.SeedImages() 27 }) 28 29 AfterEach(func() { 30 podmanTest.Cleanup() 31 f := CurrentGinkgoTestDescription() 32 processTestResult(f) 33 34 }) 35 36 It("podman run exit define.ExecErrorCodeGeneric", func() { 37 result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"}) 38 result.WaitWithDefaultTimeout() 39 Expect(result.ExitCode()).To(Equal(define.ExecErrorCodeGeneric)) 40 }) 41 42 It("podman run exit ExecErrorCodeCannotInvoke", func() { 43 result := podmanTest.Podman([]string{"run", ALPINE, "/etc"}) 44 result.WaitWithDefaultTimeout() 45 Expect(result.ExitCode()).To(Equal(define.ExecErrorCodeCannotInvoke)) 46 }) 47 48 It("podman run exit ExecErrorCodeNotFound", func() { 49 result := podmanTest.Podman([]string{"run", ALPINE, "foobar"}) 50 result.WaitWithDefaultTimeout() 51 Expect(result.ExitCode()).To(Not(Equal(define.ExecErrorCodeGeneric))) 52 // TODO This is failing we believe because of a race condition 53 // Between conmon and podman closing the socket early. 54 // Test with the following, once the race condition is solved 55 // Expect(result.ExitCode()).To(Equal(define.ExecErrorCodeNotFound)) 56 }) 57 58 It("podman run exit 0", func() { 59 result := podmanTest.Podman([]string{"run", ALPINE, "ls"}) 60 result.WaitWithDefaultTimeout() 61 Expect(result.ExitCode()).To(Equal(0)) 62 }) 63 64 It("podman run exit 50", func() { 65 result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"}) 66 result.WaitWithDefaultTimeout() 67 Expect(result.ExitCode()).To(Equal(50)) 68 }) 69 })