Skip to content

util: Port os_mkdirs to obs-util - #1446

Merged
zackees merged 2 commits into
obs-rust:masterfrom
swilk19:port/platform-mkdirs
Oct 19, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
swilk19:port/platform-mkdirs

Conversation

@swilk19

@swilk19 swilk19 commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Refs #262 (slice 4, directories).

Stacked: builds on #1445 (the verbatim move into platform-mkdirs.c). Review only the top two commits (RED, GREEN). I'll rebase onto master once #1445 merges.

RED (util: Test os_mkdirs against a Rust stub): rust/obs-util/src/platform_mkdirs.rs with a todo!() core and the C ABI shim in ffi/platform_mkdirs.rs, over the already-ported os_mkdir (now re-exported from the platform boundary as platform::mkdir). All ten Tier 1 cases fail on todo!("os_mkdirs port"). The parity cases abort when the panic crosses the extern "C" shim.

  • Tier 1 (tests/platform/platform_mkdirs.rs): 1:1 port of test_platform_mkdirs.c against the safe core, plus the empty path and a 32-level chain.
  • Tier 3 (tests/platform/platform_mkdirs_parity.rs): nested/existing, separator, trailing-slash, file-in-the-way and non-ASCII call sequences against the real platform-mkdirs.c compiled as oracle_os_mkdirs. The two sides run in separate scratch trees (each with the same regular file f), 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.
  • Tier 2: ENABLE_RUST_LIBOBS=ON drops util/platform-mkdirs.c (moved into libobs.ported-platform); export in rust-exports.d/obs-util-platform_mkdirs.txt.

GREEN (util: Port os_mkdirs to obs-util): the core follows the C step for step. \ becomes /. Then recursive_mkdir tries the path; on MKDIR_ERROR it 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 dir returns MKDIR_ERROR; the parity test does not compare those two inputs with the C.

Local checks:

  • Tier 2 (rust/tools/linux-validate/run.sh): 308/308 cmocka tests against both libobs and libobs-with-rust, test_platform* repeated 3× in each, exported symbols C vs Rust IDENTICAL (1766).
  • soldr cargo test --workspace --locked green; obs-util 578/578.
  • Windows (xwin, MSVC target): all 18 mkdirs tests pass. Full obs-util has the same 9 WSL-only failures as master (pipe windows_process cases, test_get_abs_path_ptr_dot, filesystem_matches_the_c_file: UNC working directory and interop spawns).
  • clippy (host, x86_64-pc-windows-msvc, aarch64-apple-darwin), rustfmt and the Dylints are clean.
  • 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.

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

@swilk19
swilk19 marked this pull request as ready for review October 19, 2026 00:36
@swilk19
swilk19 requested a review from zackees as a code owner October 19, 2026 00:36

@zackees zackees left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@zackees
zackees added this pull request to the merge queue Oct 19, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 19, 2026
@zackees
zackees added this pull request to the merge queue Oct 19, 2026
@zackees
zackees removed this pull request from the merge queue due to a manual request Oct 19, 2026
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]>
@zackees
zackees force-pushed the port/platform-mkdirs branch from d1fb36e to d0c4c23 Compare October 19, 2026 01:12
@zackees

zackees commented Oct 19, 2026

Copy link
Copy Markdown
Member

Coordinator: this was ejected from the merge queue (failed_checks). #1445 merged as a squash commit, and this branch still carried #1445's original commit 345b7402d. In the merge-group result, platform-mkdirs.c.h ended up in both libobs.platform and libobs.ported-platform, so test_build_groups failed and libobs linked it twice.

I rebased only the RED and GREEN commits onto master (git rebase --onto origin/master 345b7402d), now at d0c4c23b5. The file is now only in the ported group, and ci/test_build_groups.py passes locally. Auto-merge is back on.

@zackees
zackees enabled auto-merge October 19, 2026 01:12
@zackees
zackees added this pull request to the merge queue Oct 19, 2026
Merged via the queue into obs-rust:master with commit d5101a9 Oct 19, 2026
25 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.

2 participants