Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions internal/lookup/root/cuda_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ func TestLocate(t *testing.T) {
logger, _ := testlog.NewNullLogger()

testCases := []struct {
description string
libPaths []string
expected []string
expectedError error
description string
libPaths []string
driverRootSuffix string
expected []string
expectedError error
}{
{
description: "no libcuda does not resolve library",
Expand Down Expand Up @@ -68,6 +69,13 @@ func TestLocate(t *testing.T) {
},
expectedError: nil,
},
{
description: "driver root with a trailing slash returns absolute directories",
libPaths: []string{"/usr/lib64/libcuda.so.123.34"},
driverRootSuffix: "/",
expected: []string{"/usr/lib64"},
expectedError: nil,
},
}

for _, tc := range testCases {
Expand All @@ -77,7 +85,7 @@ func TestLocate(t *testing.T) {

l := New(
WithLogger(logger),
WithDriverRoot(driverRoot),
WithDriverRoot(driverRoot+tc.driverRootSuffix),
)

driverLibraryPaths, err := l.GetDriverLibDirectories()
Expand Down
5 changes: 5 additions & 0 deletions internal/lookup/root/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ func New(opts ...Option) *Driver {
if o.logger == nil {
o.logger = logger.New()
}
// A root such as /run/nvidia/driver/ would otherwise leave relative paths
// when the root is trimmed from located paths.
if o.Root != "" {
o.Root = filepath.Clean(o.Root)
}
if o.DevRoot == "" {
o.DevRoot = o.Root
}
Expand Down