Repository navigation
GeneralUpdate.Drivelution: production readiness overhaul #564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+7,178
−1,602
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4ed32ea
Overhaul GeneralUpdate.Drivelution for production readiness
JusterZhu aa5c96a
Merge remote-tracking branch 'origin/master' into pr-564-work
JusterZhu 4fc2990
CI: provision .NET SDK 11 alongside SDK 10
JusterZhu 5a523fe
Merge remote-tracking branch 'origin/master' into pr-564-work
JusterZhu 7fee155
Merge remote-tracking branch 'origin/master' into pr-564-work
JusterZhu 10e20d5
CommandRunner: decide preemption by the token states; make its tests …
JusterZhu 4d1e2ee
Address the Drivelution review: backups, rollback, retention, signer …
JusterZhu a126601
Drivelution: honor DriverBackupException.CanRetry; keep the ILogger i…
JusterZhu ac316f1
Acceptance gate: skipped destructive tests say so; the script no long…
JusterZhu f60a926
Test: make the backup spelling regression independent of the drive la…
JusterZhu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| #Requires -Version 5.1 | ||
| <# | ||
| .SYNOPSIS | ||
| GeneralUpdate.Drivelution Windows acceptance gate. | ||
| Runs REAL driver-store install/rollback tests on a DISPOSABLE Windows machine (VM/snapshot). | ||
|
|
||
| .DESCRIPTION | ||
| Preconditions: | ||
| 1. Run from an ELEVATED PowerShell (admin). | ||
| 2. Run on a disposable VM / restore-point snapshot — the tests install and delete driver | ||
| packages in the real driver store. | ||
| 3. Provide a TEST driver package: a directory whose INF (+ catalog) is test-signed or | ||
| otherwise approved for this machine. Unsigned packages will be rejected by pnputil | ||
| with 0x800B0100. For a self-made package enable test signing first: | ||
| bcdedit /set testsigning on (then reboot) | ||
| and sign the package with your own catalog (Inf2Cat + Signtool from the WDK). | ||
| 4. dotnet SDK available on PATH (tests are built and run with `dotnet test`). | ||
|
|
||
| What it runs: | ||
| - Acceptance_Install_ThenRollback_RoundTrip : fresh install -> installed inventory contains | ||
| the package -> rollback deletes exactly the package recorded in install_state.json. | ||
| - Acceptance_InstalledBackupHook_ExportsStorePackage : second install must back up the | ||
| previously installed package via `pnputil /export-driver` (manifest Source=installed). | ||
|
|
||
| All other Drivelution tests (unit + non-destructive smoke) run as well. | ||
|
|
||
| Exit codes: | ||
| 0 the gate was exercised and passed | ||
| 1 a test failed, or the gate could not be exercised although -InfPath was given | ||
| 2 only the non-destructive tests ran (-InfPath omitted): they passed, but the gate was | ||
| NOT evaluated and is not cleared | ||
|
|
||
| .PARAMETER InfPath | ||
| Path to the test package INF (inside its package directory). Optional; when omitted only | ||
| the non-destructive tests run, the destructive ones are reported as skipped, and the script | ||
| exits with code 2. | ||
|
|
||
| .EXAMPLE | ||
| .\run-windows-acceptance.ps1 -InfPath C:\testpkg\sample.inf | ||
| #> | ||
| [CmdletBinding()] | ||
| param( | ||
| [string]$InfPath = "", | ||
| [string]$RepoRoot = "" | ||
| ) | ||
|
|
||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| # ── Preconditions ───────────────────────────────────────────────────── | ||
| $identity = [Security.Principal.WindowsIdentity]::GetCurrent() | ||
| $principal = New-Object Security.Principal.WindowsPrincipal($identity) | ||
| if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { | ||
| Write-Error "Must run elevated (administrator). Aborting." | ||
| exit 1 | ||
| } | ||
|
|
||
| if ([string]::IsNullOrEmpty($RepoRoot)) { | ||
| $RepoRoot = Split-Path -Parent (Split-Path -Parent $PSScriptRoot) # scripts/acceptance -> repo root | ||
| } | ||
| $testProject = Join-Path $RepoRoot "tests/DrivelutionTest/DrivelutionTest.csproj" | ||
| if (-not (Test-Path $testProject)) { | ||
| Write-Error "Test project not found: $testProject" | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Host "== Drivelution Windows acceptance gate ==" -ForegroundColor Cyan | ||
| Write-Host "Machine : $env:COMPUTERNAME ($([Environment]::OSVersion.VersionString))" | ||
| Write-Host "Elevated : yes" | ||
| Write-Host "Test signing: $((bcdedit /enum '{current}' | Select-String 'testsigning') -join ' ')" | ||
| Write-Host "" | ||
|
|
||
| # The destructive tests need a package; whether one was given decides what this run can certify. | ||
| $destructive = -not [string]::IsNullOrEmpty($InfPath) | ||
| if ($destructive) { | ||
| if (-not (Test-Path $InfPath)) { Write-Error "INF not found: $InfPath"; exit 1 } | ||
| $InfPath = (Resolve-Path $InfPath).Path | ||
| if (-not (Test-Path (Join-Path (Split-Path -Parent $InfPath) '*.cat'))) { | ||
| Write-Warning "No .cat file next to the INF — pnputil may reject an unsigned package (0x800B0100)." | ||
| } | ||
| $env:DRIVELUTION_ACCEPTANCE_INF = $InfPath | ||
| Write-Host "Test INF : $InfPath" | ||
| } | ||
| else { | ||
| # An INF inherited from the environment would arm the destructive tests, although this | ||
| # branch announces that they skip. | ||
| Remove-Item Env:DRIVELUTION_ACCEPTANCE_INF -ErrorAction SilentlyContinue | ||
| Write-Host "Test INF : (none) — destructive acceptance tests are reported as skipped" | ||
| } | ||
|
|
||
| $env:DRIVELUTION_ACCEPTANCE = "1" | ||
|
|
||
| # ── Build & run ─────────────────────────────────────────────────────── | ||
| Push-Location $RepoRoot | ||
| $testOutput = @() | ||
| $exit = 1 | ||
| try { | ||
| Write-Host "`n== Building test project ==" -ForegroundColor Cyan | ||
| dotnet build $testProject -f net10.0 -c Release --nologo | ||
| if ($LASTEXITCODE -ne 0) { Write-Error "Build failed"; exit 1 } | ||
|
|
||
| Write-Host "`n== Running acceptance + smoke + unit tests ==" -ForegroundColor Cyan | ||
| $testOutput = @(dotnet test $testProject -f net10.0 -c Release --no-build --nologo ` | ||
| --filter "FullyQualifiedName~DrivelutionTest") | ||
| $exit = $LASTEXITCODE | ||
| $testOutput | ForEach-Object { Write-Host $_ } | ||
| } | ||
| finally { | ||
| Remove-Item Env:DRIVELUTION_ACCEPTANCE -ErrorAction SilentlyContinue | ||
| Remove-Item Env:DRIVELUTION_ACCEPTANCE_INF -ErrorAction SilentlyContinue | ||
| Pop-Location | ||
| } | ||
|
|
||
| if ($exit -ne 0) { | ||
| Write-Host "`nRESULT: FAILED — do not release." -ForegroundColor Red | ||
| exit $exit | ||
| } | ||
|
|
||
| # The destructive tests report themselves as skipped when they could not run. A skipped gate | ||
| # test is a green run, but not a passed gate. | ||
| $skippedGate = @($testOutput | Select-String -Pattern 'Skipped\s+DrivelutionTest\.Acceptance\.') | ||
| if ($destructive) { | ||
| if ($skippedGate.Count -gt 0) { | ||
| Write-Host "`nRESULT: NOT CLEARED — the install/rollback acceptance tests were skipped although a test INF was given:" -ForegroundColor Red | ||
| $skippedGate | ForEach-Object { Write-Host " $($_.Line.Trim())" -ForegroundColor Red } | ||
| Write-Host "Do not release: the acceptance gate was not exercised." -ForegroundColor Red | ||
| exit 1 | ||
| } | ||
|
|
||
| Write-Host "`nRESULT: PASSED — Windows install/rollback gate cleared." -ForegroundColor Green | ||
| exit 0 | ||
| } | ||
|
|
||
| Write-Host "`nRESULT: PASSED (non-destructive) — the unit and smoke tests passed, but the install/rollback acceptance gate was NOT evaluated: no -InfPath was given." -ForegroundColor Yellow | ||
| Write-Host "Run again with -InfPath on a disposable machine to clear the gate. Exit code 2 means: not cleared." -ForegroundColor Yellow | ||
| exit 2 |
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
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
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.