Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions tests/startup_run_ps1_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import time
from pathlib import Path

record = [sys.argv[1:], os.environ.get("X2W_TRACE_API")]
record = [sys.argv[1:], os.environ.get("X2W_TRACE_API"), os.environ.get("X2W_TITLE_ID"), os.environ.get("X2W_STORAGE_MB")]
Path(__file__).with_name("debugger.json").write_text(json.dumps(record), encoding="utf-8")
# Under -Translate, wait until the watcher stub has started so run.ps1 cannot stop it before then.
watch = Path(__file__).with_name("watch.json")
Expand Down Expand Up @@ -136,7 +136,7 @@ def alive(pid):


def run_case(shell, script, code, work, translate=False, switches=(), passed=(), fake_user_env=False,
early_exit=False, trace_api_env=None, absolute_build=False, missing_build=False):
early_exit=False, trace_api_env=None, absolute_build=False, missing_build=False, manifest="absent"):
"""Run one copy of the script on a stub that exits with `code`; return what is wrong.

`switches` are extra run.ps1 switches and `passed` the debugger arguments they must add.
Expand All @@ -154,11 +154,19 @@ def run_case(shell, script, code, work, translate=False, switches=(), passed=(),
build.mkdir()
for dll in DLLS: # the stand-ins the script copies next to the executable
(build / f"{dll}.dll").write_bytes(b"")
exe, data, log = root / "run" / "t.exe", root / "data", root / "log"
exe, data, log = root / "run" / "t.exe", root / ("data [test]" if manifest.startswith("bracket") else "data"), root / "log"
exe.parent.mkdir()
exe.write_bytes(b"")
data.mkdir()
if manifest in ("normal", "bracket"):
(data / "MicrosoftGame.config").write_text("<TitleId>1234</TitleId><SizeMB>42</SizeMB>", encoding="utf-8")
if manifest.startswith("bracket"):
decoy = root / "data t"
decoy.mkdir()
(decoy / "MicrosoftGame.config").write_text("<TitleId>9999</TitleId><SizeMB>99</SizeMB>", encoding="utf-8")
env = dict(os.environ)
env.pop("X2W_TITLE_ID", None)
env.pop("X2W_STORAGE_MB", None)
# Compare PowerShell's warning text consistently on hosts that enable ANSI colors.
env["NO_COLOR"] = "1"
env.pop("X2W_FAKE_USER", None)
Expand Down Expand Up @@ -215,9 +223,11 @@ def run_case(shell, script, code, work, translate=False, switches=(), passed=(),
"--trace-files", "1", "--continue-asserts", "4", *passed]
record = startup / "debugger.json"
got = json.loads(record.read_text(encoding="utf-8")) if record.is_file() else None
expected = [want, "1" if "-TraceApi" in switches else trace_api_env]
expected = [want, "1" if "-TraceApi" in switches else trace_api_env,
"1234" if manifest in ("normal", "bracket") else None,
"42" if manifest in ("normal", "bracket") else None]
if got != expected:
found.append(f"stub exit {code}: debugger [argv, X2W_TRACE_API] was {got}, expected {expected}")
found.append(f"stub exit {code}: debugger [argv, trace, title ID, storage MB] was {got}, expected {expected}")
watch = startup / "watch.json"
if translate:
started = json.loads(watch.read_text(encoding="utf-8")) if watch.is_file() else None
Expand All @@ -242,6 +252,8 @@ def run_problems(shell, script, work, first_only):
if found and first_only:
return found
found += run_case(shell, script, 7, work, absolute_build=True)
for manifest in ("normal", "bracket", "bracket_missing"):
found += run_case(shell, script, 0, work, manifest=manifest)
if found and first_only:
return found
found += run_case(shell, script, 0, work, switches=["-FakeUser"])
Expand Down
4 changes: 2 additions & 2 deletions tools/startup/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ foreach ($dll in "xmem", "d3d12_xs", "AcpHal", "XCRDAPI", "chad", "xapu", "xg_xs
$env:X2W_AUDIO_PERMISSIVE = "1"; $env:X2W_D3D12_DEVICE_NOOP = "1"; $env:X2W_D3D12_LIST_NOOP = "1"
$env:X2W_D3D12_PERMISSIVE = "1"; $env:X2W_XMEM_PERMISSIVE = "1"; $env:X2W_RUNTIME_PROXY = "1"
$config = Join-Path $DataDir "MicrosoftGame.config"
if (Test-Path $config) {
$text = Get-Content $config -Raw
if (Test-Path -LiteralPath $config) {
$text = Get-Content -LiteralPath $config -Raw
if ($text -match "<TitleId>([^<]*)") { $env:X2W_TITLE_ID = $Matches[1] }
if ($text -match "<SizeMB>([^<]*)") { $env:X2W_STORAGE_MB = $Matches[1] }
}
Expand Down
Loading