tests: dry runs of play-nvidia's frame generation + ray tracing rule (review of #3230)

Series S keeps frame generation with hardware RT and sets LEONIDA_FG_WITH_RT=1; Series X under 12 GB leaves it
off unless -More LEONIDA_FG_WITH_RT=1; 12 GB or more, or an unknown size, keeps it; LEONIDA_FG_WITH_RT=0 leaves it
off. The card's memory is a stubbed registry value. Fails on main's script and without the 12 GB rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
OreoFR
2026-12-03 00:49:02 +01:00
parent 1b8a69bec2
commit 6b49e52758

View File

@ -144,6 +144,82 @@ $options = @{
for args in restart_args[1:]:
self.assertNotRegex(args, r"(?:^| )-MotionBlur(?: |$)")
@unittest.skipUnless(POWERSHELL, "requires PowerShell")
def test_nvidia_frame_generation_with_ray_tracing(self) -> None:
"""Frame generation with hardware ray tracing: kept (and LEONIDA_FG_WITH_RT=1 set for the runtime's guard)
except on the Series X profile under 12 GB of video memory; -More LEONIDA_FG_WITH_RT=1 keeps it there too,
and LEONIDA_FG_WITH_RT=0 leaves it off anywhere. The card's memory is a stubbed registry value."""
with tempfile.TemporaryDirectory() as td:
root = Path(td)
scripts = root / "scripts"
scripts.mkdir()
launcher = scripts / NVIDIA_LAUNCHER.name
shutil.copyfile(NVIDIA_LAUNCHER, launcher)
executable = root / "synthetic title.exe"
executable.touch()
streamline = root / "streamline"
streamline.mkdir()
(streamline / "sl.interposer.dll").touch()
command = r"""
$ErrorActionPreference = 'Stop'
function Get-CimInstance {
param([string]$ClassName)
if ($ClassName -ne 'Win32_OperatingSystem') { throw "Unexpected CIM query: $ClassName" }
[pscustomobject]@{ BuildNumber = '26100' }
}
# The display class key: one adapter whose memory is $global:vram.
function Get-ChildItem {
param([Parameter(Position = 0)]$Path, [Parameter(ValueFromRemainingArguments = $true)]$Rest)
if ("$Path" -like 'HKLM:*{4d36e968*') { return [pscustomobject]@{ PSPath = 'stub' } }
Microsoft.PowerShell.Management\Get-ChildItem -Path $Path @Rest
}
function Get-ItemProperty {
param([Parameter(Position = 0)]$Path, [string]$Name, [Parameter(ValueFromRemainingArguments = $true)]$Rest)
if ("$Path" -eq 'stub') { return [pscustomobject]@{ 'HardwareInformation.qwMemorySize' = [uint64]$global:vram } }
Microsoft.PowerShell.Management\Get-ItemProperty -Path $Path -Name $Name @Rest
}
$options = @{
Exe = $env:TEST_NVIDIA_EXE
DryRun = $true
NoPrecompile = $true
WindowsBarMB = 0
HardwareRT = $true
FrameGen = 2
StreamlineDir = $env:TEST_STREAMLINE
}
function Show-Case([string]$name, [uint64]$memory, [hashtable]$extra) {
$global:vram = $memory
$lines = & $env:TEST_NVIDIA_LAUNCHER @options @extra
$fg = ($lines | Where-Object { $_ -like 'LEONIDA_FRAME_GEN=*' }) -replace '^LEONIDA_FRAME_GEN=', ''
$rt = ($lines | Where-Object { $_ -like 'LEONIDA_FG_WITH_RT=*' }) -replace '^LEONIDA_FG_WITH_RT=', ''
"CASE $name fg=$fg with_rt=$rt"
}
Show-Case 'S-8' 8GB @{}
Show-Case 'X-8' 8GB @{ SeriesX = $true }
Show-Case 'X-16' 16GB @{ SeriesX = $true }
Show-Case 'X-8-unlocked' 8GB @{ SeriesX = $true; More = @{ LEONIDA_FG_WITH_RT = '1' } }
Show-Case 'S-8-off' 8GB @{ More = @{ LEONIDA_FG_WITH_RT = '0' } }
Show-Case 'X-unknown' 0 @{ SeriesX = $true }
"""
env = {name: value for name, value in os.environ.items() if not name.upper().startswith("LEONIDA_")}
env.update(TEST_NVIDIA_LAUNCHER=str(launcher), TEST_NVIDIA_EXE=str(executable),
TEST_STREAMLINE=str(streamline))
result = subprocess.run(
[POWERSHELL, "-NoProfile", "-NonInteractive", "-ExecutionPolicy", "Bypass", "-Command", command],
env=env, capture_output=True, encoding="utf-8", errors="replace", timeout=120,
)
self.assertEqual(result.returncode, 0, result.stdout + result.stderr)
cases = dict(line.split(" ", 2)[1:] for line in result.stdout.splitlines() if line.startswith("CASE "))
self.assertEqual(cases, {
"S-8": "fg=2 with_rt=1", # Series S: kept, the runtime's guard told
"X-8": "fg= with_rt=", # Series X under 12 GB: left off
"X-16": "fg=2 with_rt=1", # Series X with 12 GB or more: kept
"X-8-unlocked": "fg=2 with_rt=1", # -More LEONIDA_FG_WITH_RT=1 keeps it under 12 GB
"S-8-off": "fg= with_rt=0", # LEONIDA_FG_WITH_RT=0 leaves it off
"X-unknown": "fg=2 with_rt=1", # memory unknown (0): not held back
}, result.stdout + result.stderr)
def test_static_quoting_and_no_pause_guards(self) -> None:
build_txt = BUILD_BAT.read_text(encoding="utf-8")
mods_txt = MODS_BAT.read_text(encoding="utf-8")