Repository navigation
test: Keep the module path proptests inside their own tree - #1918
Merged
Merged
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 abinsuch as..%module%LIBthe 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.ABOVE_ROOT(5) levels ofup/below a new directory of the test's own in the temporary directory, whichTreeremoves on drop. Every directory a random path can reach by climbing is the test's own, and each level above the root holds onlyup/, so both sides list the same entries however busy the temporary directory is./, so each climbing..takes a piece and a separator piece before it; a path of at mostMAX_PIECES(9, as before) pieces climbs at mostMAX_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_pathasserts the bound onbinanddata, and the newclimbing_above_the_root_stays_in_the_treechecks the pieces' two properties, the worst case, and thatABOVE_ROOTlevels above the root is the test's own directory holding only the way down. Adding a piece such as"../.."fails that test at once..., 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
test: Check how far module path proptests climb above their tree.climbing_above_the_root_stays_in_the_treefails every run: five levels above the tree is/, not the test's directory (11 passed, 1 failed inobs_core::module_paths_parity). The flake itself on master (2348fa5),TMPDIRunset,cargo test -p obs-data --test obs-tests-core obs_core::module_paths_parity, proptest regression file removed before each run:/tmp(while :; do touch /tmp/flake-$$-$RANDOM; rm -f /tmp/flake-$$-*; done): 20 of 20 runs fail infind_matches_c_for_any_path; minimal inputs such asbin = ".."(12 runs) andbin = "..%module%...";obs_core::module_paths_parity: 12 passed.uv run ci/local_gate.py --lane lintok (fmt, clippy-D warnings),--lane crossok.Checklist
masterdocs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): none