wine: normalize device IDs with one process (WINE-DEVICE-ID-NORMALIZE) #3268

Closed
leonida/mandy
chagedUserHello wants to merge 0 commits from perf/wine-device-id-normalize-2570 into main

Pull request closed

This pull request cannot be reopened because the branch was deleted.

chagedUserHello commented 2026-12-03 00:02:30 +00:00
No description provided.
copilot-pull-request-reviewer[bot] reviewed 2026-12-03 00:04:11 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
<!-- ccr-overview-v2 --> ### 🟢 Approval recommended No active review issues were identified for the Wine launcher device-selection optimization. **No open issues** 🎉 <details> <summary><strong>What changed in this PR</strong></summary> Optimizes Wine launcher device selection by normalizing the requested PCI ID once while preserving case-insensitive matching and CRLF handling. **Changes:** - Replaces per-node lowercase conversions with Bash case-insensitive matching. - Extends synthetic coverage to two render nodes, mixed-case IDs, and exactly one lowercase conversion. | File | Description | | ---- | ----------- | | tests/​test_run_game_wine_safety.py | Adds mixed-case, CRLF fixtures and conversion-count verification. | | scripts/​run_game_wine.sh | Normalizes the selector once and matches sysfs IDs case-insensitively. | </details> <sub>Review effort: Balanced</sub>
merzleckeier reviewed 2026-12-03 00:08:46 +00:00
merzleckeier left a comment
No description provided.
One state-preservation edge case on `2293effb` against `main` at `81efe4566`. The unconditional `shopt -u nocasematch` at the end of the device scan clears an option that may already be on. When the caller exports `BASHOPTS` with `nocasematch`, downstream Bash helpers inherit the changed value. I reran the actual launcher with the synthetic sysfs fixture and a stub Wine command that records `shopt -q nocasematch`. With the option initially on, the stub sees `on` on main and `off` on this PR. Recording the entry state and only undoing `shopt -s` when the launcher enabled it made both the initially-on and initially-off cases pass in a scratch copy. The intended optimization works on this head. The new assertion sees five conversions on main and one here, and all 36 Linux tests across the launcher, safety, and summary suites passed. They also pass with the state-preservation change. Synthetic fixtures only. AI-assisted.
fiestorra commented 2026-12-03 00:20:32 +00:00

VERIFY-3268 — Windows nativo: red then green (el script de wine, corrido por su test en bash)

Own commit 2293effb4 — scripts/run_game_wine.sh (7), tests/test_run_game_wine_safety.py (+34)

Ran at the head

python -I tests/test_run_game_wine_safety.py     3 tests — OK

Negative control: main's run_game_wine.sh back, tests kept:

FAIL: test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation

It bites.

What the change is: the device id is normalised once instead of on every use — a WINE_DEVICE_ID-style string being lowercased in each of several places becomes lowercased once, where it is read. Seven lines in a shell script.

And the test is a small victory of its own: it drives the actual run_game_wine.sh through bash with a fake wine, and asserts the exit status propagates through the inner bash, the lock and the summary — a shell script's three most common ways to lose an exit code, all in one test name. That is why the test caught my reversal: the normalisation is one of the things that name pins.

What I could not test

  • A real Wine run: the test fakes wine; the device id's effect on a driver needs the title under Wine.

Written with an AI assistant.

