tests: virtual HID device test harness (Linux/Windows/macOS/libusb) #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Windows Virtual HID Device Test (manual) | |
| # Builds, self-signs and installs a modified vhidmini2 UMDF2 driver on a hosted | |
| # windows-latest runner, then runs the backend-agnostic device-I/O test against | |
| # that real virtual HID device (winapi backend). It installs a kernel driver, so | |
| # it is not part of the per-push CI matrix; run it on demand. (The push trigger | |
| # below is used while developing this branch; GitHub only exposes the "Run | |
| # workflow" button once this file is on the default branch.) | |
| on: | |
| workflow_dispatch: | |
| # Also runs automatically on a pull request that carries the | |
| # 'ci-virtual-device' label (the job below is gated on that label). | |
| pull_request: | |
| types: [opened, reopened, labeled, synchronize] | |
| jobs: | |
| win-vhid: | |
| # workflow_dispatch always runs; on a PR, only when the label is present. | |
| if: github.event_name == 'workflow_dispatch' || contains(github.event.pull_request.labels.*.name, 'ci-virtual-device') | |
| runs-on: windows-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install WDK 26100.6584 (matches VS2022, registers VS2022 WDK VSIX) | |
| shell: pwsh | |
| run: | | |
| $url = "https://go.microsoft.com/fwlink/?linkid=2335869" | |
| Write-Host "Downloading WDK setup..." | |
| Invoke-WebRequest -Uri $url -OutFile "$env:RUNNER_TEMP\wdksetup.exe" | |
| Write-Host "Running WDK setup (silent)..." | |
| $p = Start-Process -FilePath "$env:RUNNER_TEMP\wdksetup.exe" -ArgumentList '/quiet','/norestart','/ceip','off' -Wait -PassThru | |
| Write-Host "WDK setup exit code: $($p.ExitCode)" | |
| - name: Build vhidmini2 (UMDF2) | |
| shell: cmd | |
| working-directory: src/tests/windows/driver | |
| run: | | |
| call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvars64.bat" | |
| msbuild VhidminiUm.vcxproj /p:Configuration=Release /p:Platform=x64 /p:WindowsTargetPlatformVersion=10.0.26100.0 /v:minimal | |
| - name: Trust the driver's test certificate | |
| shell: pwsh | |
| run: | | |
| $cer = "src/tests/windows/driver/x64/Release/VhidminiUm.cer" | |
| Import-Certificate -FilePath $cer -CertStoreLocation Cert:\LocalMachine\Root | Out-Null | |
| Import-Certificate -FilePath $cer -CertStoreLocation Cert:\LocalMachine\TrustedPublisher | Out-Null | |
| Write-Host "Imported test cert into Root and TrustedPublisher." | |
| - name: Install virtual HID device (devcon, root-enumerated) | |
| shell: pwsh | |
| run: | | |
| $devcon = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10" -Recurse -Filter devcon.exe -ErrorAction SilentlyContinue | | |
| Where-Object { $_.FullName -match '\\x64\\' } | Select-Object -First 1 -ExpandProperty FullName | |
| Write-Host "devcon: $devcon" | |
| $inf = (Resolve-Path "src/tests/windows/driver/x64/Release/VhidminiUm/VhidminiUm.inf").Path | |
| Write-Host "inf: $inf" | |
| & $devcon install $inf "root\VhidminiUm" | |
| Write-Host "devcon exit: $LASTEXITCODE" | |
| - name: HID devices present (diagnostic) | |
| shell: pwsh | |
| run: | | |
| Start-Sleep -Seconds 3 | |
| Get-PnpDevice -Class HIDClass -ErrorAction SilentlyContinue | | |
| Select-Object Status, FriendlyName, InstanceId | Format-Table -AutoSize | |
| - name: Build HIDAPI + tests | |
| shell: pwsh | |
| run: | | |
| cmake -B build -S . -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DHIDAPI_WITH_TESTS=ON | |
| cmake --build build --config Release | |
| - name: Run device-I/O test against the virtual device | |
| shell: pwsh | |
| working-directory: build | |
| run: | | |
| ctest -C Release -R DeviceIO_winapi --output-on-failure | |
| - name: Cleanup virtual device | |
| if: always() | |
| shell: pwsh | |
| run: | | |
| $devcon = Get-ChildItem "C:\Program Files (x86)\Windows Kits\10" -Recurse -Filter devcon.exe -ErrorAction SilentlyContinue | | |
| Where-Object { $_.FullName -match '\\x64\\' } | Select-Object -First 1 -ExpandProperty FullName | |
| if ($devcon) { & $devcon remove "root\VhidminiUm" 2>$null } | |
| Write-Host "cleanup done" |