Skip to content

test: Keep the module path proptests inside their own tree - #1918

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/module-paths-proptest-tmp
Oct 23, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/module-paths-proptest-tmp

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1917

What and why

find_matches_c_for_any_path (rust/obs-core/tests/obs_core/module_paths_parity.rs, from #1894) searches <root>/<random path>, and a random path's .. can climb above the tree's root. For a bin such as ..%module%LIB the search lists <root>/.., which was the system temporary directory itself. The shim and the C oracle list it at slightly different moments, so any other process creating or removing an entry there in between (including the trees of the other tests in the same binary) makes the two results differ, although both sides are correct.

  • The tree's entries now sit ABOVE_ROOT (5) levels of up/ below a new directory of the test's own in the temporary directory, which Tree removes on drop. Every directory a random path can reach by climbing is the test's own, and each level above the root holds only up/, so both sides list the same entries however busy the temporary directory is.
  • The bound is by construction, not rejection: a piece has at most two dots and no piece has both a dot and a /, so each climbing .. takes a piece and a separator piece before it; a path of at most MAX_PIECES (9, as before) pieces climbs at most MAX_PIECES.div_ceil(2) = 5 levels. No case is discarded.
  • levels_above_root() counts how far a path climbs, over the path with %module% replaced by a name (what the search stats) and over the part before the first %module% (the directory it lists). find_matches_c_for_any_path asserts the bound on bin and data, and the new climbing_above_the_root_stays_in_the_tree checks the pieces' two properties, the worst case, and that ABOVE_ROOT levels above the root is the test's own directory holding only the way down. Adding a piece such as "../.." fails that test at once.
  • Unchanged: the fixed cases, the pieces, the path length, and 2048 cases per proptest. The proptests still cover .., including climbing above the root, now into the test's own directories. The comparison itself is the same, so this does not change what the test accepts.

RED → GREEN

  • RED commit: 60fc779 test: Check how far module path proptests climb above their tree. climbing_above_the_root_stays_in_the_tree fails every run: five levels above the tree is /, not the test's directory (11 passed, 1 failed in obs_core::module_paths_parity). The flake itself on master (2348fa5), TMPDIR unset, cargo test -p obs-data --test obs-tests-core obs_core::module_paths_parity, proptest regression file removed before each run:
    • with a loop creating and deleting files in /tmp (while :; do touch /tmp/flake-$$-$RANDOM; rm -f /tmp/flake-$$-*; done): 20 of 20 runs fail in find_matches_c_for_any_path; minimal inputs such as bin = ".." (12 runs) and bin = "..%module%...";
    • without the loop: 17 of 20 runs fail (the other tests' trees come and go in the same directory).
  • GREEN: c2365b6. Same command, same loop running: 80 of 80 runs pass (50 on the change before formatting, 30 on the final commit); 20 of 20 without the loop. obs_core::module_paths_parity: 12 passed. uv run ci/local_gate.py --lane lint ok (fmt, clippy -D warnings), --lane cross ok.
  • Real app (UI, protocol output or logging changes): N/A, test-only change.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: its line in docs/features.md is added or updated (not applicable: no user-visible change)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite (lint and cross lanes passed locally; not stamped)
  • Warning or flag changes (-W..., ratchets): none
  • Intentional differences from C listed in the parity test header and rust/README.md (ports): none changed

find_matches_c_for_any_path searches <root>/<random path>, and a random
path's ".." can climb above the tree's root: for "..%module%" the search
lists <root>/.., the system temporary directory itself. The shim and the
oracle list it at different moments, and any other process (or another
test's tree) adding or removing an entry in between makes them differ.

levels_above_root() counts how many levels above the root a path climbs,
over the path with %module% replaced by a name (what the search stats)
and over the part before the first %module% (the directory it lists).
The pieces have at most two dots and none has both a dot and a '/', so a
path of MAX_PIECES (9, as before) pieces climbs at most ABOVE_ROOT = 5
levels. find_matches_c_for_any_path asserts that bound on bin and data;
climbing_above_the_root_stays_in_the_tree checks the pieces, the worst
case, and that ABOVE_ROOT levels above the root is the tree's own
directory holding only the way down.

The tree still sits directly in the temporary directory, so the last
check fails: five levels above it is not the tree's.

Refs obs-rust#1917
Tree now makes its entries ABOVE_ROOT (5) levels of up/ below a new
directory in the temporary directory, and removes that directory on
drop. Whatever a random path's ".." reaches is the test's own: each
level above the root holds only up/, so the shim and the oracle list the
same entries however busy the temporary directory is.

The fixed cases, the 2048 cases of each proptest and the pieces are
unchanged; the proptests still climb above the root, now into the
test's own directories.

Fixes obs-rust#1917
@rdoupe
rdoupe requested a review from zackees as a code owner October 23, 2026 08:22
@zackees
zackees added this pull request to the merge queue Oct 23, 2026
Merged via the queue into obs-rust:master with commit 243c03f Oct 23, 2026
30 checks passed
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.

test: module_paths_parity find_matches_c_for_any_path can list the system temp dir and flake

2 participants