Skip to content
Merged
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
2 changes: 1 addition & 1 deletion pkg/nvcdi/lib-csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ func (l *csvlib) getEnableCUDACompatHookOptions() (*discover.EnableCUDACompatHoo

hostCUDAVersion, err := l.getCUDAVersionString()
if err != nil {
return nil, fmt.Errorf("failed to get host CUDA version: %v", ret)
return nil, fmt.Errorf("failed to get host CUDA version: %w", err)
}

f := &discover.EnableCUDACompatHookOptions{
Expand Down
27 changes: 27 additions & 0 deletions pkg/nvcdi/lib-csv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,30 @@ func mockIGXServer() nvml.Interface {
},
}
}

func TestGetEnableCUDACompatHookOptionsReportsWhyTheVersionFailed(t *testing.T) {
// The message used to interpolate the NVML return of the Init call above it,
// which is always SUCCESS by then, so the real failure was dropped.
nvmllib := &mock.Interface{
InitFunc: func() nvml.Return { return nvml.SUCCESS },
ShutdownFunc: func() nvml.Return { return nvml.SUCCESS },
SystemGetCudaDriverVersionFunc: func() (int, nvml.Return) {
return 0, nvml.ERROR_NOT_SUPPORTED
},
DeviceGetCountFunc: func() (int, nvml.Return) { return 0, nvml.SUCCESS },
}

l := &csvlib{
platformlibs: platformlibs{
infolib: &infoInterfaceMock{
HasNvmlFunc: func() (bool, string) { return true, "forced" },
},
nvmllib: nvmllib,
devicelib: device.New(nvmllib),
},
}

_, err := l.getEnableCUDACompatHookOptions()
require.ErrorContains(t, err, nvml.ERROR_NOT_SUPPORTED.Error())
require.NotContains(t, err.Error(), nvml.SUCCESS.Error())
}
Loading