Skip to content

test(cmocka): Run the PipeWire context-failure harness from Python (#962) - #2619

Merged
zackees merged 3 commits into
masterfrom
infra/962-gen-005-pipewire-context-fail-python
Oct 27, 2026
Merged

zackees merged 3 commits into
masterfrom
infra/962-gen-005-pipewire-context-fail-python

Conversation

@zackees

@zackees zackees commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

GEN-005 burn-down, one unit: test/cmocka/test_pipewire_context_fail.sh (70 lines) → test/cmocka/test_pipewire_context_fail.py, with its [[exceptions]] block removed from ci.toml (Refs #962).

  • RED 99e693be4 — new ci/test_pipewire_context_fail.py drives the ported module by path with a stub pipewire on PATH (one that binds the daemon socket, one that exits at once) and a stub test binary that records its environment, cwd and argv. On the unfixed tree the module does not exist, so the module cases error and the wiring case fails: 10 tests → 8 failures + 2 errors.
  • GREEN d622c821f — the module, the shell deleted, the exception gone. 10 tests → OK.
  • Consumer fix 91678412b — test/cmocka/test_pipewire_wrapper.sh ran the deleted shell as a control; it now drives the ported module (uv run --script), and ci/test_pipewire_context_fail.py pins that wiring. No CI lane installs pipewire, so PR CI cannot see this; it would fail on a dev machine.

(SHAs re-stated after a rebase onto origin/master at 4d10528e4.)

Why this unit is contained

The shell has exactly one caller, test/cmocka/tests.d/test_pipewire_context_fail.cmake, and the tree already has the Python shape for a cmocka wrapper: test/cmocka/tests.d/test_pulse_default_follow.cmake runs uv run --script .../test_pulse_pulseaudio.py. The caller therefore keeps its interpreter (the cmocka tests run where uv is on PATH) and no workflow, container image or package list changes.

The port

The shell's steps keep their order and meaning:

  1. DISPLAY, WAYLAND_DISPLAY, HYPRLAND_INSTANCE_SIGNATURE, both DBus bus addresses and the PIPEWIRE_* variables are unset.
  2. A mktemp -d runtime directory, remade under /tmp when len(dir) + 23 > 107: the daemon's longest socket path (<dir>/run/pipewire-0-manager) must fit a Unix socket address, and a deep TMPDIR (a build tree) does not.
  3. XDG_RUNTIME_DIR, XDG_CONFIG_HOME, XDG_STATE_HOME and HOME under that directory.
  4. When pipewire is on PATH: write the minimal daemon config (native protocol + access module only; support.dbus = false; no realtime/X11 modules, no session manager, no devices), start the daemon with PIPEWIRE_CONFIG_DIR and PIPEWIRE_RUNTIME_DIR as command prefixes (the shell's FOO=bar cmd &, so the test binary does not inherit PIPEWIRE_CONFIG_DIR), wait up to 200 × 0.1 s for <runtime>/pipewire-0 to be a socket, and fail with private pipewire did not start: plus the log when a daemon that is installed does not come up. Without pipewire: print that the control case will skip.
  5. Run the test binary and exit with its status; kill the daemon and remove the directory either way.

Deliberate differences

  • A usage error (exit 2) when the test binary argument is missing. The shell had only the usage comment and would run ""; this can never fire from the cmake caller.
  • test/cmocka/test_pipewire_context_fail.c's doc comment now names the Python file. Comment only: no assertion, include or linkage changed.

Checks (local)

  • ./lint (clang-format, gersemi, rustfmt, clippy, Dylints): ok.
  • uv run --no-project ci/local_gate.py --only self-test (the whole ci/ self-test lane, new suite included): ok.
  • ci/test_uv_run.py, ci/test_tool_guard.py, ci/test_ci_scope.py: ok.

No user-visible change, so docs/features.md has no line. No submodule pointer change.

@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Handed off to the coordinator.

Local evidence before the handoff: ./lint (clang-format, gersemi, rustfmt, clippy, Dylints) ok; uv run --no-project ci/local_gate.py --only self-test ok (the new ci/test_pipewire_context_fail.py included); ci/test_uv_run.py, ci/test_tool_guard.py, ci/test_ci_scope.py ok; ci-lint precheck 560 → 559 approved exceptions with no new violation or needs_review.

HEAD is not stamped with the local gate, so PR CI runs the full suite rather than the Linux jobs skipping; auto-merge is on and waits for it. The change touches no workflow, no container image and no package list.

…962)

RED: ci/test_pipewire_context_fail.py drives the ported module by path with a
stub `pipewire` on PATH (one that binds the daemon socket, one that exits at
once) and a stub test binary that records the environment, the cwd and the argv
it was handed. On the unfixed tree the module does not exist, so the module
cases error and the wiring case fails: 10 tests -> 8 failures + 2 errors.

Refs #962
GREEN: test/cmocka/test_pipewire_context_fail.py is the port of
test/cmocka/test_pipewire_context_fail.sh, which is deleted, and its GEN-005
exception is removed from ci.toml. The shell's only caller,
test/cmocka/tests.d/test_pipewire_context_fail.cmake, runs the module through
"uv run --script" -- the shape test_pulse_default_follow.cmake already uses for
test_pulse_pulseaudio.py -- so the caller keeps its interpreter and no workflow
changes.

The shell's steps keep their order and meaning: the display/DBus/PipeWire
variables are unset; mktemp-style runtime directory that moves to /tmp when
len(dir) + len("/run/pipewire-0-manager") > 107 (a deep TMPDIR cannot hold the
daemon's socket); XDG_RUNTIME_DIR/XDG_CONFIG_HOME/XDG_STATE_HOME/HOME under it;
when pipewire is on PATH, its minimal configuration (native protocol and access
module only, support.dbus = false) is written and the daemon starts with
PIPEWIRE_CONFIG_DIR/PIPEWIRE_RUNTIME_DIR as command prefixes -- not exports, as
in the shell -- and the test waits up to 200 x 0.1 s for the socket, failing
with "private pipewire did not start:" and the log when a daemon that is
installed does not come up; without pipewire it prints that the control case
will skip; then the test binary runs and its status is the exit status, with the
daemon killed and the directory removed either way.

The one deliberate addition is a usage error (exit 2) for a missing test
binary, where the shell had only the usage comment. The module's doc comment in
test_pipewire_context_fail.c now names the Python file; no assertion changed.

Refs #962
test_pipewire_wrapper.sh ran test_pipewire_context_fail.sh as a control; the
port renames that to test_pipewire_context_fail.py, so the wrapper test would
fail on a machine with pipewire installed (CI installs none, so PR CI cannot
see it). Drive each wrapper with the interpreter it now uses, and pin the
wiring in ci/test_pipewire_context_fail.py.
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Heads-up from a parallel worker: this PR deletes test/cmocka/test_pipewire_context_fail.sh, but test/cmocka/test_pipewire_wrapper.sh still runs it — its loop for wrapper in test_pipewire_cursor_hdr.py test_pipewire_context_fail.sh; do ... sh "$scripts/$wrapper" ... and its PulseAudio branch. So once master carries this PR, the wrapper test would sh a deleted file (it fails only where pipewire is installed, i.e. locally and any PipeWire lane — CI's Tier 2 cmocka lane skips it, so PR CI could stay green with the reference dangling).

For reference, the sibling port of test_pipewire_cursor_hdr.sh (#2620) had to do the same wrapper edit; its change to that loop is exactly this shape — run the .py entry through uv run --script (resolved by absolute path so the stub PATH still reaches uv) and leave the still-shell entries on sh.

@zackees
zackees force-pushed the infra/962-gen-005-pipewire-context-fail-python branch from fb4d0a8 to 9167841 Compare October 27, 2026 12:38
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Rebased onto origin/master (4d10528e4) after a self-review found a consumer the port missed.

test/cmocka/test_pipewire_wrapper.sh drove test_pipewire_context_fail.sh as a control (long-TMPDIR and dying-daemon cases). With the shell deleted it would read a missing file and fail — on any machine with pipewire installed. CI installs none (the wrapper test exits 77 at the top), so PR CI cannot see it. Fixed in 91678412b: each wrapper now runs through the interpreter it uses (uv run --script for the ported module, sh for the others), and ci/test_pipewire_context_fail.py's wiring case asserts the sibling test names the .py and no longer the .sh.

SHAs after the rebase: RED 99e693be4, GREEN d622c821f, consumer fix 91678412b.

Local: ./lint ok; ci/test_pipewire_context_fail.py 10 tests ok; ci/test_uv_run.py, ci/test_tool_guard.py ok.

@zackees zackees left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the head 91678412b. Verdict: correct, and the port keeps the coverage the shell had. Queueing it.

Verified by running, not by reading (in a worktree at the PR head):

  • uv run --no-project ci/test_pipewire_context_fail.py → Ran 10 tests … OK.
  • The same file copied into a worktree at origin/master → FAILED (failures=8, errors=2). That is the RED state, and it is the new gate test that produces it, so RED → GREEN is real and not asserted.
  • ci/test_uv_run.py → OK, and ci/test_ci_toml.py → OK, so the GEN-005 exception removal in ci.toml matches the set of shell files that remain and the new module's #!/usr/bin/env -S uv run --script satisfies TOOL-003.
  • The test_pipewire_wrapper.sh consumer the earlier commit missed is handled the right way: the loop carries the interpreter per wrapper (uv run --script for the .py, sh for the rest) instead of dropping the case, so the long-TMPDIR and daemon-dies-at-once checks still cover the harness.
  • test_pipewire_context_fail.py moves the runtime dir to /tmp when <dir>/run/pipewire-0-manager would exceed 107 bytes and fails with the daemon's log instead of skipping, which is stronger than the shell's behaviour and is covered by test_a_deep_tmpdir_falls_back_to_tmp and test_a_daemon_that_does_not_come_up_fails_with_its_log.

One nit, not blocking: in test_pipewire_wrapper.sh the runner is stored as a string and expanded unquoted (runner="uv run --script $scripts/$wrapper", then timeout 60 $runner …). The word splitting is wanted here, but it also splits a $scripts path containing a space. set -- uv run --script "$scripts/$wrapper" (and set -- sh "$scripts/$wrapper") would keep both properties.

One note for the record: with pipewire absent the harness now exits 0 and the control case skips inside the C test, where the shell wrapper exited 77 and ctest recorded a skip. That is the intended improvement (the failure cases run in CI instead of the whole test skipping), and test_a_missing_pipewire_skips_the_control_case_and_passes_the_status_through pins it — it just means the Tier 2 job report will no longer show this test as skipped.

No docs/features.md line needed: CI tooling only.

@zackees
zackees added this pull request to the merge queue Oct 27, 2026
@zackees

zackees commented Oct 27, 2026

Copy link
Copy Markdown
Member Author

Tier 2 Linux is green on the rebased head 91678412b — all six Tier 2 jobs pass (including tests OFF, the one that failed on the pre-rebase head at test_pipewire_wrapper), plus Fast Gate, Format and CI Gate ✅. Auto-merge is on; handing back to the coordinator.

Merged via the queue into master with commit 2c9ebf3 Oct 27, 2026
36 checks passed
@zackees
zackees deleted the infra/962-gen-005-pipewire-context-fail-python branch October 27, 2026 12:57
zackees added a commit that referenced this pull request Oct 27, 2026
…2619 rebase (#962)

#2619 landed the context-failure harness in Python, so both private-PipeWire
wrappers are Python now. The wrapper test's loop runs both through
`uv run --script` — the literal its sibling `ci/test_pipewire_context_fail.py`
pins — instead of the per-extension `$runner` case, whose `$uv --script` form
uv rejected (it is a `uv run` flag). The no-pipewire control still uses the
absolute `$uv`, because it runs with a stripped PATH and would not find uv
otherwise.

Refs #962.
MCPVOT pushed a commit to MCPVOT/obs-studio that referenced this pull request Oct 30, 2026
…bs-rust#2620)

* test(ci): pin the private-PipeWire-dir harness in Python (obs-rust#962)

RED: ci/test_pipewire_cursor_hdr.py drives test/cmocka/test_pipewire_cursor_hdr.py
by path with stub Xvfb-style stubs (a stub pipewire that binds the socket, one
that dies at once, and a test-binary stub that captures its env/cwd/argv) and
pins the wiring: the shell gone, its GEN-005 exception gone, the ctest callers
running the Python through uv run --script. It fails on master (the module does
not exist and the shell is still there).

* ci: Port the private-PipeWire-dir harness to Python (obs-rust#962)

GREEN: port test/cmocka/test_pipewire_cursor_hdr.sh (the private PipeWire
daemon wrapper the camera/screencast cmocka tests and the wrapper test run
through) to test/cmocka/test_pipewire_cursor_hdr.py, and delete the shell.

- the twelve ctest callers in test/cmocka/tests.d/*.cmake run it through
  `uv run --script` (the shell's callers all reach Python: they are ctest
  entries on the Linux runners and the Tier 2 image, both of which carry uv);
- test/cmocka/test_pipewire_wrapper.sh runs the Python wrapper the same way,
  with uv by absolute path so its stub PATH still reaches it;
- the stub-skip messages in the camera/screencast tests name the .py now;
- the GEN-005 exception for the .sh is removed (ci-lint precheck: 560 -> 559
  approved exceptions, 23 violations unchanged).

* style(cmocka): gersemi-format the PipeWire test entries (obs-rust#962)

The lint lane (ci/local_gate.py --lane lint) runs gersemi over the
changed .cmake files and the multi-line COMMAND in the ten ported
PipeWire test entries needed wrapping; `./lint --fix` produced this.

Refs obs-rust#962.

* test(cmocka): run both wrappers through `uv run --script` after the obs-rust#2619 rebase (obs-rust#962)

obs-rust#2619 landed the context-failure harness in Python, so both private-PipeWire
wrappers are Python now. The wrapper test's loop runs both through
`uv run --script` — the literal its sibling `ci/test_pipewire_context_fail.py`
pins — instead of the per-extension `$runner` case, whose `$uv --script` form
uv rejected (it is a `uv run` flag). The no-pipewire control still uses the
absolute `$uv`, because it runs with a stripped PATH and would not find uv
otherwise.

Refs obs-rust#962.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant