github.com/containers/podman/v5@v5.1.0-rc1/test/e2e/run_exit_test.go (about)

     1  package integration
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/containers/podman/v5/libpod/define"
     7  	. "github.com/containers/podman/v5/test/utils"
     8  	. "github.com/onsi/ginkgo/v2"
     9  	. "github.com/onsi/gomega"
    10  	. "github.com/onsi/gomega/gexec"
    11  )
    12  
    13  var _ = Describe("Podman run exit", func() {
    14  
    15  	It("podman run exit define.ExecErrorCodeGeneric", func() {
    16  		result := podmanTest.Podman([]string{"run", "--foobar", ALPINE, "ls", "$tmp"})
    17  		result.WaitWithDefaultTimeout()
    18  		Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
    19  	})
    20  
    21  	It("podman run exit ExecErrorCodeCannotInvoke", func() {
    22  		result := podmanTest.Podman([]string{"run", ALPINE, "/etc"})
    23  		result.WaitWithDefaultTimeout()
    24  		Expect(result).Should(Exit(define.ExecErrorCodeCannotInvoke))
    25  	})
    26  
    27  	It("podman run exit ExecErrorCodeNotFound", func() {
    28  		result := podmanTest.Podman([]string{"run", ALPINE, "foobar"})
    29  		result.WaitWithDefaultTimeout()
    30  		Expect(result).Should(Exit(define.ExecErrorCodeNotFound))
    31  	})
    32  
    33  	It("podman run exit 0", func() {
    34  		result := podmanTest.Podman([]string{"run", ALPINE, "ls"})
    35  		result.WaitWithDefaultTimeout()
    36  		Expect(result).Should(ExitCleanly())
    37  	})
    38  
    39  	It("podman run exit 50", func() {
    40  		result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", "exit 50"})
    41  		result.WaitWithDefaultTimeout()
    42  		Expect(result).Should(Exit(50))
    43  	})
    44  
    45  	It("podman run exit 125", func() {
    46  		result := podmanTest.Podman([]string{"run", ALPINE, "sh", "-c", fmt.Sprintf("exit %d", define.ExecErrorCodeGeneric)})
    47  		result.WaitWithDefaultTimeout()
    48  		Expect(result).Should(Exit(define.ExecErrorCodeGeneric))
    49  	})
    50  })