From d3cfa7a23c2343581185b8ddf9bab6f2ccf9eccc Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 9 Apr 2020 09:56:26 +0200 Subject: test: fix exec preserve-fds test it specifies a fd is passed down but we are not really doing it, and it triggers the wrong fd to be closed by Podman after the OCI runtime invocation. Closes: https://github.com/containers/libpod/issues/5769 Signed-off-by: Giuseppe Scrivano --- test/e2e/exec_test.go | 8 +++++++- test/e2e/libpod_suite_remoteclient_test.go | 6 ++++++ test/e2e/libpod_suite_test.go | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) (limited to 'test/e2e') diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 5d0d6e689..6a71a2114 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -252,7 +252,13 @@ var _ = Describe("Podman exec", func() { setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) - session := podmanTest.Podman([]string{"exec", "--preserve-fds", "1", "test1", "ls"}) + devNull, err := os.Open("/dev/null") + Expect(err).To(BeNil()) + defer devNull.Close() + files := []*os.File{ + devNull, + } + session := podmanTest.PodmanExtraFiles([]string{"exec", "--preserve-fds", "1", "test1", "ls"}, files) session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) diff --git a/test/e2e/libpod_suite_remoteclient_test.go b/test/e2e/libpod_suite_remoteclient_test.go index c87ff016a..b5da041ab 100644 --- a/test/e2e/libpod_suite_remoteclient_test.go +++ b/test/e2e/libpod_suite_remoteclient_test.go @@ -34,6 +34,12 @@ func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration return &PodmanSessionIntegration{podmanSession} } +// PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files +func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration { + podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, nil, extraFiles) + return &PodmanSessionIntegration{podmanSession} +} + // PodmanNoCache calls podman with out adding the imagecache func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { podmanSession := p.PodmanBase(args, false, true) diff --git a/test/e2e/libpod_suite_test.go b/test/e2e/libpod_suite_test.go index dc5e91c72..29a55980c 100644 --- a/test/e2e/libpod_suite_test.go +++ b/test/e2e/libpod_suite_test.go @@ -27,6 +27,12 @@ func (p *PodmanTestIntegration) Podman(args []string) *PodmanSessionIntegration return &PodmanSessionIntegration{podmanSession} } +// PodmanExtraFiles is the exec call to podman on the filesystem and passes down extra files +func (p *PodmanTestIntegration) PodmanExtraFiles(args []string, extraFiles []*os.File) *PodmanSessionIntegration { + podmanSession := p.PodmanAsUserBase(args, 0, 0, "", nil, false, false, extraFiles) + return &PodmanSessionIntegration{podmanSession} +} + // PodmanNoCache calls the podman command with no configured imagecache func (p *PodmanTestIntegration) PodmanNoCache(args []string) *PodmanSessionIntegration { podmanSession := p.PodmanBase(args, false, true) @@ -42,7 +48,7 @@ func (p *PodmanTestIntegration) PodmanNoEvents(args []string) *PodmanSessionInte // PodmanAsUser is the exec call to podman on the filesystem with the specified uid/gid and environment func (p *PodmanTestIntegration) PodmanAsUser(args []string, uid, gid uint32, cwd string, env []string) *PodmanSessionIntegration { - podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false, false) + podmanSession := p.PodmanAsUserBase(args, uid, gid, cwd, env, false, false, nil) return &PodmanSessionIntegration{podmanSession} } -- cgit v1.2.3-54-g00ecf From 4503650f418aa0da0c6e63949c60a9af035f8681 Mon Sep 17 00:00:00 2001 From: Giuseppe Scrivano Date: Thu, 9 Apr 2020 09:57:34 +0200 Subject: test: enable preserve fds test for crun Signed-off-by: Giuseppe Scrivano --- test/e2e/exec_test.go | 4 ---- 1 file changed, 4 deletions(-) (limited to 'test/e2e') diff --git a/test/e2e/exec_test.go b/test/e2e/exec_test.go index 6a71a2114..8b95794d2 100644 --- a/test/e2e/exec_test.go +++ b/test/e2e/exec_test.go @@ -244,10 +244,6 @@ var _ = Describe("Podman exec", func() { }) It("podman exec preserve fds sanity check", func() { - // TODO: add this test once crun adds the --preserve-fds flag for exec - if strings.Contains(podmanTest.OCIRuntime, "crun") { - Skip("Test only works on crun") - } setup := podmanTest.RunTopContainer("test1") setup.WaitWithDefaultTimeout() Expect(setup.ExitCode()).To(Equal(0)) -- cgit v1.2.3-54-g00ecf