From 682bbba40ae822644ad88f5d6c40af01b5df7e75 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 A missing report.json combined with an unavailable CIM service stopped smoke.ps1 before it could show the measured memory and device-removal count. Treat optional adapter discovery separately from the smoke results. Assisted-by: OpenAI Codex (gpt-6.2-sol) --- scripts/smoke-adapter.tests.ps1 | 46 +++++++++++++++++++++++++++++++++ scripts/smoke.ps1 | 9 ++++++- 2 files changed, 54 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..28d28b9a5 --- /dev/null +++ b/scripts/smoke-adapter.tests.ps1 @@ -0,0 +1,46 @@ +# 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' + +function Get-CimInstance { + [CmdletBinding()] + param([Parameter(Position = 0)][string]$ClassName) + if ($cimMode -eq 'unavailable') { throw 'Fixture: CIM is unavailable' } + [pscustomobject]@{ Name = 'Microsoft Basic Display Adapter' } + if ($cimMode -eq 'available') { [pscustomobject]@{ Name = 'Fixture Controller' } } +} + +function Test-SmokeAdapter([string]$Expected) { + $block = & $Smoke -Game 'D:\Synthetic' -Seconds 2 -Xcl $xcl -Title 'fixture' + 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' + } +} + +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' + $cimMode = 'empty' + 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 { + 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 b7859c924..2f2a44416 100644 --- a/scripts/smoke.ps1 +++ b/scripts/smoke.ps1 @@ -81,7 +81,14 @@ $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 { $_.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 } @"