(t *testing.T)
| 206 | } |
| 207 | |
| 208 | func TestGPUModeLabeler(t *testing.T) { |
| 209 | testCases := []struct { |
| 210 | description string |
| 211 | devices []resource.Device |
| 212 | expectedError bool |
| 213 | expectedLabels map[string]string |
| 214 | }{ |
| 215 | { |
| 216 | description: "single device with compute PCI class", |
| 217 | devices: []resource.Device{ |
| 218 | rt.NewDeviceWithPCIClassMock(0x030000), |
| 219 | }, |
| 220 | expectedLabels: map[string]string{ |
| 221 | "nvidia.com/gpu.mode": "graphics", |
| 222 | }, |
| 223 | }, |
| 224 | { |
| 225 | description: "single device with graphics PCI class", |
| 226 | devices: []resource.Device{ |
| 227 | rt.NewDeviceWithPCIClassMock(0x030200), |
| 228 | }, |
| 229 | expectedLabels: map[string]string{ |
| 230 | "nvidia.com/gpu.mode": "compute", |
| 231 | }, |
| 232 | }, |
| 233 | { |
| 234 | description: "single device with switch PCI class", |
| 235 | devices: []resource.Device{ |
| 236 | rt.NewDeviceWithPCIClassMock(0x068000), |
| 237 | }, |
| 238 | expectedLabels: map[string]string{ |
| 239 | "nvidia.com/gpu.mode": "unknown", |
| 240 | }, |
| 241 | }, |
| 242 | { |
| 243 | description: "multiple device have same graphics PCI class", |
| 244 | devices: []resource.Device{ |
| 245 | rt.NewDeviceWithPCIClassMock(0x030200), |
| 246 | rt.NewDeviceWithPCIClassMock(0x030200), |
| 247 | rt.NewDeviceWithPCIClassMock(0x030200), |
| 248 | }, |
| 249 | expectedLabels: map[string]string{ |
| 250 | "nvidia.com/gpu.mode": "compute", |
| 251 | }, |
| 252 | }, |
| 253 | { |
| 254 | description: "multiple device have same compute PCI class", |
| 255 | devices: []resource.Device{ |
| 256 | rt.NewDeviceWithPCIClassMock(0x030000), |
| 257 | rt.NewDeviceWithPCIClassMock(0x030000), |
| 258 | rt.NewDeviceWithPCIClassMock(0x030000), |
| 259 | }, |
| 260 | expectedLabels: map[string]string{ |
| 261 | "nvidia.com/gpu.mode": "graphics", |
| 262 | }, |
| 263 | }, |
| 264 | { |
| 265 | description: "multiple device with some with graphics and others with compute PCI class", |
nothing calls this directly
no test coverage detected