Repository navigation
util: Port os_mkdirs to obs-util - #1446
Conversation
zackees
left a comment
There was a problem hiding this comment.
Coordinator review: LGTM. mkdirs/recursive_mkdir match the C exactly: the \\ → / rewrite, a retry only on MKDIR_ERROR, the recursion on the prefix before the last /, an existing parent counting as done, and the result taken from the last os_mkdir (so a/b/ reports MKDIR_EXISTS, as documented). The slice replaces C's in-place NUL swap, with the same effect. Tier 1, Tier 3 parity against the oracle, and Tier 2 (the C file moves to the ported group) are all present.
Refs obs-rust#262 (slice 4, directories). rust/obs-util/src/platform_mkdirs.rs with a todo!() core and the C ABI shim in ffi/platform_mkdirs.rs for os_mkdirs, over the ported os_mkdir now re-exported from the platform boundary. - Tier 1 (tests/platform/platform_mkdirs.rs): 1:1 port of test_platform_mkdirs.c, plus the empty path and a 32-level chain. All ten cases fail on todo!("os_mkdirs port"). - Tier 3 (tests/platform/platform_mkdirs_parity.rs): nested, existing, separator, trailing-slash, file-in-the-way and non-ASCII sequences against the real platform-mkdirs.c compiled as oracle_os_mkdirs, in separate scratch trees compared entry by entry, plus a proptest over random paths. Aborts on the todo!() panic crossing the shim. - Tier 2: ENABLE_RUST_LIBOBS=ON drops util/platform-mkdirs.c (moved to libobs.ported-platform); export in rust-exports.d/obs-util-platform_mkdirs.txt. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Refs obs-rust#262 (slice 4, directories). The core follows platform-mkdirs.c step for step: '\' becomes '/', then recursive_mkdir tries the path, on MKDIR_ERROR creates everything before the last '/' and tries the path again, over the ported os_mkdir of each host (mkdir 0755 on Unix, CreateDirectoryW on Windows). On the shim, a NULL or empty dir returns MKDIR_ERROR (not compared with the C). Mutation check: skipping the '\' conversion, cutting at the first '/' instead of the last, or returning MKDIR_SUCCESS instead of retrying the full path each fails Tier 1 and Tier 3 cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
d1fb36e to
d0c4c23
Compare
|
Coordinator: this was ejected from the merge queue ( I rebased only the RED and GREEN commits onto master ( |
Refs #262 (slice 4, directories).
RED (
util: Test os_mkdirs against a Rust stub):rust/obs-util/src/platform_mkdirs.rswith atodo!()core and the C ABI shim inffi/platform_mkdirs.rs, over the already-portedos_mkdir(now re-exported from the platform boundary asplatform::mkdir). All ten Tier 1 cases fail ontodo!("os_mkdirs port"). The parity cases abort when the panic crosses theextern "C"shim.tests/platform/platform_mkdirs.rs): 1:1 port oftest_platform_mkdirs.cagainst the safe core, plus the empty path and a 32-level chain.tests/platform/platform_mkdirs_parity.rs): nested/existing, separator, trailing-slash, file-in-the-way and non-ASCII call sequences against the realplatform-mkdirs.ccompiled asoracle_os_mkdirs. The two sides run in separate scratch trees (each with the same regular filef), and the test compares return values and the resulting trees entry by entry. A proptest runs random sequences of paths built from names (including the file) and/,\,//,/\separators, with optional trailing separators.ENABLE_RUST_LIBOBS=ONdropsutil/platform-mkdirs.c(moved intolibobs.ported-platform); export inrust-exports.d/obs-util-platform_mkdirs.txt.GREEN (
util: Port os_mkdirs to obs-util): the core follows the C step for step.\becomes/. Thenrecursive_mkdirtries the path; onMKDIR_ERRORit creates everything before the last/and tries the full path again. A parent that already exists counts as done.On the shim, a NULL or empty
dirreturnsMKDIR_ERROR; the parity test does not compare those two inputs with the C.Local checks:
rust/tools/linux-validate/run.sh): 308/308 cmocka tests against bothlibobsandlibobs-with-rust,test_platform*repeated 3× in each, exported symbols C vs Rust IDENTICAL (1766).soldr cargo test --workspace --lockedgreen; obs-util 578/578.windows_processcases,test_get_abs_path_ptr_dot,filesystem_matches_the_c_file: UNC working directory and interop spawns).x86_64-pc-windows-msvc,aarch64-apple-darwin), rustfmt and the Dylints are clean.\conversion, cutting at the first/instead of the last, or returningMKDIR_SUCCESSinstead of retrying the full path each fails Tier 1 and Tier 3 cases.The
rust/obs-util/src/platform/change starts the Windows and macOS Rust and Tier 2 lanes here, which also covers #1445's move on those hosts.🤖 Generated with Claude Code