(t *testing.T)
| 32 | ) |
| 33 | |
| 34 | func TestWindowsDevice(t *testing.T) { |
| 35 | testPodLogDir := t.TempDir() |
| 36 | |
| 37 | t.Log("Create a sandbox with log directory") |
| 38 | sb, sbConfig := PodSandboxConfigWithCleanup(t, "sandbox", "windows-device", |
| 39 | WithPodLogDirectory(testPodLogDir), |
| 40 | ) |
| 41 | |
| 42 | var ( |
| 43 | // TODO: An image with the device-dumper |
| 44 | testImage = images.Get(images.BusyBox) |
| 45 | containerName = "test-container" |
| 46 | ) |
| 47 | |
| 48 | const ( |
| 49 | // Mount this device class to expose host-GPU-accelerated DirectX inside the container |
| 50 | // https://techcommunity.microsoft.com/t5/containers/bringing-gpu-acceleration-to-windows-containers/ba-p/393939 |
| 51 | GUID_DEVINTERFACE_DISPLAY_ADAPTER = "5B45201D-F2F2-4F3B-85BB-30FF1F953599" //nolint:revive |
| 52 | ) |
| 53 | |
| 54 | EnsureImageExists(t, testImage) |
| 55 | |
| 56 | t.Log("Create a container to run the device test") |
| 57 | cnConfig := ContainerConfig( |
| 58 | containerName, |
| 59 | testImage, |
| 60 | // Per C:\windows\System32\containers\devices.def, enabling GUID_DEVINTERFACE_DISPLAY_ADAPTER |
| 61 | // will mount the host driver store into the container at this location. |
| 62 | WithCommand("sh", "-c", "ls -d /Windows/System32/HostDriverStore/* | grep /Windows/System32/HostDriverStore/FileRepository"), |
| 63 | WithLogPath(containerName), |
| 64 | WithDevice("", "class/"+GUID_DEVINTERFACE_DISPLAY_ADAPTER, ""), |
| 65 | ) |
| 66 | cn, err := runtimeService.CreateContainer(sb, cnConfig, sbConfig) |
| 67 | require.NoError(t, err) |
| 68 | |
| 69 | t.Log("Start the container") |
| 70 | require.NoError(t, runtimeService.StartContainer(cn)) |
| 71 | |
| 72 | t.Log("Wait for container to finish running") |
| 73 | require.NoError(t, Eventually(func() (bool, error) { |
| 74 | s, err := runtimeService.ContainerStatus(cn) |
| 75 | if err != nil { |
| 76 | return false, err |
| 77 | } |
| 78 | if s.GetState() == runtime.ContainerState_CONTAINER_EXITED { |
| 79 | return true, nil |
| 80 | } |
| 81 | return false, nil |
| 82 | }, time.Second, 30*time.Second)) |
| 83 | |
| 84 | t.Log("Check container log") |
| 85 | content, err := os.ReadFile(filepath.Join(testPodLogDir, containerName)) |
| 86 | assert.NoError(t, err) |
| 87 | checkContainerLog(t, string(content), []string{ |
| 88 | fmt.Sprintf("%s %s %s", runtime.Stdout, runtime.LogTagFull, "/Windows/System32/HostDriverStore/FileRepository"), |
| 89 | }) |
| 90 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…