diff --git a/tests/exec.go b/tests/exec.go index 43256a5..65ebb53 100644 --- a/tests/exec.go +++ b/tests/exec.go @@ -38,7 +38,7 @@ func Exec(o *option.Option) { gomega.Expect(output).Should(gomega.Equal(strEchoed)) }) - for _, interactive := range []string{"-i", "--interactive"} { + for _, interactive := range []string{"-i", "--interactive", "-i=true", "--interactive=true"} { interactive := interactive ginkgo.It(fmt.Sprintf("should output string by piping if %s flag keeps STDIN open", interactive), func() { want := []byte("hello") @@ -48,7 +48,7 @@ func Exec(o *option.Option) { }) } - for _, detach := range []string{"-d", "--detach"} { + for _, detach := range []string{"-d", "--detach", "-d=true", "--detach=true"} { detach := detach ginkgo.It(fmt.Sprintf("should execute command in detached mode with %s flag", detach), func() { command.Run(o, "exec", detach, testContainerName, "nc", "-l") @@ -91,6 +91,13 @@ func Exec(o *option.Option) { gomega.Expect(output).Should(gomega.ContainSubstring("dummy1")) }) + ginkgo.It("should execute command in privileged mode with --privileged=true long form flag", func() { + command.RunWithoutSuccessfulExit(o, "exec", testContainerName, "ip", "link", "add", "dummy1", "type", "dummy") + command.Run(o, "exec", "--privileged=true", testContainerName, "ip", "link", "add", "dummy1", "type", "dummy") + output := command.StdoutStr(o, "exec", "--privileged=true", testContainerName, "ip", "link") + gomega.Expect(output).Should(gomega.ContainSubstring("dummy1")) + }) + for _, user := range []string{"-u", "--user"} { user := user ginkgo.It(fmt.Sprintf("should output user id according to user name specified by %s flag", user), func() { diff --git a/tests/start.go b/tests/start.go index eee930a..fad1698 100644 --- a/tests/start.go +++ b/tests/start.go @@ -5,6 +5,7 @@ package tests import ( "fmt" + "strings" "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -34,7 +35,7 @@ func Start(o *option.Option) { containerShouldBeRunning(o, testContainerName) }) - for _, attach := range []string{"--attach", "-a"} { + for _, attach := range []string{"--attach", "-a", "-a=true", "--attach=true"} { attach := attach ginkgo.It(fmt.Sprintf("with %s flag, should start the container with stdout", attach), func() { command.Run(o, "create", "--name", testContainerName, localImages[defaultImage], "echo", "foo") @@ -42,5 +43,24 @@ func Start(o *option.Option) { gomega.Expect(output).To(gomega.Equal("foo")) }) } + + ginkgo.It("should run a container without an init process when --init=false flag is used", func() { + command.Run(o, "run", "--name", testContainerName, "--init=false", localImages[defaultImage], "ps", "aux") + psOutput := command.StdoutStr(o, "logs", testContainerName) + + // Split the output into lines + lines := strings.Split(strings.TrimSpace(psOutput), "\n") + + processLine := lines[1] // Second line (after header) + fields := strings.Fields(processLine) + + pid := fields[0] + command := fields[3] + gomega.Expect(pid).To(gomega.Equal("1"), "The only process should have PID 1") + gomega.Expect(command).To(gomega.Equal("ps"), "The only process should be ps") + + // Verify there's no init process + gomega.Expect(psOutput).NotTo(gomega.ContainSubstring("tini"), "There should be no tini process") + }) }) }