## VERIFY-3268 — Windows nativo: `red then green` (el script de wine, corrido por su test en bash) | | | |---|---| | Own commit | `2293effb4` — `scripts/run_game_wine.sh` (7), `tests/test_run_game_wine_safety.py` (+34) | **Ran at the head** ``` python -I tests/test_run_game_wine_safety.py 3 tests — OK ``` **Negative control**: `main`'s `run_game_wine.sh` back, tests kept: ``` FAIL: test_uppercase_device_inner_bash_lock_parent_and_summary_exit_propagation ``` **It bites.** **What the change is**: **the device id is normalised once instead of on every use** — a `WINE_DEVICE_ID`-style string being lowercased **in each of several places** becomes **lowercased once, where it is read.** **Seven lines in a shell script.** **And the test is a small victory of its own**: it drives the *actual* `run_game_wine.sh` **through bash with a fake `wine`**, and asserts **the exit status propagates through the inner bash, the lock and the summary** — **a shell script's three most common ways to lose an exit code**, all in one test name. **That is why the test caught my reversal**: the normalisation is one of the things that name pins. **What I could not test** - **A real Wine run**: the test fakes `wine`; **the device id's effect on a driver** needs the title under Wine. Written with an AI assistant.
josefernanlo commented 2026-12-03 00:35:31 +00:00

Addressed the nocasematch state-preservation review in 8fc604271.

The launcher now records shopt -q nocasematch before enabling it and only clears the option when this scan enabled it. The safety fixture checks both inherited states at the actual wine stub: off -> off and exported BASHOPTS with nocasematch on -> on. The off-state case is also deterministic when the test process itself inherits BASHOPTS=nocasematch.

Validation:

  • python -I tests/test_run_game_wine_safety.py: 3 passed (including with hostile inherited BASHOPTS=nocasematch)
  • python -I tests/test_run_wine_tests.py: 65 passed, 14 skipped
  • python -I scripts/check_no_game_data.py scripts/run_game_wine.sh tests/test_run_game_wine_safety.py: passed
  • bash -n scripts/run_game_wine.sh, git diff --check: passed
  • Independent read-only re-review: LGTM

Synthetic fixtures only; no real Wine run or GPU.

Addressed the `nocasematch` state-preservation review in `8fc604271`. The launcher now records `shopt -q nocasematch` before enabling it and only clears the option when this scan enabled it. The safety fixture checks both inherited states at the actual `wine` stub: `off -> off` and exported `BASHOPTS` with `nocasematch` `on -> on`. The off-state case is also deterministic when the test process itself inherits `BASHOPTS=nocasematch`. Validation: - `python -I tests/test_run_game_wine_safety.py`: 3 passed (including with hostile inherited `BASHOPTS=nocasematch`) - `python -I tests/test_run_wine_tests.py`: 65 passed, 14 skipped - `python -I scripts/check_no_game_data.py scripts/run_game_wine.sh tests/test_run_game_wine_safety.py`: passed - `bash -n scripts/run_game_wine.sh`, `git diff --check`: passed - Independent read-only re-review: LGTM Synthetic fixtures only; no real Wine run or GPU.
merzleckeier reviewed 2026-12-03 00:42:52 +00:00
merzleckeier left a comment
No description provided.
Rechecked `8fc60427`. The new regression detects the inherited `nocasematch` loss with the previous launcher `2293effb` and passes with the fix. The inherited-on and default-off cases now both reach the synthetic Wine subprocess with their original state. All 36 tests in the Wine launcher, safety and summary suites passed on Linux, including the one-conversion check. This resolves my earlier review point. AI-assisted.
copilot-pull-request-reviewer[bot] reviewed 2026-12-03 00:50:11 +00:00
copilot-pull-request-reviewer[bot] left a comment
No description provided.
<!-- ccr-overview-v2 --> ### 🟡 Changes recommended The Wine safety test can pass despite a missing `nocasematch` restore because the wrapper does not export `BASHOPTS` to the stub. <details open> <summary><strong>1 open issue</strong></summary> - <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Export nocasematch in the wrapper to detect leaked shell options](https://github.com/ProjectLeonida/mandy/pull/3268#discussion_r4778307200) · New </details> <sub>Review effort: Max</sub> **`tests/test_run_game_wine_safety.py` line 217:** > Without exported `BASHOPTS`, the Wine stub starts with `nocasematch` off even if the launcher leaves it enabled, so the new `off` assertion cannot detect a missing restore. Explicitly disable `nocasematch` and export `BASHOPTS` in the first wrapper so leaked options reach the probe.
Sign in to join this conversation.
No description provided.