mirror of
https://github.com/containers/podman.git
synced 2025-06-27 21:50:18 +08:00
test: ad more tests for rootless containers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com> Closes: #1323 Approved by: umohnani8
This commit is contained in:

committed by
Atomic Bot

parent
77bcc89d52
commit
4a95ef4a4e
@ -44,7 +44,7 @@ var _ = Describe("Podman rootless", func() {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman rootless rootfs", func() {
|
runRootless := func(args []string) {
|
||||||
// Check if we can create an user namespace
|
// Check if we can create an user namespace
|
||||||
err := exec.Command("unshare", "-r", "echo", "hello").Run()
|
err := exec.Command("unshare", "-r", "echo", "hello").Run()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -96,7 +96,9 @@ var _ = Describe("Podman rootless", func() {
|
|||||||
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", xdgRuntimeDir))
|
env = append(env, fmt.Sprintf("XDG_RUNTIME_DIR=%s", xdgRuntimeDir))
|
||||||
env = append(env, fmt.Sprintf("HOME=%s", home))
|
env = append(env, fmt.Sprintf("HOME=%s", home))
|
||||||
env = append(env, "PODMAN_ALLOW_SINGLE_ID_MAPPING_IN_USERNS=1")
|
env = append(env, "PODMAN_ALLOW_SINGLE_ID_MAPPING_IN_USERNS=1")
|
||||||
cmd := podmanTest.PodmanAsUser([]string{"run", "--rootfs", mountPath, "echo", "hello"}, 1000, 1000, env)
|
allArgs := append([]string{"run"}, args...)
|
||||||
|
allArgs = append(allArgs, "--rootfs", mountPath, "echo", "hello")
|
||||||
|
cmd := podmanTest.PodmanAsUser(allArgs, 1000, 1000, env)
|
||||||
cmd.WaitWithDefaultTimeout()
|
cmd.WaitWithDefaultTimeout()
|
||||||
Expect(cmd.LineInOutputContains("hello")).To(BeTrue())
|
Expect(cmd.LineInOutputContains("hello")).To(BeTrue())
|
||||||
Expect(cmd.ExitCode()).To(Equal(0))
|
Expect(cmd.ExitCode()).To(Equal(0))
|
||||||
@ -107,5 +109,21 @@ var _ = Describe("Podman rootless", func() {
|
|||||||
umount := podmanTest.Podman([]string{"umount", cid})
|
umount := podmanTest.Podman([]string{"umount", cid})
|
||||||
umount.WaitWithDefaultTimeout()
|
umount.WaitWithDefaultTimeout()
|
||||||
Expect(umount.ExitCode()).To(Equal(0))
|
Expect(umount.ExitCode()).To(Equal(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
It("podman rootless rootfs", func() {
|
||||||
|
runRootless([]string{})
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman rootless rootfs --net host", func() {
|
||||||
|
runRootless([]string{"--net", "host"})
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman rootless rootfs --privileged", func() {
|
||||||
|
runRootless([]string{"--privileged"})
|
||||||
|
})
|
||||||
|
|
||||||
|
It("podman rootless rootfs --net host --privileged", func() {
|
||||||
|
runRootless([]string{"--net", "host", "--privileged"})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user