9e597a8f98e918d3c118943293cc7f45ec37768a braney Tue Sep 8 10:12:21 2026 -0700 lib/tests: add pathSimplifyTest, covering path canonicalization Covers eatSlashSlashInPath and eatExcessDotsInPath, which had no test. The test has two halves. The first prints the canonical form of 41 named paths and the makefile diffs that against expected/, so a change in behavior shows up as a diff. Those paths include the cases from #37263: a ".." that climbs out of a relative path, a "." next to a "..", and a ".." at the root of an absolute path. The second half enumerates every path over the alphabets "/.a" up to length 9 and "/.ab" up to length 7, 51369 in all, and compares the answer against a reference written inside the test. The reference builds a stack of components instead of walking one buffer with two pointers, so the two are unlikely to share a mistake. Only the count and the number of disagreements go in the expected file, which keeps it small while the check stays broad. A test that cannot fail is worth nothing, so this was checked against the version of osunix.c from before the fix: it reports 32 differing named lines and 1949 disagreements with the reference there, and none against the current code. refs #37263 diff --git src/lib/tests/expected/pathSimplifyTest src/lib/tests/expected/pathSimplifyTest new file mode 100644 index 00000000000..2cf8eb7a0ba --- /dev/null +++ src/lib/tests/expected/pathSimplifyTest @@ -0,0 +1,41 @@ + -> +a -> a +a/b -> a/b +/ -> / +/a/b -> /a/b +a/ -> a +a/b/ -> a/b +/a/ -> /a +. -> . +./ -> . +./a -> a +a/. -> a +a/./b -> a/b +/a/./b -> /a/b +a/.. -> . +a/../ -> . +a/../b -> b +/a/.. -> / +/a/../b -> /b +a/b/.. -> a +a/b/../c -> a/c +a/../b/../c -> c +a/../b/../c/.. -> . +/a/../b/../c/.. -> / +x/./../y -> y +.. -> .. +../ -> .. +../.. -> ../.. +../a -> ../a +../../a -> ../../a +a/../../b -> ../b +h/../../../etc/passwd -> ../../etc/passwd +/.. -> / +/../a -> /a +/a/../../b -> /b +/../../a -> /a +// -> / +//../ -> / +a//b///c -> a/b/c +a/b/// -> a/b +enumerated 51369 paths, 0 disagree with the reference