Skip to content

test: characterize callback/signal.c before port (Refs #1441) - #1457

Merged
zackees merged 1 commit into
obs-rust:masterfrom
vpacher:rust/1441-signal-characterization
Oct 19, 2026
Merged

zackees merged 1 commit into
obs-rust:masterfrom
vpacher:rust/1441-signal-characterization

Conversation

@vpacher

@vpacher vpacher commented Oct 19, 2026

Copy link
Copy Markdown
Member

Refs #1441 (meta #1437). This is the characterization PR before the port, like #1442 for decl and #1454 for proc.

test/cmocka/test_signal.c (Tier 2) pins what signal.c.h does today. It is registered in test/cmocka/tests.d/test_signal.cmake.

Test Pinned behavior
create_destroy_test create and destroy; signal_handler_destroy(NULL) does nothing
add_test a duplicate name is refused (LOG_WARNING "Signal declaration 'ev' exists"). An invalid declaration is refused: decl logs its warning, then signal logs LOG_ERROR "Signal declaration invalid: ...". signal_handler_add_array adds every string and returns false if one failed; the strings after a failure are still added.
connect_signal_test callbacks run in connect order with the caller's calldata; the same callback and data are added once; an unknown signal calls nothing; a null handler is ignored
connect_unknown_test LOG_WARNING "signal_handler_connect: signal 'nope' not found"
disconnect_test disconnect removes; an unknown pair or signal does nothing
disconnect_during_signal_test a disconnect while signalling only marks the callback; a marked callback later in the list is skipped in the same pass, then erased
remove_current_test removes the running callback after the pass; outside a signal it does nothing
connect_during_signal_test characterized, not endorsed: a callback connected while signalling is called in the same pass
nested_signal_test characterized, not endorsed: after a nested signal, signal_handler_remove_current() removes nothing (the thread-local current callback is reset to NULL)
keep_ref_test connect_ref adds the same pair again, and each one keeps the handler alive after signal_handler_destroy; each disconnect drops one reference, and the last one destroys the handler
keep_ref_remove_current_test a keep_ref callback removed while signalling gives its reference back after the pass
global_test global callbacks run after the signal's own, with the signal name and calldata; a null handler or callback is ignored; characterized, not endorsed: an unknown signal returns before the global callbacks
global_remove_test signal_handler_remove_current() removes a global callback; characterized, not endorsed: a global callback that disconnects itself stays connected (da_find compares the whole entry, and its signaling count is 1)

Every test checks bnum_allocs() before and after.

Not pinned, on purpose: signal_handler_connect_global and signal_handler_disconnect_global find entries with da_find, a memcmp of the whole struct global_callback_info, including its padding. Whether a second connect or a disconnect matches depends on bytes that the C does not set. The port compares the fields.

Checked against the C: 13/13 on Linux x86_64, against libobs and libobs-with-rust (signal is still C in both), and against an AddressSanitizer build of libobs.

No change outside test/cmocka/. The port follows in its own PR.

🤖 Generated with Claude Code

Add test/cmocka/test_signal.c, registered in tests.d. It pins the
current C behavior of signal.c.h: add (duplicates, invalid
declarations, add_array), connect and disconnect, a null handler, an
unknown signal, a disconnect and a connect while signalling,
signal_handler_remove_current (also after a nested signal),
keep_ref refcounting, and global callbacks. Every case checks
bnum_allocs.

Global connect and disconnect matching is not pinned: da_find compares
the struct padding too.

Refs obs-rust#1441

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

@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 signal.c.h, registered in tests.d/. It's good judgment to leave the global connect/disconnect matching unpinned: da_find memcmps global_callback_info padding included, so pinning it would pin uninitialized bytes. Pinning the nested-signal case, where signal_handler_remove_current removes nothing because the inner signal reset the thread-local, as "characterized, not endorsed" is exactly the kind of quirk the port has to decide on deliberately. A cmocka test runs in its own process, so its log capture can't race other tests.

@zackees
zackees added this pull request to the merge queue Oct 19, 2026
Merged via the queue into obs-rust:master with commit 7b0c557 Oct 19, 2026
23 checks passed
@vpacher
vpacher deleted the rust/1441-signal-characterization branch October 20, 2026 04:19
@vpacher vpacher mentioned this pull request Oct 21, 2026
5 tasks done
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