mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2025-06-26 18:18:24 +00:00
Support both nvidia and nvidia-frontend when extracting major
With newer driver versions the nvidia-frontend name in /proc/devices was replaced with nvidia. This change allows both nvidia and nvidia-frontend to be used to extract the expected device major (195). Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
@@ -28,15 +28,18 @@ import (
|
||||
func TestCreateControlDevices(t *testing.T) {
|
||||
logger, _ := testlog.NewNullLogger()
|
||||
|
||||
nvidiaDevices := &devices.DevicesMock{
|
||||
GetFunc: func(name devices.Name) (devices.Major, bool) {
|
||||
devices := map[devices.Name]devices.Major{
|
||||
"nvidia-frontend": 195,
|
||||
"nvidia-uvm": 243,
|
||||
}
|
||||
return devices[name], true
|
||||
},
|
||||
}
|
||||
nvidiaDevices := devices.New(
|
||||
devices.WithDeviceToMajor(map[string]int{
|
||||
"nvidia-frontend": 195,
|
||||
"nvidia-uvm": 243,
|
||||
}),
|
||||
)
|
||||
nvidia550Devices := devices.New(
|
||||
devices.WithDeviceToMajor(map[string]int{
|
||||
"nvidia": 195,
|
||||
"nvidia-uvm": 243,
|
||||
}),
|
||||
)
|
||||
|
||||
mknodeError := errors.New("mknode error")
|
||||
|
||||
@@ -53,7 +56,7 @@ func TestCreateControlDevices(t *testing.T) {
|
||||
}
|
||||
}{
|
||||
{
|
||||
description: "no root specified",
|
||||
description: "no root specified; pre 550 driver",
|
||||
root: "",
|
||||
devices: nvidiaDevices,
|
||||
mknodeError: nil,
|
||||
@@ -68,6 +71,22 @@ func TestCreateControlDevices(t *testing.T) {
|
||||
{"/dev/nvidia-uvm-tools", 243, 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "no root specified; 550 driver",
|
||||
root: "",
|
||||
devices: nvidia550Devices,
|
||||
mknodeError: nil,
|
||||
expectedCalls: []struct {
|
||||
S string
|
||||
N1 int
|
||||
N2 int
|
||||
}{
|
||||
{"/dev/nvidiactl", 195, 255},
|
||||
{"/dev/nvidia-modeset", 195, 254},
|
||||
{"/dev/nvidia-uvm", 243, 0},
|
||||
{"/dev/nvidia-uvm-tools", 243, 1},
|
||||
},
|
||||
},
|
||||
{
|
||||
description: "some root specified",
|
||||
root: "/some/root",
|
||||
@@ -129,5 +148,4 @@ func TestCreateControlDevices(t *testing.T) {
|
||||
require.EqualValues(t, tc.expectedCalls, mknode.MknodeCalls())
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user