Skip to content

test: characterize callback/decl.c before port (Refs #1438) - #1442

Merged
zackees merged 2 commits into
obs-rust:masterfrom
vpacher:rust/1438-decl
Oct 18, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
vpacher:rust/1438-decl

Conversation

@vpacher

@vpacher vpacher commented Oct 18, 2026

Copy link
Copy Markdown
Member

Refs #1438 (meta #1437). Characterization PR before the port, like #788 for obs-data.

test/cmocka/test_decl.c (Tier 2) pins what parse_decl_string does today. There was no C test for libobs/callback/.

Case Pinned behavior
void f(int a) name f, decl_string points to the input, a is INT with CALL_PARAM_IN (no specifier = input)
int get(in ptr src, out string s, in out float x) IN, OUT, IN | OUT; the return type is appended last as an output parameter "return"
bool f(int, float, bool, ptr, string) all five types, then "return" as BOOL
void destroy(), ptr get() no parameters; only "return"
11 failures unknown type, void parameter, unknown return type, duplicate name, reserved names (return, int) for a parameter or the function, in in, out out, missing ), empty string. A failed parse frees and zeroes the whole decl_info, decl_string included.

Every case checks bnum_allocs() before and after: nothing is left behind.

Checked against the C: 5/5 against the C libobs.so on Linux. Each failure logs the expected error (for example 'in' specifier already exists).

No change outside test/cmocka/. The port (new crate rust/obs-callback) follows in its own PR.

🤖 Generated with Claude Code

test/cmocka/test_decl.c pins what parse_decl_string does today, as the
Tier 2 test for the port in obs-rust#1438 (meta obs-rust#1437). There was no C test for
libobs/callback/.

- Parameters without a specifier are input parameters; `in out` sets
  both flags.
- A non-void return type is appended as an output parameter "return",
  after the declared parameters.
- All five parameter types; `void` only as the return type.
- `void f()` has no parameters; `ptr get()` only "return".
- Each error fails the parse: unknown type, void parameter, unknown
  return type, duplicate name, reserved name ("return", "int") for a
  parameter or the function, a repeated in/out specifier, a missing
  ")" and an empty string. A failed parse frees and zeroes the whole
  decl_info, decl_string included.
- No allocation is left behind (bnum_allocs) in any case.

Checked against the C: 5/5 against the C libobs.so on Linux (each
failure logs the expected error, for example "'in' specifier already
exists").

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vpacher
vpacher requested a review from zackees as a code owner October 18, 2026 21:07

@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 characterization test that pins today's behavior, with a bnum_allocs leak check on every case, is exactly what should come before the port.

Fixup pushed (280533f): test_decl is now registered in test/cmocka/tests.d/test_decl.cmake instead of being appended to CMakeLists.txt. The comment at CMakeLists.txt:686 asks new tests to go there so that concurrent PRs adding tests don't conflict. Nothing else changed.

@zackees
zackees enabled auto-merge October 18, 2026 21:12
@zackees
zackees added this pull request to the merge queue Oct 18, 2026
Merged via the queue into obs-rust:master with commit 943082c Oct 18, 2026
23 checks passed
@vpacher
vpacher deleted the rust/1438-decl branch October 20, 2026 04:19
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