| 487 | } |
| 488 | |
| 489 | func TestParseDevice(t *testing.T) { |
| 490 | skip.If(t, runtime.GOOS != "linux") // Windows and macOS validate server-side |
| 491 | testCases := []struct { |
| 492 | devices []string |
| 493 | deviceMapping *container.DeviceMapping |
| 494 | deviceRequests []container.DeviceRequest |
| 495 | }{ |
| 496 | { |
| 497 | devices: []string{"/dev/snd"}, |
| 498 | deviceMapping: &container.DeviceMapping{ |
| 499 | PathOnHost: "/dev/snd", |
| 500 | PathInContainer: "/dev/snd", |
| 501 | CgroupPermissions: "rwm", |
| 502 | }, |
| 503 | }, |
| 504 | { |
| 505 | devices: []string{"/dev/snd:rw"}, |
| 506 | deviceMapping: &container.DeviceMapping{ |
| 507 | PathOnHost: "/dev/snd", |
| 508 | PathInContainer: "/dev/snd", |
| 509 | CgroupPermissions: "rw", |
| 510 | }, |
| 511 | }, |
| 512 | { |
| 513 | devices: []string{"/dev/snd:/something"}, |
| 514 | deviceMapping: &container.DeviceMapping{ |
| 515 | PathOnHost: "/dev/snd", |
| 516 | PathInContainer: "/something", |
| 517 | CgroupPermissions: "rwm", |
| 518 | }, |
| 519 | }, |
| 520 | { |
| 521 | devices: []string{"/dev/snd:/something:rw"}, |
| 522 | deviceMapping: &container.DeviceMapping{ |
| 523 | PathOnHost: "/dev/snd", |
| 524 | PathInContainer: "/something", |
| 525 | CgroupPermissions: "rw", |
| 526 | }, |
| 527 | }, |
| 528 | { |
| 529 | devices: []string{"vendor.com/class=name"}, |
| 530 | deviceMapping: nil, |
| 531 | deviceRequests: []container.DeviceRequest{ |
| 532 | { |
| 533 | Driver: "cdi", |
| 534 | DeviceIDs: []string{"vendor.com/class=name"}, |
| 535 | }, |
| 536 | }, |
| 537 | }, |
| 538 | { |
| 539 | devices: []string{"vendor.com/class=name", "/dev/snd:/something:rw"}, |
| 540 | deviceMapping: &container.DeviceMapping{ |
| 541 | PathOnHost: "/dev/snd", |
| 542 | PathInContainer: "/something", |
| 543 | CgroupPermissions: "rw", |
| 544 | }, |
| 545 | deviceRequests: []container.DeviceRequest{ |
| 546 | { |