Skip to content

Commit 04c7567

Browse files
committed
[no-relnote] Add basic CDI generate test
Signed-off-by: Evan Lezar <[email protected]>
1 parent e32a94a commit 04c7567

File tree

4 files changed

+859
-0
lines changed

4 files changed

+859
-0
lines changed

cmd/nvidia-ctk/cdi/generate/generate.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import (
2525
"github.com/urfave/cli/v2"
2626
cdi "tags.cncf.io/container-device-interface/pkg/parser"
2727

28+
"github.com/NVIDIA/go-nvml/pkg/nvml"
29+
2830
"github.com/NVIDIA/nvidia-container-toolkit/internal/config"
2931
"github.com/NVIDIA/nvidia-container-toolkit/internal/logger"
3032
"github.com/NVIDIA/nvidia-container-toolkit/internal/platform-support/tegra/csv"
@@ -60,6 +62,9 @@ type options struct {
6062
files cli.StringSlice
6163
ignorePatterns cli.StringSlice
6264
}
65+
66+
// the following are used for dependency injection during spec generation.
67+
nvmllib nvml.Interface
6368
}
6469

6570
// NewCommand constructs a generate-cdi command with the specified logger
@@ -269,6 +274,8 @@ func (m command) generateSpec(opts *options) (spec.Interface, error) {
269274
nvcdi.WithLibrarySearchPaths(opts.librarySearchPaths.Value()),
270275
nvcdi.WithCSVFiles(opts.csv.files.Value()),
271276
nvcdi.WithCSVIgnorePatterns(opts.csv.ignorePatterns.Value()),
277+
// We set the following to allow for dependency injection:
278+
nvcdi.WithNvmlLib(opts.nvmllib),
272279
)
273280
if err != nil {
274281
return nil, fmt.Errorf("failed to create CDI library: %v", err)

0 commit comments

Comments
 (0)