github.com/containers/libpod@v1.9.4-0.20220419124438-4284fd425507/test/e2e/run_cleanup_test.go (about) 1 // +build !remoteclient 2 3 package integration 4 5 import ( 6 "os" 7 8 . "github.com/containers/libpod/test/utils" 9 . "github.com/onsi/ginkgo" 10 . "github.com/onsi/gomega" 11 ) 12 13 var _ = Describe("Podman run exit", func() { 14 var ( 15 tempdir string 16 err error 17 podmanTest *PodmanTestIntegration 18 ) 19 20 BeforeEach(func() { 21 tempdir, err = CreateTempDirInTempDir() 22 if err != nil { 23 os.Exit(1) 24 } 25 podmanTest = PodmanTestCreate(tempdir) 26 podmanTest.Setup() 27 podmanTest.RestoreArtifact(ALPINE) 28 }) 29 30 AfterEach(func() { 31 podmanTest.Cleanup() 32 f := CurrentGinkgoTestDescription() 33 processTestResult(f) 34 35 }) 36 37 It("podman run -d mount cleanup test", func() { 38 SkipIfRootless() 39 40 result := podmanTest.Podman([]string{"run", "-dt", ALPINE, "top"}) 41 result.WaitWithDefaultTimeout() 42 cid := result.OutputToString() 43 Expect(result.ExitCode()).To(Equal(0)) 44 45 mount := SystemExec("mount", nil) 46 Expect(mount.ExitCode()).To(Equal(0)) 47 Expect(mount.OutputToString()).To(ContainSubstring(cid)) 48 49 pmount := podmanTest.Podman([]string{"mount", "--notruncate"}) 50 pmount.WaitWithDefaultTimeout() 51 Expect(pmount.ExitCode()).To(Equal(0)) 52 Expect(pmount.OutputToString()).To(ContainSubstring(cid)) 53 54 stop := podmanTest.Podman([]string{"stop", cid}) 55 stop.WaitWithDefaultTimeout() 56 Expect(stop.ExitCode()).To(Equal(0)) 57 58 // We have to force cleanup so the unmount happens 59 podmanCleanupSession := podmanTest.Podman([]string{"container", "cleanup", cid}) 60 podmanCleanupSession.WaitWithDefaultTimeout() 61 Expect(podmanCleanupSession.ExitCode()).To(Equal(0)) 62 63 mount = SystemExec("mount", nil) 64 Expect(mount.ExitCode()).To(Equal(0)) 65 Expect(mount.OutputToString()).NotTo(ContainSubstring(cid)) 66 67 pmount = podmanTest.Podman([]string{"mount", "--notruncate"}) 68 pmount.WaitWithDefaultTimeout() 69 Expect(pmount.ExitCode()).To(Equal(0)) 70 Expect(pmount.OutputToString()).NotTo(ContainSubstring(cid)) 71 72 }) 73 })