summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/e2e/cp_test.go37
-rw-r--r--test/e2e/info_test.go1
-rw-r--r--test/e2e/libpod_suite_remoteclient_test.go1
-rw-r--r--test/e2e/unshare_test.go52
4 files changed, 63 insertions, 28 deletions
diff --git a/test/e2e/cp_test.go b/test/e2e/cp_test.go
index 273668f35..1dfa8f50d 100644
--- a/test/e2e/cp_test.go
+++ b/test/e2e/cp_test.go
@@ -40,15 +40,11 @@ var _ = Describe("Podman cp", func() {
It("podman cp file", func() {
path, err := os.Getwd()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
filePath := filepath.Join(path, "cp_test.txt")
fromHostToContainer := []byte("copy from host to container")
err = ioutil.WriteFile(filePath, fromHostToContainer, 0644)
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"create", ALPINE, "cat", "foo"})
session.WaitWithDefaultTimeout()
@@ -69,15 +65,12 @@ var _ = Describe("Podman cp", func() {
It("podman cp file to dir", func() {
path, err := os.Getwd()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
filePath := filepath.Join(path, "cp_test.txt")
fromHostToContainer := []byte("copy from host to container directory")
err = ioutil.WriteFile(filePath, fromHostToContainer, 0644)
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
+
session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foodir/"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
@@ -97,14 +90,10 @@ var _ = Describe("Podman cp", func() {
It("podman cp dir to dir", func() {
path, err := os.Getwd()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
testDirPath := filepath.Join(path, "TestDir")
err = os.Mkdir(testDirPath, 0777)
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"create", ALPINE, "ls", "/foodir"})
session.WaitWithDefaultTimeout()
@@ -124,19 +113,13 @@ var _ = Describe("Podman cp", func() {
It("podman cp stdin/stdout", func() {
path, err := os.Getwd()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
testDirPath := filepath.Join(path, "TestDir")
err = os.Mkdir(testDirPath, 0777)
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
cmd := exec.Command("tar", "-zcvf", "file.tar.gz", testDirPath)
_, err = cmd.Output()
- if err != nil {
- os.Exit(1)
- }
+ Expect(err).To(BeNil())
session := podmanTest.Podman([]string{"create", ALPINE, "ls", "foo"})
session.WaitWithDefaultTimeout()
diff --git a/test/e2e/info_test.go b/test/e2e/info_test.go
index ca4012dde..c960fb311 100644
--- a/test/e2e/info_test.go
+++ b/test/e2e/info_test.go
@@ -24,7 +24,6 @@ var _ = Describe("Podman Info", func() {
}
podmanTest = PodmanTestCreate(tempdir)
podmanTest.Setup()
- podmanTest.DelayForVarlink()
})
AfterEach(func() {
diff --git a/test/e2e/libpod_suite_remoteclient_test.go b/test/e2e/libpod_suite_remoteclient_test.go
index 05c355711..b7fd8537d 100644
--- a/test/e2e/libpod_suite_remoteclient_test.go
+++ b/test/e2e/libpod_suite_remoteclient_test.go
@@ -77,6 +77,7 @@ func (p *PodmanTestIntegration) StartVarlink() {
command.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
p.VarlinkCommand = command
p.VarlinkSession = command.Process
+ p.DelayForVarlink()
}
func (p *PodmanTestIntegration) StopVarlink() {
diff --git a/test/e2e/unshare_test.go b/test/e2e/unshare_test.go
new file mode 100644
index 000000000..1e3f06a62
--- /dev/null
+++ b/test/e2e/unshare_test.go
@@ -0,0 +1,52 @@
+package integration
+
+import (
+ "os"
+
+ . "github.com/containers/libpod/test/utils"
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+var _ = Describe("Podman unshare", func() {
+ var (
+ tempdir string
+ err error
+ podmanTest *PodmanTestIntegration
+ )
+ BeforeEach(func() {
+ SkipIfRemote()
+ if _, err := os.Stat("/proc/self/uid_map"); err != nil {
+ Skip("User namespaces not supported.")
+ }
+
+ if os.Geteuid() == 0 {
+ Skip("Use unshare in rootless only")
+ }
+
+ tempdir, err = CreateTempDirInTempDir()
+ if err != nil {
+ os.Exit(1)
+ }
+ podmanTest = PodmanTestCreate(tempdir)
+ podmanTest.CgroupManager = "cgroupfs"
+ podmanTest.StorageOptions = ROOTLESS_STORAGE_OPTIONS
+ podmanTest.Setup()
+ podmanTest.RestoreAllArtifacts()
+ })
+
+ AfterEach(func() {
+ podmanTest.Cleanup()
+ f := CurrentGinkgoTestDescription()
+ processTestResult(f)
+ })
+
+ It("podman unshare", func() {
+ userNS, _ := os.Readlink("/proc/self/ns/user")
+ session := podmanTest.Podman([]string{"unshare", "readlink", "/proc/self/ns/user"})
+ session.WaitWithDefaultTimeout()
+ Expect(session.ExitCode()).To(Equal(0))
+ ok, _ := session.GrepString(userNS)
+ Expect(ok).To(BeFalse())
+ })
+})