tests: link the running interpreter in the GuestWatch test #675

Open
gtb-sbe wants to merge 1 commit from upstream-pr/675 into main
gtb-sbe commented 2026-12-03 14:21:38 +00:00 (Migrated from github.com)

Imported from brcly/TuxBox. Originally posted by gtb-sbe on 2026-12-03T14:21:38Z.


Problem

GuestWatch.test_a_guest_that_died_stops_the_sandbox_instead_of_waiting_out_the_timeout fails on every check --no-gpu I run on NixOS, inside the repository's own dev shell:

AssertionError: 0 != 'guest gone'

The test links os.path.realpath(sys.executable) as stage-baseline.exe and expects the kernel to name the process after the link. In the flake's dev shell, sys.executable is nixpkgs' python3.withPackages wrapper, a small binary that execvs the real interpreter in another store path. That exec renames the process to python3.12, so watch_guest never sees a stage-baseline process, waits out the 60 s sleep, and returns the shell's exit status.

Change

Link /proc/self/exe, the binary that is actually running, instead of sys.executable. Outside such wrappers both resolve to the same file. The test already relies on /proc (process_states).

Testing

On my machine (NixOS, Python 3.12.16):

  • python -m unittest tests.test_stage_baseline in the flake's dev shell: 14 tests OK (1 skipped), 2.2 s. Before: 1 failure after 62 s.
  • The same module with a python3.withPackages wrapper and with plain unwrapped nixpkgs Python plus pefile: OK both times.
  • python tuxbox.py check --no-gpu: 13 passed, 0 failed (Evidence: TuxBox check of ed039b3b2d79, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run). No GPU checks, since the change only touches a Python test.

AI use

I made this branch with an AI coding agent (Claude Code, following AGENTS.md). The agent found the cause (the nixpkgs wrapper's execv), wrote the change, and ran the tests and checks listed above on my machine.

<!-- greyfinch-sync:brcly/TuxBox:issue:5628339146 --> Imported from [brcly/TuxBox](https://github.com/brcly/TuxBox/pull/675). Originally posted by [gtb-sbe](https://github.com/gtb-sbe) on 2026-12-03T14:21:38Z. --- ## Problem `GuestWatch.test_a_guest_that_died_stops_the_sandbox_instead_of_waiting_out_the_timeout` fails on every `check --no-gpu` I run on NixOS, inside the repository's own dev shell: ``` AssertionError: 0 != 'guest gone' ``` The test links `os.path.realpath(sys.executable)` as `stage-baseline.exe` and expects the kernel to name the process after the link. In the flake's dev shell, `sys.executable` is nixpkgs' `python3.withPackages` wrapper, a small binary that `execv`s the real interpreter in another store path. That exec renames the process to `python3.12`, so `watch_guest` never sees a `stage-baseline` process, waits out the 60 s `sleep`, and returns the shell's exit status. ## Change Link `/proc/self/exe`, the binary that is actually running, instead of `sys.executable`. Outside such wrappers both resolve to the same file. The test already relies on `/proc` (`process_states`). ## Testing On my machine (NixOS, Python 3.12.16): - `python -m unittest tests.test_stage_baseline` in the flake's dev shell: 14 tests OK (1 skipped), 2.2 s. Before: 1 failure after 62 s. - The same module with a `python3.withPackages` wrapper and with plain unwrapped nixpkgs Python plus pefile: OK both times. - `python tuxbox.py check --no-gpu`: 13 passed, 0 failed (`Evidence: TuxBox check of ed039b3b2d79, no uncommitted changes, no GPU checks: 13 passed, 0 failed, 0 not run`). No GPU checks, since the change only touches a Python test. ## AI use I made this branch with an AI coding agent (Claude Code, following `AGENTS.md`). The agent found the cause (the nixpkgs wrapper's `execv`), wrote the change, and ran the tests and checks listed above on my machine.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/675:upstream-pr/675'
git switch 'upstream-pr/675'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/675'
git switch 'upstream-pr/675'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/675'
git switch 'upstream-pr/675'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/675'
git switch 'main'
git merge --squash 'upstream-pr/675'
git switch 'main'
git merge --ff-only 'upstream-pr/675'
git switch 'main'
git merge 'upstream-pr/675'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
brcly/TuxBox!675
No description provided.