Skip to content

test: characterize callback/proc.c before port (Refs #1440) - #1454

Merged
zackees merged 1 commit into
obs-rust:masterfrom
nathan-v:test/proc
Oct 19, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
nathan-v:test/proc

Conversation

@nathan-v

@nathan-v nathan-v commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Refs #1440 (meta #1437). Characterization PR before the port, like #1442 for decl and #1447 for calldata.

test/cmocka/test_proc.c pins what proc_handler_create, proc_handler_destroy, proc_handler_add, and proc_handler_call do today. callback/ had no cmocka test for this file. The port may not edit this test.

What and why

The handler stays opaque. proc_handler_add parses the declaration with parse_decl_string and stores the callback under that name. proc_handler_call looks the name up with strcmp, copies the callback, drops the mutex, then calls it. The calldata pointer is passed through. The declaration is not checked against the calldata.

A few results are odd. They are pinned on purpose, with a comment that says characterized, not endorsed:

  • An invalid declaration is logged at LOG_ERROR (Function declaration invalid: ...) and not stored. A NULL declaration string logs (null). An empty string logs a blank name. The parser may also log a warning before that error line.
  • A duplicate name logs Procedure '<name>' already exists at LOG_WARNING and keeps the first callback, even when the second declaration has a different signature.
  • A NULL callback is stored. Calling it faults, so this test only checks that destroy still releases the declaration.
  • A NULL procedure name faults in strcmp once any proc is registered. With an empty handler it returns false.
  • The callback runs after the lock is released, so it can add, call, or destroy the same handler. Destroy from inside the callback returns true and frees the handler.

RED → GREEN

  • This PR is the characterization. It contains no Rust, so there is no RED or GREEN commit yet.
  • Local run: 9/9 passed against the C libobs on macOS (arm64), build_rust_OFF RelWithDebInfo, ENABLE_UNIT_TESTS=ON.
  • The port PR (rust/obs-callback) follows, RED then GREEN. It calls the existing parse_decl_string, so it does not wait on the Rust decl port (rust: Port callback/decl.c to obs-callback #1438). Tier 1 mirrors this test. Tier 3 compares against the C oracle.

Checklist

  • Base is master
  • I claimed the issue (rust: Port callback/proc.c to obs-callback #1440)
  • Characterization test. RED and GREEN are the next PR
  • User-visible change: not applicable (no user-visible change)
  • Local gate stamped. PR CI runs the full suite
  • No warning or flag changes
  • Intentional differences: not this PR. The port PR lists them if any

Pin proc_handler_create, destroy, add, and call against the
current C. No Rust in this change. The port may not edit
this test.

Invalid declarations are logged and not stored. A duplicate
name keeps the first callback. The call drops the mutex
before the callback, so the callback can add, call, or
destroy the same handler.

Refs obs-rust#1440
@nathan-v
nathan-v requested a review from zackees as a code owner October 19, 2026 06:35

@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. A test-only characterization of proc.c.h before the port, registered in tests.d/.

I checked the trickiest case, destroy_from_call, against the C. proc_handler_call copies the proc_info and unlocks before invoking the callback, and doesn't touch the handler afterwards, so destroying the handler from inside its own call is defined behavior. That makes it a guarantee worth pinning for the Rust port, which must not hold a borrow or lock across the callback. The re-entrant add/call case and the NULL-callback case ("characterized, not endorsed") are likewise good to have pinned.

@zackees
zackees enabled auto-merge October 19, 2026 06:41
@zackees
zackees added this pull request to the merge queue Oct 19, 2026
Merged via the queue into obs-rust:master with commit f45adaa Oct 19, 2026
23 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