more fixes for the scrubber
This commit is contained in:
@@ -936,13 +936,16 @@ try {
|
||||
Set-Content -LiteralPath "$LogPrefix.stderr.log" -Value ''
|
||||
$script:scrubExit
|
||||
}
|
||||
function Get-CimInstance { if ($script:scrubMode -eq 'running') { [pscustomobject]@{Name='GetHelpCmd.exe'} } }
|
||||
function Get-CimInstance {
|
||||
if ($script:scrubMode -eq 'running') { [pscustomobject]@{Name='GetHelpCmd.exe'} }
|
||||
if ($script:scrubMode -eq 'background') { [pscustomobject]@{Name='powershell.exe';ProcessId=7064;CommandLine='powershell.exe -File C:\Windows\SystemTemp\GetHelpElevated\d509ee113e5346fa82eded7e01f47f69\Run.ps1'} }
|
||||
}
|
||||
function Get-OfficeSuiteInventory {
|
||||
if ($script:scrubMode -eq 'remaining') { [pscustomobject]@{DisplayName='Leftover MSI Office';WindowsInstaller=1} }
|
||||
if ($script:scrubMode -eq 'inventory-error') { throw 'Registry unreadable' }
|
||||
}
|
||||
function Assert-OfficeFreshInstallState { if ($script:scrubMode -eq 'stale') { throw 'Previous Click-to-Run state remains' } }
|
||||
foreach ($script:scrubMode in @('success','restart','download','failure','not-found-66','not-found-68','empty','invalid-arguments','usage','contradictory','bad-exit','running','remaining','inventory-error','stale')) {
|
||||
foreach ($script:scrubMode in @('success','restart','download','failure','not-found-66','not-found-68','empty','invalid-arguments','usage','background','background-no-worker','background-with-00','generic-success','contradictory','bad-exit','running','remaining','inventory-error','stale')) {
|
||||
$workspace=Join-Path $testRoot ('scrub-result-' + $script:scrubMode); $null=[IO.Directory]::CreateDirectory($workspace)
|
||||
$media=[pscustomobject]@{}; $script:scrubExit=0; $script:scrubOutput='00: Successfully completed this scenario.'
|
||||
switch ($script:scrubMode) {
|
||||
@@ -953,6 +956,8 @@ try {
|
||||
'empty' { $script:scrubOutput='' }
|
||||
'invalid-arguments' { $script:scrubOutput="Starting Microsoft GetHelp Command Line Tool`nError: Invalid command line arguments`nUsage: GetHelpCmd.exe [options]`nExamples:`nGetHelpCmd.exe -S OfficeScrubScenario -AcceptEula" }
|
||||
'usage' { $script:scrubOutput="Usage: GetHelpCmd.exe [options]`n00: Success" }
|
||||
{ $_ -like 'background*' } { $script:scrubOutput="Starting Microsoft GetHelp Command Line Tool`nDiagnostic action completed.`nScenario completed successfully.`nExecutionResultDetails: Uninstall office is running in the background."; if ($_ -eq 'background-with-00') { $script:scrubOutput += "`n00: Success" } }
|
||||
'generic-success' { $script:scrubOutput='Scenario completed successfully.' }
|
||||
'contradictory' { $script:scrubOutput="09: Failure`n00: Success" }
|
||||
'bad-exit' { $script:scrubExit=1 }
|
||||
}
|
||||
@@ -960,14 +965,14 @@ try {
|
||||
$result=@(Invoke-OfficeScrubRecovery $media $workspace 'fixture corruption')
|
||||
Assert-OfficeTest ($result.Count -eq 1 -and $result[0] -eq 3010 -and $media.ScrubAttempted -and $media.ScrubReason -eq 'fixture corruption') 'Verified scrub must surface its use and restart requirement without leaking log messages.'
|
||||
} else {
|
||||
$pattern=switch ($script:scrubMode) { 'download' {'Scrub download failed'}; 'invalid-arguments' {'rejected its command line.*process 0'}; 'usage' {'rejected its command line.*process 0'}; 'running' {'processes are still running'}; 'remaining' {'Office remains.*Leftover MSI Office'}; 'inventory-error' {'Registry unreadable'}; 'stale' {'Click-to-Run state remains'}; default {'failed or returned an unverified result'} }
|
||||
$pattern=switch ($script:scrubMode) { 'download' {'Scrub download failed'}; 'invalid-arguments' {'rejected its command line.*process 0'}; 'usage' {'rejected its command line.*process 0'}; { $_ -like 'background*' } {'background removal requires attended verification.*launcher exit 0'}; 'running' {'processes are still running'}; 'remaining' {'Office remains.*Leftover MSI Office'}; 'inventory-error' {'Registry unreadable'}; 'stale' {'Click-to-Run state remains'}; default {'failed or returned an unverified result'} }
|
||||
Assert-OfficeThrows { Invoke-OfficeScrubRecovery $media $workspace 'fixture corruption' } $pattern
|
||||
}
|
||||
$before=$script:scrubLaunches
|
||||
Assert-OfficeThrows { Invoke-OfficeScrubRecovery $media $workspace 'second attempt' } 'already attempted'
|
||||
Assert-OfficeTest ($script:scrubLaunches -eq $before) 'Failure must not create a scrub loop.'
|
||||
$warnings=Complete-OfficeDeploymentFiles $workspace
|
||||
if ($script:scrubMode -eq 'running') { Assert-OfficeTest ($warnings.Count -gt 0 -and (Test-Path -LiteralPath (Join-Path $workspace 'GetHelp.zip'))) 'Surviving scrub workers must retain in-use media.' }
|
||||
if ($script:scrubMode -in @('running','background')) { Assert-OfficeTest ($warnings.Count -gt 0 -and (Test-Path -LiteralPath (Join-Path $workspace 'GetHelp.zip'))) 'Surviving scrub workers must retain in-use media.' }
|
||||
else {
|
||||
Assert-OfficeTest (!$warnings.Count -and !(Test-Path -LiteralPath (Join-Path $workspace 'GetHelp.zip'))) 'Scrub download must be removed on success and failure.'
|
||||
if ($script:scrubMode -ne 'download') { Assert-OfficeTest (Test-Path -LiteralPath (Join-Path $workspace 'office-scrub.stdout.log')) 'Scrub result logs must survive cleanup.' }
|
||||
@@ -975,6 +980,26 @@ try {
|
||||
}
|
||||
Assert-OfficeTest (Test-OfficeStagingInUse $testRoot @([pscustomobject]@{Name='cscript.exe';CommandLine='cscript.exe C:\Temp\OffScrubC2R.vbs ALL'})) 'Detached Office scrub scripts must block a new deployment and media cleanup.'
|
||||
}
|
||||
# Get Help's detached signed launcher lives outside the deployment workspace
|
||||
# and can remain at Console.ReadKey after either success or failure.
|
||||
& {
|
||||
$worker=[pscustomobject]@{Name='powershell.exe';ProcessId=7064;CommandLine='"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File C:\Windows\SystemTemp\GetHelpElevated\d509ee113e5346fa82eded7e01f47f69\Run.ps1 C:\Windows\SystemTemp\GetHelpElevated\d509ee113e5346fa82eded7e01f47f69'}
|
||||
$root=Join-Path $testRoot 'detached-gethelp'; $workspace=Join-Path $root ('a'*32)
|
||||
$null=[IO.Directory]::CreateDirectory($workspace)
|
||||
$payload=Join-Path $workspace 'GetHelp.zip'; Set-Content -LiteralPath $payload -Value 'fixture'
|
||||
function Get-CimInstance { $worker }
|
||||
function Get-OfficeDeploymentRoots { $root }
|
||||
function Get-ScheduledTask { throw 'Worker guard must run before retiring tasks.' }
|
||||
Assert-OfficeTest (Test-OfficeStagingInUse $workspace @($worker)) 'GetHelpElevated Run.ps1 must block cleanup despite not naming our workspace.'
|
||||
Assert-OfficeTest (@(Get-OfficeBlockingProcesses $workspace @($worker)).Count -eq 1) 'A worker must be returned once for diagnostics.'
|
||||
Assert-OfficeThrows { Clear-OfficePreviousDeploymentFiles } 'surviving installer.*powershell.exe \(PID 7064\)'
|
||||
$warnings=Complete-OfficeDeploymentFiles $workspace
|
||||
Assert-OfficeTest ($warnings.Count -gt 0 -and (Test-Path -LiteralPath $payload)) 'Detached Get Help workers must preserve media on failure as well as block fresh downloads.'
|
||||
$quoted=[pscustomobject]@{Name='powershell.exe';CommandLine='powershell.exe -File "C:\Temp Folder\GETHELPELEVATED\abc\run.ps1" "C:\Temp Folder\GETHELPELEVATED\abc"'}
|
||||
Assert-OfficeTest (Test-OfficeStagingInUse $workspace @($quoted)) 'Quoted Get Help worker paths must be recognized case-insensitively.'
|
||||
$ordinary=@([pscustomobject]@{Name='powershell.exe';CommandLine='powershell.exe -File C:\Tools\Run.ps1'},[pscustomobject]@{Name='OfficeClickToRun.exe';CommandLine='OfficeClickToRun.exe /service'},[pscustomobject]@{Name='OfficeClickToRun.exe';CommandLine='OfficeClickToRun.exe /user'})
|
||||
Assert-OfficeTest (!(Test-OfficeStagingInUse $workspace $ordinary)) 'Unrelated PowerShell and idle Click-to-Run hosts must not be mistaken for scrub workers.'
|
||||
}
|
||||
# Deployment resolves release metadata and deletes it on success or failure.
|
||||
& {
|
||||
$script:historyPaths=@()
|
||||
|
||||
Reference in New Issue
Block a user