Skip to content

Phase 3: characterize and port pure leaf utilities (crc32, utf8, dstr, lexers, text-lookup, base, bmem) #6

Closed

Description

@zackees

Part of the roadmap meta issue. Requires Phase 2's policy and CI.

Context

These libobs/util files have no OS dependencies and no existing C tests: crc32.c (64 LOC), utf8.c (366), dstr.c (787), lexer.c (305), cf-lexer.c (1376), cf-parser.c (60), text-lookup.c (271), base.c (126, logging), bmem.c (164, allocator). With no C test, Tier 2 has nothing to run.

Proposal

  1. Policy addition: characterization tests first. Before porting a file with no C test, add cmocka tests that pin its current behavior. Merge them against the C implementation in their own PR.
  2. Port order, by dependency: crc32 → utf8 → lexer/cf-lexer/cf-parser → text-lookup → dstr → base → bmem (last; everything allocates through it, including bmalloc hooks and alignment guarantees).
  3. dstr.h has inline helpers: apply the header-inline exemption from Phase 2 to those, and port dstr.c.

Acceptance criteria

  • For each file, a characterization cmocka test PR merged first, passing against C.
  • Each port: RED → GREEN, Tier 2 (unchanged C tests OFF/ON, layout tests), Tier 3 proptest parity, mutation check.
  • bmem: parity on the allocation hooks (base_set_allocator), alignment, and bnum_allocs accounting.
  • Exported-symbol sets identical OFF vs ON.

Decisions

  • bmem goes last: a wrong allocator breaks every other Tier 2 run.
  • utf8/dstr parity uses arbitrary byte strings, including invalid UTF-8.

Activity

  1. added
    enhancement
    on Oct 8, 2026
  2. added 2 commits that reference this issue on Oct 9, 2026
  3. zackees commented on Oct 9, 2026

    @zackees
    MemberAuthor

    Landed on feature branch grind/meta-4-9b41 via #34; closes when feature PR #33 merges into master.

  4. b7216309-jpg commented on Oct 9, 2026

    @b7216309-jpg
    Contributor

    I'm picking up the utf8 port (step 2 of the Phase 3 order, after crc32). I'll branch from grind/meta-4-9b41, follow the RED → GREEN workflow, and use test/cmocka/test_utf8.c unchanged as the Tier 2 test. The Tier 3 parity test will use arbitrary byte strings, including invalid UTF-8. I'll open the PR against the feature branch. Please let me know if the grind run already has this queued, so we don't duplicate work.

  5. b7216309-jpg commented on Oct 9, 2026

    @b7216309-jpg
    Contributor

    Recording the decisions for the utf8 port in #40, as the testing policy asks:

    • Scope: non-Windows only. On Windows, utf8.c is a thin wrapper over MultiByteToWideChar/WideCharToMultiByte on 16-bit wchar_t, so with ENABLE_RUST_LIBOBS=ON it stays in C there (per-OS rule).
    • wchar_t signedness: the core is generic over i32/u32. The oracle compiles the non-Windows branch twice, with wchar_t as int32_t and as uint32_t, so parity covers x86 Linux/macOS and Arm Linux.
    • Internal symbols: utf8_to_wchar/wchar_to_utf8 have no EXPORT, so they are hidden via rust-exports.map local: and rust-unexports-macos.txt rather than listed in rust-exports.txt. export_list.rs now enforces exported-or-hidden.
    • Intentional differences: none.
  6. zackees commented on Oct 9, 2026

    @zackees
    MemberAuthor

    Closed by feature PR #33, but this phase landed only partially. The remaining work is tracked in #43 (a sub-issue of #4).

  7. 21 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions