Skip to content

Phase 2: finish cmocka suite (os_path, serializer, darray) + CI + Windows/macOS Tier 2 - #10

Merged
zackees merged 10 commits into
grind/meta-4-7c2efrom
grind/5-phase2-cmocka-suite
Oct 9, 2026
Merged

zackees merged 10 commits into
grind/meta-4-7c2efrom
grind/5-phase2-cmocka-suite

Conversation

@zackees

@zackees zackees commented Oct 8, 2026

Copy link
Copy Markdown
Member

Refs #5

Phase 2 of the Rust port testing roadmap. It finishes the existing cmocka suite (os_path, serializer, darray), adds CI, and adds Windows/macOS Tier 2.

Commits (kept separate, as #5 decides)

  1. docs(rust-port): policy first. Adds the function-extraction rule, the header-inline (static inline/macro) Tier 2 exemption, and the bmalloc, Windows/macOS export and CI requirements.
  2. refactor(libobs): moves os_get_path_extension verbatim from util/platform.c to util/path-extension.c, which is always compiled. Behavior-neutral; no Rust.
  3. feat(obs-util): ports path-extension and array-serializer and adds the darray core. Includes Tier 1 1:1 ports, layout tests for struct darray/struct serializer/struct array_output_data, and proptest parity against oracle_* C builds. ENABLE_RUST_LIBOBS=ON drops array-serializer.c and path-extension.c.
  4. ci(rust): Windows /EXPORT: list (rust-exports.txt, kept in sync by export_list.rs), macOS -unexported_symbols_list, rust/tools/tier2-validate/validate.{sh,ps1}, and three jobs added to the existing build-project.yaml (no new workflow file).
  5. fix(linux-validate): the ON/OFF object check now queries ninja -t inputs libobs instead of find on the persistent /build volume, where a stale pre-guard array-serializer.c.o caused a false failure.

Decisions (recorded in #5)

  • os_get_path_extension(NULL) returns NULL in Rust. C hits UB (strlen(NULL)). Intentional, documented.
  • CI uses soldr (zackees/setup-soldr pinned by SHA, cache: false, then soldr cargo test/clippy/fmt), per the approved rule and AGENTS.md.

RED -> GREEN (per port)

  • path_extension: body replaced by todo!() -> Tier 1 path_extension 0/6 passed (RED). Restored -> all pass. Mutation (drop the '\\' separator arm) -> path_extension_parity both proptests fail.
  • darray: grow_capacity, reserve, ensure_capacity, resize, push_back(_array), clear, free, erase, pop_back, find stubbed -> Tier 1 darray 0/9 and darray_parity 0/1 (RED). Restored -> pass. Mutation (capacity * 3 growth) -> darray_ops_match_c fails.
  • array_serializer: seek_type_from_c, seek_target, plan_write, ArrayOutput::{write,get_pos,seek,reset} stubbed -> Tier 1 array_serializer 0/12 (RED); the parity binary aborts. Restored -> pass. Mutations: seek_target > -> >= fails the shim parity. get_pos returning cur_pos originally survived, because parity only drove the shim. The parity proptest now also drives the safe ArrayOutput core against the oracle, and that mutation now fails (core after GetPos).

Verification (local, Linux x86_64)

  • soldr cargo test --workspace: all green (incl. path_extension*, darray*, array_serializer*, export_list, bitstream*)
  • soldr cargo clippy --workspace --all-targets -- -D warnings: clean; soldr cargo fmt --all --check: clean
  • rust/tools/linux-validate/run.sh: cmocka 4/4 OFF and ON; OFF has path-extension.c.o; ON has no bitstream/array-serializer/path-extension objects; exported symbols IDENTICAL (1752)
  • Oracle C sources: clang -std=c11 -Wall -Wextra -pedantic clean.

Not run locally (no macOS/Windows host): covered by the new CI jobs

  • macOS rust/tools/tier2-validate/validate.sh (Xcode + Corrosion, nm -gU OFF vs ON)
  • Windows rust/tools/tier2-validate/validate.ps1 with vcpkg cmocka (windows-ci-x64, /EXPORT: list)
  • toolchain + clippy/rustfmt install on all three runners, and the cc-built oracle under MSVC /std:c11

zackees added 10 commits October 8, 2026 15:50
…cy (#5)

Add the function-extraction rule and the header-inline (static inline /
macro) Tier 2 exemption, plus bmalloc, Windows/macOS export and CI
requirements, before any Phase 2 port. Refs #5
…ion.c (#5)

Behavior-neutral move, as the function-extraction policy requires: the
function body is unchanged, no header or signature changes, and the new
file is always compiled. Refs #5
…core (#5)

- path_extension: safe core + os_get_path_extension shim. NULL path
  returns NULL (C dereferences it); intentional, documented difference.
- array_serializer: safe ArrayOutput core + C ABI shim for the three
  exported functions; write/seek/get_pos stay private callbacks.
- darray: safe DArray + #[repr(C)] struct darray mirror under the
  header-inline exemption (layout is the contract, nothing exported).
- Tier 1 1:1 ports of test_os_path/test_serializer/test_darray, layout
  tests for struct darray/serializer/array_output_data, and proptest
  parity against oracle_* builds of the original C (shim and safe core).
- Test-only bmalloc/brealloc/bfree linked whole-archive into the oracle.
- ENABLE_RUST_LIBOBS=ON drops util/array-serializer.c and
  util/path-extension.c; linux-validate checks both objects.

Refs #5
- Windows: /EXPORT: options from libobs/cmake/rust-exports.txt so obs.dll
  exports the Rust shims; export_list.rs keeps the list in sync with the
  #[unsafe(no_mangle)] shims.
- macOS: ld64 -unexported_symbols_list hides Rust internals.
- rust/tools/tier2-validate/validate.{sh,ps1}: cmocka OFF/ON plus an
  exported-symbol diff on macOS and Windows.
- build-project.yaml (existing workflow only): rust-tests on Linux,
  macOS and Windows via setup-soldr + soldr cargo, rust-linux-tier2 and
  rust-tier2 jobs.

Refs #5
… volume (#5)

The /build volume persists across runs, so an array-serializer.c.o built
before the ENABLE_RUST_LIBOBS guard existed made the ON check fail.
Query ninja -t inputs libobs instead. Refs #5
…ork path on macOS (#5)

- obs-c-oracle build.rs: drop canonicalize(), whose verbatim \\?\ path
  broke MSVC include resolution (C1083 on util/bitstream.c).
- rust-linux-tier2: fetch-depth 0 so versionconfig.cmake finds a tag.
- tier2-validate/validate.sh: set DYLD_FRAMEWORK_PATH for ctest so the
  cmocka tests load the built libobs.framework.
…tree (#5)

A worktree's .git file and its submodules' gitdir links resolve only on
the host, so git describe in versionconfig.cmake failed in the container.
…a tests (#5)

ctest runs each test from its own directory, so the relative framework
path did not resolve.
…test (#5)

macOS: DYLD_LIBRARY_PATH to the obs-deps lib dir (libavcodec etc.).
Windows: obs.dll, w32-pthreads.dll and obs-deps FFmpeg DLL dirs on PATH,
since the cmocka executables are built apart from them.
…rts (#5)

With ENABLE_RUST_LIBOBS=ON the Rust staticlib's compiler_builtins defines
___isOSVersionAtLeast and ___isPlatformVersionAtLeast, which libobs then
exported, so nm -gU differed from the C build (Tier 2 macOS).
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.

1 participant