summaryrefslogtreecommitdiff
path: root/test/e2e
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-15 13:20:35 -0400
committerGitHub <noreply@github.com>2020-06-15 13:20:35 -0400
commit5a82a559c6b58833df8fc02a589e9f349a053e16 (patch)
treedcb6288ce8fafc73ebf5e6244ddce47462a33892 /test/e2e
parent6e0cf678745a1dff267b800fd3490e6889b473ec (diff)
parent9d293bd2de60f101b3712d2e099584221516776d (diff)
downloadpodman-5a82a559c6b58833df8fc02a589e9f349a053e16.tar.gz
podman-5a82a559c6b58833df8fc02a589e9f349a053e16.tar.bz2
podman-5a82a559c6b58833df8fc02a589e9f349a053e16.zip
Merge pull request #6601 from zhangguanzhang/podman-cp-dir
fix podman cp can create an extra directory when the source is the container's root directory
Diffstat (limited to 'test/e2e')
-rw-r--r--test/e2e/build/Dockerfile.test-cp-root-dir2
-rw-r--r--test/e2e/cp_test.go38
2 files changed, 40 insertions, 0 deletions
diff --git a/test/e2e/build/Dockerfile.test-cp-root-dir b/test/e2e/build/Dockerfile.test-cp-root-dir
new file mode 100644
index 000000000..9f7de7c32
--- /dev/null
+++ b/test/e2e/build/Dockerfile.test-cp-root-dir
@@ -0,0 +1,2 @@
+FROM scratch
+COPY Dockerfile.test-cp-root-dir /
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go
index 6ae54ba34..3f9b12e0a 100644
--- a/test/e2e/cp_test.go
+++ b/test/e2e/cp_test.go
@@ -296,4 +296,42 @@ var _ = Describe("Podman cp", func() {
os.Remove("testfile1")
})
+ It("podman cp the root directory from the ctr to an existing directory on the host ", func() {
+ imgName := "test-cp-root-dir:latest"
+ DockerfileName := "Dockerfile.test-cp-root-dir"
+ ctrName := "test-container-cp-root"
+
+ session := podmanTest.PodmanNoCache([]string{"build", "-f", "build/" + DockerfileName, "-t", imgName, "build/"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ testDirPath := filepath.Join(podmanTest.RunRoot, "TestDirForCp")
+
+ session = podmanTest.Podman([]string{"create", "--name", ctrName, imgName, "dummy"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ err := os.Mkdir(testDirPath, 0755)
+ Expect(err).To(BeNil())
+ defer os.RemoveAll(testDirPath)
+
+ // Copy the root directory of the container to an existing directory
+ session = podmanTest.Podman([]string{"cp", ctrName + ":/", testDirPath})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ // The file should be in the directory,
+ // not one layer too much of the directory called merged
+ checkFile := filepath.Join(testDirPath, DockerfileName)
+ _, err = os.Stat(checkFile)
+ Expect(err).To(BeNil())
+
+ session = podmanTest.Podman([]string{"container", "rm", ctrName})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+
+ session = podmanTest.PodmanNoCache([]string{"rmi", "-f", imgName})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ })
})