Skip to content

Make the Linux test suite pass, and run it in CI - #48

Merged
padenot merged 1 commit into
mozilla:masterfrom
zang3tsu:fix-linux-tests
Aug 10, 2026
Merged

Make the Linux test suite pass, and run it in CI#48
padenot merged 1 commit into
mozilla:masterfrom
zang3tsu:fix-linux-tests

Conversation

@zang3tsu

@zang3tsu zang3tsu commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to the discussion in #47.

The Linux/dbus test suite could never pass:

  • Without a usable rtkit-daemon, every promotion test panics — the graceful skip only existed for the native (no-dbus) build.
  • With rtkit-daemon, the suite issued 168 promotion requests by construction, but the daemon only grants 25 per 20-second window per user (--actions-per-burst-max / --actions-burst-sec), so a cold cargo test always hit "Device or resource busy" partway through. CI never caught either, because the Linux test step was disabled.

Changes:

  • The rt_scheduling_available skip-guard now covers both Linux builds and all four tests, and prints the underlying error when it skips, so a missing daemon and an exhausted budget are distinguishable.
  • The promotion tests hold a shared lock (they share the daemon's per-user budget), probe once per test, and the concurrency test promotes once per thread across 4 threads on Linux — measured usage is 16 of the 25-request budget per run, including the doctest, so a cold run passes deterministically against a stock rtkit-daemon. The other platforms have no budget and keep 32 threads. Two runs inside one 20-second window can still exhaust the shared budget; leave ~20s between consecutive local runs.
  • Checks that need no real-time permission (argument validation, thread-info serialization round trips) moved above the guards, so they run everywhere including CI.
  • The Linux CI test step is re-enabled with --nocapture so the skip notices are visible in the log. The runners do have rtkit installed (pulled in by pulseaudio's Recommends), but its polkit policy only serves processes in an active session, which a runner job is not — so the promotion tests skip themselves there while the permission-free checks run.

Verified on Arch Linux (rtkit 0.14): cold cargo test passes repeatedly with 25s spacing, exercising real promotions (16/25 requests measured in the rtkit journal); with rtkit-daemon masked, the suite passes via skips (the CI scenario).

Noticed while auditing, out of scope here: in rt_linux.rs the demotion paths test pthread_setschedparam(...) < 0, but pthread functions return 0 or a positive errno, so demotion failures on the dbus build are silently reported as success (rt_linux_native.rs gets this right with != 0).

The promotion tests now skip when the environment cannot do real-time
scheduling on both Linux builds; previously only the native (no-dbus)
build had the guard, so machines without a usable rtkit-daemon failed
every test. The guard prints the underlying error when it skips, which
distinguishes a missing daemon from an exhausted request budget.

rtkit-daemon grants at most --actions-per-burst-max (default 25)
requests per --actions-burst-sec (default 20 seconds) window per user,
and the suite issued 168 promotion requests by construction, so a cold
cargo test run could never pass against a stock daemon. The tests now
hold a shared lock, probe once per test, and the concurrency test
promotes once per thread across four threads on Linux (the other
platforms have no budget and keep 32 threads), which measures 16
requests per run including the doctest. The budget is shared with the
whole desktop session, so leave about twenty seconds between
consecutive runs.

Checks that need no real-time permission, argument validation and the
thread-info serialization round trips, moved above the guards so they
run everywhere, including CI.

CI now runs the test step on Linux too, with --nocapture so the skip
notices are visible. The runners do have rtkit installed, pulled in by
pulseaudio, but its polkit policy only serves processes in an active
session, so the promotion tests skip themselves there.

@padenot padenot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good catch, thanks a lot.

@padenot
padenot merged commit 0291454 into mozilla:master Aug 10, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants