From 4248cde9da24481c29775632d20f5cd5a9f19fea Mon Sep 17 00:00:00 2001 From: rrrarrra9 <122691427+rrrarrra9@users.noreply.github.com> Date: Tue, 24 Nov 2026 22:53:59 +0100 Subject: [PATCH] Scripts: keep smoke reports when adapter lookup fails Treat optional adapter discovery separately from the smoke results. Skip blank controller names and the basic display adapter while keeping the measured crash, device removal and memory counters if CIM is unavailable. Assisted-by: OpenAI Codex (GPT-6) --- scripts/smoke-adapter.tests.ps1 | 68 +++++++++++++++++++++++++++++++++ scripts/smoke.ps1 | 11 +++++- 2 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 scripts/smoke-adapter.tests.ps1 diff --git a/scripts/smoke-adapter.tests.ps1 b/scripts/smoke-adapter.tests.ps1 new file mode 100644 index 000000000..fc5efc437 --- /dev/null +++ b/scripts/smoke-adapter.tests.ps1 @@ -0,0 +1,68 @@ +# Run in PowerShell 5.1 or 7. Simulate a test run on a machine without access to CIM. +param([string]$Smoke = (Join-Path $PSScriptRoot 'smoke.ps1')) +$ErrorActionPreference = 'Stop' +$fixture = Join-Path ([IO.Path]::GetTempPath()) ('xcl-smoke-adapter-' + [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' +$artifacts = Join-Path $fixture 'artifacts' + +function Get-CimInstance { + [CmdletBinding()] + param([Parameter(Position = 0)][string]$ClassName) + if ($cimMode -eq 'unavailable') { throw 'Fixture: CIM is unavailable' } + if ($cimMode -eq 'empty') { return } + if ($cimMode -eq 'available') { + [pscustomobject]@{ Name = $null } + [pscustomobject]@{ Name = ' ' } + } + [pscustomobject]@{ Name = 'Microsoft Basic Display Adapter' } + if ($cimMode -eq 'available') { [pscustomobject]@{ Name = 'Fixture Controller' } } +} + +function Test-SmokeAdapter([string]$Expected, [switch]$SaveArtifacts) { + $options = @{} + if ($SaveArtifacts) { $options.OutDir = $artifacts } + $block = & $Smoke -Game 'D:\Synthetic' -Seconds 2 -Xcl $xcl -Title 'fixture' @options + if ($block -notmatch ('(?m)^gpu: ' + [regex]::Escape($Expected) + '\r?$')) { + throw "Smoke did not report '$Expected'" + } + if ($block -notmatch '(?m)^device removals: 1\r?$' -or $block -notmatch '(?m)^crashes: 1\r?$' -or + $block -notmatch '(?m)^peak commit: 512 MB\r?$') { + throw 'Smoke lost the failure or memory diagnostics' + } + if ($SaveArtifacts) { + $manifest = Get-Content -LiteralPath (Join-Path $artifacts 'manifest.json') -Raw -Encoding utf8 | ConvertFrom-Json + if ($manifest.gpu -ne $Expected -or $manifest.removals -ne 1 -or $manifest.crashes -ne 1 -or + $manifest.peak_commit_mb -ne 512 -or -not (Test-Path -LiteralPath (Join-Path $artifacts 'xcl.log'))) { + throw 'Smoke lost the failure diagnostics in the saved artifacts' + } + } +} + +try { + [IO.File]::WriteAllText($xcl, "@echo off`r`necho Log: %~dp0xcl.log`r`n") + [IO.File]::WriteAllLines($log, @('memory: 512 MB committed', 'device removed', 'unhandled exception')) + + $cimMode = 'unavailable' + Test-SmokeAdapter 'unknown' -SaveArtifacts + $cimMode = 'empty' + Test-SmokeAdapter 'unknown' + $cimMode = 'basic' + Test-SmokeAdapter 'unknown' + $cimMode = 'available' + Test-SmokeAdapter 'Fixture Controller' + + [IO.File]::WriteAllText($report, '{"d3d12":{"adapter":"Report GPU (4096 MiB VRAM)"}}') + Test-SmokeAdapter 'Report GPU' + 'smoke-adapter: ok' +} finally { + if (Test-Path -LiteralPath $artifacts) { + [IO.File]::Delete((Join-Path $artifacts 'manifest.json')) + [IO.File]::Delete((Join-Path $artifacts 'xcl.log')) + [IO.Directory]::Delete($artifacts) + } + foreach ($path in $xcl,$log,$report) { [IO.File]::Delete($path) } + [IO.Directory]::Delete($fixture) +} diff --git a/scripts/smoke.ps1 b/scripts/smoke.ps1 index db296218b..50fd37db9 100644 --- a/scripts/smoke.ps1 +++ b/scripts/smoke.ps1 @@ -87,7 +87,16 @@ $report = Join-Path (Split-Path $log -Parent) 'report.json' 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 } +if (-not $gpu) { + try { + $gpu = (Get-CimInstance Win32_VideoController -ErrorAction Stop | + Where-Object { -not [string]::IsNullOrWhiteSpace($_.Name) -and $_.Name -notmatch 'Basic' } | + Select-Object -First 1).Name + } catch { + # A run can lack a report, and CIM can be unavailable. Keep the crash summary. + } +} +if (-not $gpu) { $gpu = 'unknown' } $code = if ($timedOut) { 'killed (no exit)' } else { '0x{0:x}' -f $p.ExitCode } if ($OutDir) {