MCPcopy Create free account
hub / github.com/containerd/nerdctl / TestRunDeviceCDI

Function TestRunDeviceCDI

cmd/nerdctl/container/container_run_linux_test.go:672–694  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

670}
671
672func TestRunDeviceCDI(t *testing.T) {
673 t.Parallel()
674 // Although CDI injection is supported by Docker, specifying the --cdi-spec-dirs on the command line is not.
675 testutil.DockerIncompatible(t)
676 cdiSpecDir := filepath.Join(t.TempDir(), "cdi")
677 const testCDIVendor1 = `
678cdiVersion: "0.3.0"
679kind: "vendor1.com/device"
680devices:
681- name: foo
682 containerEdits:
683 env:
684 - FOO=injected
685`
686 writeTestCDISpec(t, testCDIVendor1, "vendor1.yaml", cdiSpecDir)
687
688 base := testutil.NewBase(t)
689 base.Cmd("--cdi-spec-dirs", cdiSpecDir, "run",
690 "--rm",
691 "--device", "vendor1.com/device=foo",
692 testutil.AlpineImage, "env",
693 ).AssertOutContains("FOO=injected")
694}
695
696func TestRunDeviceCDIWithNerdctlConfig(t *testing.T) {
697 t.Parallel()

Callers

nothing calls this directly

Calls 6

CmdMethod · 0.95
DockerIncompatibleFunction · 0.92
NewBaseFunction · 0.92
writeTestCDISpecFunction · 0.85
AssertOutContainsMethod · 0.80
TempDirMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…