diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-04-26 09:31:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-26 09:31:06 -0400 |
commit | fef3ea80aa597fb8fb0cb133b4d7410d1e2a65d6 (patch) | |
tree | c11b5aff7eb871af2ed6375bd4adc600bf43ea88 /test | |
parent | 333817a187f7811919b9f5fb75a829fe5abfbc44 (diff) | |
parent | db7cff8c86a35a4b1971c3fbb2365eff9cc205d4 (diff) | |
download | podman-fef3ea80aa597fb8fb0cb133b4d7410d1e2a65d6.tar.gz podman-fef3ea80aa597fb8fb0cb133b4d7410d1e2a65d6.tar.bz2 podman-fef3ea80aa597fb8fb0cb133b4d7410d1e2a65d6.zip |
Merge pull request #10081 from sjug/cdi_device_lib
Add support for CDI device configuration
Diffstat (limited to 'test')
-rw-r--r-- | test/e2e/cdi/device.json | 14 | ||||
-rw-r--r-- | test/e2e/run_device_test.go | 19 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/e2e/cdi/device.json b/test/e2e/cdi/device.json new file mode 100644 index 000000000..f49470c88 --- /dev/null +++ b/test/e2e/cdi/device.json @@ -0,0 +1,14 @@ +{ + "cdiVersion": "0.2.0", + "kind": "vendor.com/device", + "devices": [ + { + "name": "myKmsg", + "containerEdits": { + "mounts": [ + {"hostPath": "/dev/kmsg", "containerPath": "/dev/kmsg1", "options": ["rw", "rprivate", "rbind"]} + ] + } + } + ] +} diff --git a/test/e2e/run_device_test.go b/test/e2e/run_device_test.go index 5a32ed827..3137e3fe4 100644 --- a/test/e2e/run_device_test.go +++ b/test/e2e/run_device_test.go @@ -2,6 +2,7 @@ package integration import ( "os" + "os/exec" . "github.com/containers/podman/v3/test/utils" . "github.com/onsi/ginkgo" @@ -94,4 +95,22 @@ var _ = Describe("Podman run device", func() { session.WaitWithDefaultTimeout() Expect(session.ExitCode()).To(Equal(0)) }) + + It("podman run CDI device test", func() { + SkipIfRootless("Rootless will not be able to create files/folders in /etc") + cdiDir := "/etc/cdi" + if _, err := os.Stat(cdiDir); os.IsNotExist(err) { + Expect(os.MkdirAll(cdiDir, os.ModePerm)).To(BeNil()) + } + defer os.RemoveAll(cdiDir) + + cmd := exec.Command("cp", "cdi/device.json", cdiDir) + err = cmd.Run() + Expect(err).To(BeNil()) + + session := podmanTest.Podman([]string{"run", "-q", "--security-opt", "label=disable", "--device", "myKmsg", ALPINE, "ls", "--color=never", "/dev/kmsg1"}) + session.WaitWithDefaultTimeout() + Expect(session.ExitCode()).To(Equal(0)) + Expect(session.OutputToString()).To(Equal("/dev/kmsg1")) + }) }) |