Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions scripts/smoke-startup-errors.tests.ps1
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 4 additions & 2 deletions scripts/smoke.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 }

@"
``````
Expand Down
Loading