github.com/AbhinandanKurakure/podman/v3@v3.4.10/test/e2e/run_exit_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  
     7  	"github.com/containers/podman/v3/libpod/define"
     8  	. "github.com/containers/podman/v3/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  		podmanTest.SeedImages()
    29  	})
    30  
    31  	AfterEach(func() {
    32  		podmanTest.Cleanup()
    33  		f := CurrentGinkgoTestDescription()
    34  		processTestResult(f)
    35  
    36  	})
    37  
    38  	It("podman run exit define.ExecErrorCodeGeneric", func() {
    39  		result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"})
    40  		result.WaitWithDefaultTimeout()
    41  		Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
    42  	})
    43  
    44  	It("podman run exit ExecErrorCodeCannotInvoke", func() {
    45  		result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
    46  		result.WaitWithDefaultTimeout()
    47  		Expect(result).Should(Exit(define.ExecErrorCodeCannotInvoke))
    48  	})
    49  
    50  	It("podman run exit ExecErrorCodeNotFound", func() {
    51  		result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
    52  		result.WaitWithDefaultTimeout()
    53  		Expect(result).Should(Exit(define.ExecErrorCodeNotFound))
    54  	})
    55  
    56  	It("podman run exit 0", func() {
    57  		result := podmanTest.Podman([]string{"run", ALPINE, "ls"})
    58  		result.WaitWithDefaultTimeout()
    59  		Expect(result).Should(Exit(0))
    60  	})
    61  
    62  	It("podman run exit 50", func() {
    63  		result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"})
    64  		result.WaitWithDefaultTimeout()
    65  		Expect(result).Should(Exit(50))
    66  	})
    67  
    68  	It("podman run exit 125", func() {
    69  		result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", fmt.Sprintf("exit %d", define.ExecErrorCodeGeneric)})
    70  		result.WaitWithDefaultTimeout()
    71  		Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
    72  	})
    73  })