diff --git a/scripts/smoke-startup-errors.tests.ps1 b/scripts/smoke-startup-errors.tests.ps1 new file mode 100644 index 0000000000..f6ebfd7822 --- /dev/null +++ b/scripts/smoke-startup-errors.tests.ps1 @@ -0,0 +1,30 @@ +# A stand-in for xcl.exe exits before printing a log path. +param([string]$Smoke = (Join-Path $PSScriptRoot 'smoke.ps1')) +$ErrorActionPreference = 'Stop' +$fixture = Join-Path ([IO.Path]::GetTempPath()) ('xcl-smoke-error-' + [guid]::NewGuid()) +$null = New-Item -ItemType Directory -Path $fixture +$xcl = Join-Path $fixture 'xcl.cmd' +$network, $seconds, $activity = $env:XCL_NETWORK, $env:XCL_RUN_SECONDS, $env:XCL_ACTIVITY +try { + @' +@echo off +echo synthetic startup output +>&2 echo xcl: synthetic startup failure +exit /b 2 +'@ | Set-Content -LiteralPath $xcl -Encoding Ascii + $diagnostic = '' + try { + $null = & $Smoke -Game $fixture -Seconds 1 -Xcl $xcl + } catch { + $diagnostic = $_.Exception.Message + } + foreach ($expected in 'XCL printed no log path', 'exit: 0x2', 'synthetic startup output', 'xcl: synthetic startup failure') { + if (!$diagnostic.Contains($expected)) { + throw "Expected '$expected' in the failure diagnostic. Got '$diagnostic'." + } + } + Write-Host 'Passed: early failure reports the exit code, stdout and stderr.' +} finally { + $env:XCL_NETWORK, $env:XCL_RUN_SECONDS, $env:XCL_ACTIVITY = $network, $seconds, $activity + Remove-Item -LiteralPath $fixture -Recurse -Force +} diff --git a/scripts/smoke.ps1 b/scripts/smoke.ps1 index f0738cdb98..1ce41f7f42 100644 --- a/scripts/smoke.ps1 +++ b/scripts/smoke.ps1 @@ -47,7 +47,10 @@ $null = $stderrTask.Result Remove-Item Env:XCL_RUN_SECONDS, Env:XCL_ACTIVITY $logLine = ($stdout -split "`n" | Where-Object { $_ -match '^Log:\s+(.+)$' } | Select-Object -Last 1) -if (-not $logLine) { throw "XCL printed no log path; its output:`n$stdout" } +$code = if ($timedOut) { 'killed (no exit)' } else { '0x{0:x}' -f $p.ExitCode } +if (-not $logLine) { + throw "XCL printed no log path (exit: $code).`nstdout:`n$stdout`nstderr:`n$($stderrTask.Result)" +} $log = ($logLine -replace '^Log:\s+', '').Trim() $text = Get-Content $log -Raw -Encoding utf8 @@ -66,7 +69,6 @@ if (Test-Path $report) { try { $gpu = ((Get-Content $report -Raw -Encoding utf8 | ConvertFrom-Json).d3d12.adapter -replace '\s*\([^()]*VRAM\)$', '') } catch { } } if (-not $gpu) { $gpu = (Get-CimInstance Win32_VideoController | Where-Object { $_.Name -notmatch 'Basic' } | Select-Object -First 1).Name } -$code = if ($timedOut) { 'killed (no exit)' } else { '0x{0:x}' -f $p.ExitCode } @" ``````