From 791fbe135db894cfcea8f1699a91f46dc5ac82a3 Mon Sep 17 00:00:00 2001 From: NiiRoZz Date: Tue, 24 Nov 2026 01:08:19 +0100 Subject: [PATCH] Scripts: a test of smoke.ps1's block Nothing ran scripts/smoke.ps1, whose block is the evidence every runtime PR pastes. scripts/smoke.tests.ps1 runs it against a stand-in xcl and a written log and report, as test-native-stderr.tests.ps1 does for test.ps1: - gpu: is the adapter of the run's report.json with its VRAM suffix dropped; a report without an adapter (the null backend) and no report at all fall back to the first video controller; - title, seconds, exit code, frames, presents and peak commit come from the run and its log; - a device removal and an unhandled exception in the log are counted. Against smoke.ps1 as it was before its gpu: line came from the report, the test fails on that line. AI-assisted. --- scripts/smoke.tests.ps1 | 46 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 scripts/smoke.tests.ps1 diff --git a/scripts/smoke.tests.ps1 b/scripts/smoke.tests.ps1 new file mode 100644 index 000000000..d3ba3b06b --- /dev/null +++ b/scripts/smoke.tests.ps1 @@ -0,0 +1,46 @@ +# Run with powershell.exe or pwsh.exe. A stand-in for xcl.exe prints the path of a log written here. +$ErrorActionPreference = 'Stop' +$smoke = Join-Path $PSScriptRoot 'smoke.ps1' +$fixture = Join-Path ([IO.Path]::GetTempPath()) ('xcl-smoke-' + [guid]::NewGuid()) +$null = New-Item -ItemType Directory -Path $fixture +$xcl = Join-Path $fixture 'xcl.cmd' +$log = Join-Path $fixture 'xcl.log' +$report = Join-Path $fixture 'report.json' +$game = Join-Path $fixture 'SomeTitle' +$null = New-Item -ItemType Directory -Path $game +function Get-Block { ((& $smoke -Game $game -Seconds 1 -Xcl $xcl) -join "`n") -replace "`r", '' } +function Assert-Line($block, $line) { if (!$block.Contains("$line`n")) { throw "Expected '$line' in the block:`n$block" } } +try { + "@echo off`r`necho Log: $log" | Set-Content -LiteralPath $xcl -Encoding Ascii + @( + 'xcl: activity (2 s): 60 presents, 240 submits' + 'xcl: memory: 1234 MB committed by the process' + 'xcl: timed run over (118 frames shown, 120 PresentX calls)' + ) | Set-Content -LiteralPath $log -Encoding utf8 + $first = (Get-CimInstance Win32_VideoController | Where-Object { $_.Name -notmatch 'Basic' } | Select-Object -First 1).Name + + # a run on a machine's second adapter: the block names the one in the run's report + '{"d3d12":{"adapter":"Synthetic Adapter 9000 (32187 MiB VRAM)"}}' | Set-Content -LiteralPath $report -Encoding utf8 + $block = Get-Block + foreach ($line in 'gpu: Synthetic Adapter 9000', 'title: SomeTitle', 'seconds: 1', 'exit: 0x0', + 'frames shown: 118 (PresentX 120)', 'presents per 2 s (last 3): 60', 'device removals: 0', 'crashes: 0', + 'peak commit: 1234 MB') { + Assert-Line $block $line + } + + # a report without an adapter (the null backend), and no report at all: the first video controller + '{"d3d12":{"adapter":null}}' | Set-Content -LiteralPath $report -Encoding utf8 + Assert-Line (Get-Block) "gpu: $first" + Remove-Item -LiteralPath $report + Assert-Line (Get-Block) "gpu: $first" + + # a crash and a device removal in the log are counted + Add-Content -LiteralPath $log -Value 'xcl: D3D12.X: device removed (0x887a0006)', 'xcl: unhandled exception 0xc0000005' -Encoding utf8 + $block = Get-Block + Assert-Line $block 'device removals: 1' + Assert-Line $block 'crashes: 1' +} finally { + foreach ($path in $xcl, $log, $report, $game, $fixture) { + if (Test-Path -LiteralPath $path) { Remove-Item -LiteralPath $path } + } +}