Skip to content

runtime: add unit test suite for console identity and registry ConsoleMode mapping (RT-CONSOLE-IDENTITY-COVERAGE) - #2034

Open
abnalstlll-byte wants to merge 1 commit into
ProjectLeonida:mainfrom
abnalstlll-byte:feat/rt-console-identity-coverage
Open

abnalstlll-byte wants to merge 1 commit into
ProjectLeonida:mainfrom
abnalstlll-byte:feat/rt-console-identity-coverage

Conversation

@abnalstlll-byte

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: RT-CONSOLE-IDENTITY-COVERAGE (claim)

What and why

runtime/shims/console_identity.h is the single source of truth for console device type (configured_device_type()) and OEM registry ConsoleMode mapping (console_mode_for()), ensuring XSystemGetDeviceType and registry queries HKLM\Software\Microsoft\Windows NT\CurrentVersion\OEM\ConsoleMode never disagree.

Previously, console_identity.h lacked a dedicated standalone unit test exercising all device type enums and environment variable boundary conditions.

This adds runtime/test/console_identity_test.cpp verifying:

  1. console_mode_for:
    • Returns true and correct DWORD values for Xbox Series consoles: Lockhart (0x60), Anaconda (0x64), Devkit (0x68).
    • Returns false for non-console / Xbox One types (Unknown, Pc, XboxOne, XboxOneS, XboxOneX, XboxOneXDevkit) and out-of-range values, leaving them to the host registry.
  2. configured_device_type:
    • Defaults to Series X (XboxScarlettAnaconda, 7) when LEONIDA_DEVICE_TYPE is unset, empty, or outside 0..8.
    • Accurately parses values 0..8.
    • Treats non-numeric text strings as 0 per documented contract.
    • Handles oversized strings (>16 bytes) gracefully without buffer overrun.
  3. Cross-subsystem consistency between configured_device_type() and console_mode_for().

Registers console_identity_test and CTest console_identity in runtime/CMakeLists.txt.

Tested

  • Unit test execution: 41/41 checks passed (0 failures).
  • python -I tests/test_ci_registration.py: 16/16 pass.
  • python -I tests/test_text_write_line_endings.py: 3/3 pass.
  • python -I scripts/check_no_game_data.py: clean (0 violations, no game data).

AI-assisted (Claude Code)

…eMode mapping (RT-CONSOLE-IDENTITY-COVERAGE)

Add standalone CPU-only unit test runtime/test/console_identity_test.cpp covering configured_device_type, console_mode_for, and cross-subsystem consistency across all device types and environment variable inputs.

Register console_identity_test executable and CTest in runtime/CMakeLists.txt.

AI-assisted (Claude Code)
@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main d48a957bb + ba4d61e12b (claim #2570#issuecomment-7239425776):

  • Line-by-line diff audit: Clean (runtime/CMakeLists.txt, runtime/test/console_identity_test.cpp); adds dedicated Win32 unit coverage for rt::shims::console_identity::console_mode_for (0x60/0x64/0x68 vs non-console device types) and configured_device_type() (LEONIDA_DEVICE_TYPE 0..8, non-numeric -> 0, out-of-range/empty/oversized -> Series X 7) with RAII environment restoration. check_no_game_data.py clean.
  • Red (d48a957bb / fault injection): console_identity_test.cpp is absent on main (C1083), and injecting a 0x64 -> 0x60 regression in console_identity.h fails Red (rc=1, FAIL Anaconda mode is 0x64, 39/41 checks passed).
  • Green (d48a957bb + ba4d61e12b merge): Auto-merges cleanly (rc=0), compiles with 0 warnings under /W4 /permissive-, and passes (41/41 checks passed, rc=0).
  • Coordination note with #2039: Both #2034 and #2039 insert adjacent blocks at the same lines of runtime/CMakeLists.txt (git merge-tree rc=1 trivial additive conflict once the first merges).

AI-assisted.

@OreoFR

OreoFR commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Verified by OreoFR

  • Base: main aa918e5d9 + PR head ba4d61e12
  • Test: ctest -R ^console_identity$
  • Red on main: passes (test-only PR, the new test covers behaviour already on main)
  • Green with the PR: passes; package builds, full ctest shows no new failure
  • Verdict: NO RED (test-only PR, no fix to show)
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

Note: shares runtime/CMakeLists.txt with the open #2566; a rebase may be needed if #2566 lands first.

AI-assisted (Claude Code, Claude Opus 5.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants