runtime/test: run_tiny_tls_ga's failed-reservation half unsets LEONIDA_TEST_DIR (RT-TLS-INDEX0-TEST-DIR) #3514

Code

Clone this repository

Checkout

From your project repository, check out a new branch and test the changes.

git fetch -u  "rt/tls-index0-test-dir:jirehcwe-rt/tls-index0-test-dir"
git switch "jirehcwe-rt/tls-index0-test-dir"
Open
leonida/mandy
jirehcwe wants to merge 1 commit from jirehcwe/mandy:rt/tls-index0-test-dir into main

This branch is out-of-date with the base branch

Conversation
Reviewers 0 approvals
  • No reviewers
Details
This pull request is blocked because it's outdated.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'rt/tls-index0-test-dir:jirehcwe-rt/tls-index0-test-dir'
git switch 'jirehcwe-rt/tls-index0-test-dir'
First-time contributor

Claimed in the coordination issue as: RT-TLS-INDEX0-TEST-DIR (claim)

What and why

run_tiny_tls_ga fails whenever LEONIDA_TEST_DIR is set. AGENTS.md says to set it when antivirus blocks
loader_test, so a contributor who followed that advice gets a failing test.

The second half of runtime/test/check_tls_index0.cmake points TMP and TEMP at a missing folder, so the home
clone of gta6rt_tls_host.dll cannot be written and --run and --init must refuse the image. But
tls_host_clone_dir() (runtime/src/pe_loader.cpp) reads LEONIDA_TEST_DIR before TMP and TEMP. That lookup is
deliberate (f0bd98bef, TEST-TEMPDIR-STRIPPED-ENV). With the variable set, the clone is written there, the
reservation succeeds, and the script fails with --run without the reservation returned 0.

The change is test-only: the script's failed-reservation commands, the emulator probe included, now run with
LEONIDA_TEST_DIR unset (cmake -E env --unset=LEONIDA_TEST_DIR ...). With the variable unset, nothing changes. The
first half still honours the variable, which is its purpose.

The claim said the commands would point LEONIDA_TEST_DIR at the missing folder. I unset it instead. Setting it would
exercise the variable's branch in the loader, not the TMP/TEMP → GetTempPathW path this test is about, and it
would change what the Wine probe sees.

Tested

On main f4b0404e9, Windows 11, same build, ctest -R "^(run_tiny_tls_ga|loader_tls_index0)":

Script LEONIDA_TEST_DIR run_tiny_tls_ga
main set fails (--run without the reservation returned 0)
main unset passes
this change set passes
this change unset passes
  • The three loader_tls_index0* tests pass in all four runs.
  • python -I scripts/check_no_game_data.py: clean, on the whole tree.
  • An independent read-only reviewer agent approved:
    • The diagnosis and the -E env --unset usage are right (--unset exists since CMake 3.1; the runtime requires 3.24).
    • A test-side fix is the right place.
    • The Wine SKIP logic is unchanged.
  • Not tested: Wine or Linux. Under an emulator the probe now depends only on whether TMP/TEMP reach
    GetTempPathW, which is what its comment describes.

GPUs tested: n/a (no GPU involved)

AI-assisted: yes. Claude Code with Claude Fable 5.2 wrote the change. A separate read-only reviewer agent on Claude
Opus 5.5 reviewed it.

Follow-up (not in this pull request)

runtime/test/check_tls_clone_cleanup.cmake (run_tiny_tls_clone_cleanup) looks for clone files only in TMP or
TEMP. With LEONIDA_TEST_DIR set, the loader writes them elsewhere, so both globs find nothing and the test passes
without checking anything. Reported as a finding: in the coordination issue.

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)

🤖 Generated with Claude Code

Claimed in the coordination issue as: RT-TLS-INDEX0-TEST-DIR ([claim](https://clearfieldswimming.com/leonida/mandy/issues/3312#issuecomment-26782)) ### What and why `run_tiny_tls_ga` fails whenever `LEONIDA_TEST_DIR` is set. AGENTS.md says to set it when antivirus blocks `loader_test`, so a contributor who followed that advice gets a failing test. The second half of `runtime/test/check_tls_index0.cmake` points `TMP` and `TEMP` at a missing folder, so the home clone of `gta6rt_tls_host.dll` cannot be written and `--run` and `--init` must refuse the image. But `tls_host_clone_dir()` (`runtime/src/pe_loader.cpp`) reads `LEONIDA_TEST_DIR` before `TMP` and `TEMP`. That lookup is deliberate (`f0bd98bef`, TEST-TEMPDIR-STRIPPED-ENV). With the variable set, the clone is written there, the reservation succeeds, and the script fails with `--run without the reservation returned 0`. The change is test-only: the script's failed-reservation commands, the emulator probe included, now run with `LEONIDA_TEST_DIR` unset (`cmake -E env --unset=LEONIDA_TEST_DIR ...`). With the variable unset, nothing changes. The first half still honours the variable, which is its purpose. The claim said the commands would point `LEONIDA_TEST_DIR` at the missing folder. I unset it instead. Setting it would exercise the variable's branch in the loader, not the `TMP`/`TEMP` → `GetTempPathW` path this test is about, and it would change what the Wine probe sees. ### Tested On `main` `f4b0404e9`, Windows 11, same build, `ctest -R "^(run_tiny_tls_ga|loader_tls_index0)"`: | Script | `LEONIDA_TEST_DIR` | `run_tiny_tls_ga` | |---|---|---| | `main` | set | fails (`--run without the reservation returned 0`) | | `main` | unset | passes | | this change | set | passes | | this change | unset | passes | - The three `loader_tls_index0*` tests pass in all four runs. - `python -I scripts/check_no_game_data.py`: clean, on the whole tree. - An independent read-only reviewer agent approved: - The diagnosis and the `-E env --unset` usage are right (`--unset` exists since CMake 3.1; the runtime requires 3.24). - A test-side fix is the right place. - The Wine SKIP logic is unchanged. - Not tested: Wine or Linux. Under an emulator the probe now depends only on whether `TMP`/`TEMP` reach `GetTempPathW`, which is what its comment describes. GPUs tested: n/a (no GPU involved) AI-assisted: yes. Claude Code with Claude Fable 5.2 wrote the change. A separate read-only reviewer agent on Claude Opus 5.5 reviewed it. ### Follow-up (not in this pull request) `runtime/test/check_tls_clone_cleanup.cmake` (`run_tiny_tls_clone_cleanup`) looks for clone files only in `TMP` or `TEMP`. With `LEONIDA_TEST_DIR` set, the loader writes them elsewhere, so both globs find nothing and the test passes without checking anything. Reported as a `finding:` in the coordination issue. ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
That half points TMP and TEMP at a missing folder so the home clone of gta6rt_tls_host.dll
cannot be written and --run and --init must refuse the image. But tls_host_clone_dir()
reads LEONIDA_TEST_DIR before TMP and TEMP, so with that variable set (AGENTS.md says to set
it when antivirus blocks loader_test) the clone was written, the reservation succeeded and
the test failed with "--run without the reservation returned 0".

The script's failed-reservation commands, the emulator probe included, now run with
LEONIDA_TEST_DIR unset. Test-only; with the variable unset nothing changes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
First-time contributor

Verified at the script level with a stub loader. The run_tiny_tls_ga CTest itself was not run: no MSVC toolchain on this host, so gta6rt cannot be built here.

What was run. runtime/test/check_tls_index0.cmake from the PR head (2c2bfb87) and from the merge base (f4b0404e), with a stub LOADER (gcc 16.2.0, mingw) that models the loader's documented precedence: the home clone goes to LEONIDA_TEST_DIR when it is set and writable, otherwise to TMP; a missing folder fails the reservation, with the reason text, exit codes and --dry-run note the script asserts. GUEST is a dummy file, RUNNER empty, TRACE_DIR a scratch folder.

Result — with LEONIDA_TEST_DIR pointing at an existing folder:

  • base script: --run without the reservation returned 0 (stub wrote the clone to LEONIDA_TEST_DIR, the reservation succeeded, the half asserted nothing) — exit 1.
  • PR script: exit 0.
  • both scripts with LEONIDA_TEST_DIR unset: exit 0 (controls).

So the base half is defeated by exactly the caller the comment in the diff names (the AGENTS.md antivirus workaround), and the --unset=LEONIDA_TEST_DIR on the cmake -E env calls closes it. cmake -E env --unset=NAME is supported by the project's minimum CMake (3.24; the flag is documented as --modify NAME=unset: and carries no version gate), and it was exercised here by cmake 4.5.1.

gcc -O2 -o stub.exe stub.c
$env:LEONIDA_TEST_DIR = "...\clone-ok"
cmake -DLOADER=stub.exe -DGUEST=tiny_tls_ga.exe -DTRACE_DIR=trace -DRUNNER= -P base.cmake        # exit 1, "--run without the reservation returned 0"
cmake -DLOADER=...\stub.exe -DGUEST=... -DTRACE_DIR=... -DRUNNER= -P runtime/test/check_tls_index0.cmake   # exit 0

git diff --check on 2c2bfb87: clean. scripts/check_no_game_data.py runtime/test/check_tls_index0.cmake: clean.

Limits. The stub is a model of tls_host_clone_dir, not the loader: the real reason string, GetTempPathW, and the CTest path stay unproven on this host. Everything above is script-and-stub evidence, not run_tiny_tls_ga output.

AI-assisted (Hy4 flash). GPU: RTX 5060 Laptop (driver 621.40) and Radeon 780M present, unused by this test. No game data used or needed.

Verified at the script level with a stub loader. The `run_tiny_tls_ga` CTest itself was **not** run: no MSVC toolchain on this host, so `gta6rt` cannot be built here. **What was run.** `runtime/test/check_tls_index0.cmake` from the PR head (2c2bfb87) and from the merge base (f4b0404e), with a stub `LOADER` (gcc 16.2.0, mingw) that models the loader's documented precedence: the home clone goes to `LEONIDA_TEST_DIR` when it is set and writable, otherwise to `TMP`; a missing folder fails the reservation, with the reason text, exit codes and `--dry-run` note the script asserts. `GUEST` is a dummy file, `RUNNER` empty, `TRACE_DIR` a scratch folder. **Result** — with `LEONIDA_TEST_DIR` pointing at an existing folder: - base script: `--run without the reservation returned 0` (stub wrote the clone to `LEONIDA_TEST_DIR`, the reservation succeeded, the half asserted nothing) — exit 1. - PR script: exit 0. - both scripts with `LEONIDA_TEST_DIR` unset: exit 0 (controls). So the base half is defeated by exactly the caller the comment in the diff names (the AGENTS.md antivirus workaround), and the `--unset=LEONIDA_TEST_DIR` on the `cmake -E env` calls closes it. `cmake -E env --unset=NAME` is supported by the project's minimum CMake (3.24; the flag is documented as `--modify NAME=unset:` and carries no version gate), and it was exercised here by cmake 4.5.1. ```powershell gcc -O2 -o stub.exe stub.c $env:LEONIDA_TEST_DIR = "...\clone-ok" cmake -DLOADER=stub.exe -DGUEST=tiny_tls_ga.exe -DTRACE_DIR=trace -DRUNNER= -P base.cmake # exit 1, "--run without the reservation returned 0" cmake -DLOADER=...\stub.exe -DGUEST=... -DTRACE_DIR=... -DRUNNER= -P runtime/test/check_tls_index0.cmake # exit 0 ``` `git diff --check` on 2c2bfb87: clean. `scripts/check_no_game_data.py runtime/test/check_tls_index0.cmake`: clean. **Limits.** The stub is a model of `tls_host_clone_dir`, not the loader: the real reason string, `GetTempPathW`, and the CTest path stay unproven on this host. Everything above is script-and-stub evidence, not `run_tiny_tls_ga` output. AI-assisted (Hy4 flash). GPU: RTX 5060 Laptop (driver 621.40) and Radeon 780M present, unused by this test. No game data used or needed.
Sign in to join this conversation.
No description provided.