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

Open
opened 2026-11-26 21:19:49 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/2034
Author: @abnalstlll-byte
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: feat/rt-console-identity-coverage


📝 Commits (1)

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

📊 Changes

2 files changed (+212 additions, -0 deletions)

View changed files

📝 runtime/CMakeLists.txt (+12 -0)
➕ runtime/test/console_identity_test.cpp (+200 -0)

📄 Description

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)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/2034 **Author:** [@abnalstlll-byte](https://github.com/abnalstlll-byte) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/rt-console-identity-coverage` --- ### 📝 Commits (1) - [`ba4d61e`](https://github.com/ubiquitarianism/leonida/commit/ba4d61e12bd1cc65dc631bccf7bb461cd4df78da) runtime: add unit test suite for console identity and registry ConsoleMode mapping (RT-CONSOLE-IDENTITY-COVERAGE) ### 📊 Changes **2 files changed** (+212 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `runtime/CMakeLists.txt` (+12 -0) ➕ `runtime/test/console_identity_test.cpp` (+200 -0) </details> ### 📄 Description Claimed in the coordination issue as: RT-CONSOLE-IDENTITY-COVERAGE ([claim](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7171091676)) ### 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) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#2040
No description provided.