diff --git a/scripts/smoke.ps1 b/scripts/smoke.ps1 index db296218b2..d54692378c 100644 --- a/scripts/smoke.ps1 +++ b/scripts/smoke.ps1 @@ -72,6 +72,7 @@ $logLine = ($stdout -split "`n" | Where-Object { $_ -match '^Log:\s+(.+)$' } | S if (-not $logLine) { throw "XCL printed no log path; its output:`n$stdout" } $log = ($logLine -replace '^Log:\s+', '').Trim() $text = Get-Content $log -Raw -Encoding utf8 +if ([string]::IsNullOrWhiteSpace($text)) { throw "XCL log is empty: $log" } $frames = if ($text -match '\((\d+) frames shown, (\d+) PresentX calls\)') { "$($Matches[1]) (PresentX $($Matches[2]))" } else { 'none logged (the run did not reach its end)' } $presents = [regex]::Matches($text, 'activity \(2 s\): (\d+) presents') | ForEach-Object { [int]$_.Groups[1].Value } diff --git a/scripts/test-smoke-empty-log.tests.ps1 b/scripts/test-smoke-empty-log.tests.ps1 new file mode 100644 index 0000000000..3d05bc4b1a --- /dev/null +++ b/scripts/test-smoke-empty-log.tests.ps1 @@ -0,0 +1,26 @@ +# Run with powershell.exe or pwsh.exe. An empty log cannot support a smoke report. +$ErrorActionPreference = 'Stop' +$smoke = Join-Path $PSScriptRoot 'smoke.ps1' +$temp = (Resolve-Path -LiteralPath ([IO.Path]::GetTempPath())).Path +$fixture = Join-Path $temp ('xcl-smoke-empty-' + [guid]::NewGuid()) +$null = New-Item -ItemType Directory -Path $fixture +try { + $xcl = Join-Path $fixture 'xcl.cmd' + $log = Join-Path $fixture 'xcl.log' + [IO.File]::WriteAllText($xcl, "@echo off`r`necho Log: %~dp0xcl.log`r`n") + [IO.File]::WriteAllText((Join-Path $fixture 'report.json'), '{"d3d12":{"adapter":"Fixture GPU"}}') + + foreach ($content in @('', " `t`r`n")) { + [IO.File]::WriteAllText($log, $content) + $failure = $null + try { $null = & $smoke -Game $fixture -Xcl $xcl -Seconds 1 -Title 'Fixture' } + catch { $failure = $_.Exception.Message } + if ($failure -ne "XCL log is empty: $log") { + throw "Expected the empty log diagnostic, got '$failure'." + } + } + 'smoke-empty-log: ok' +} finally { + $resolved = (Resolve-Path -LiteralPath $fixture).Path + if ((Split-Path -Parent $resolved) -eq $temp) { Remove-Item -LiteralPath $resolved -Recurse -Force } +}