Repository navigation
test: Characterize the output stream delay - #1547
Merged
zackees merged 1 commit intoOct 20, 2026
Merged
Conversation
The stream delay in libobs/obs-output-delay.c has no C test. Before its Rust port, test_output_delay pins what the C does now, so the port keeps it as an unchanged Tier 2 check and Tier 1 ports its assertions 1:1. process_delay() and the delay start, stop and cleanup are not exported, so the test compiles the file into itself with a zeroed struct obs_output, recording stubs for the obs-output.c functions it calls, and a test clock in place of os_gettime_ns(). No libobs core, display or real time. 20 cases: the setter and getters (raw outputs, NULL, whole seconds); packets held for the delay and released oldest first once more than the delay has passed, all due packets per call, copied with their packet time; packets dropped when the delay is not capturing; delay_start's order of checks, `starting` and restart references, and the restart while a delay runs; queued start and stop running after the delay, the stop with the time it was asked for; cleanup releasing everything without running it; and preserve on disconnect, which holds every packet while reconnecting and grows the delay by the outage. Callbacks run with the delay mutex released. Odd cases are marked "characterized, not endorsed". Refs obs-rust#1546
6 of 7 tasks
This was referenced Oct 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #1546 (PR 1 of the plan: the characterization; the accessor and the port follow)
What and why
libobs/obs-output-delay.c.h, the stream delay, has no C test. This PR addstest/cmocka/test_output_delay.c, which pins what the C does now before the Rust port. From then on it is an unchanged Tier 2 check, and Tier 1 ports its assertions 1:1. No Rust, and no change to libobs, to a public header or to an existing test.process_delay()and the delay start, stop and cleanup are not exported, so the test compiles the file into itself, astest_scene_blendandtest_hotkey_loaddo. That means it characterizes the C source only, and Tier 3 will be the proof of the swap (as with libobs: Port the Wayland hotkey key state to obs-hotkey #1516).struct obs_output; only the fields the file reads are set up.obs-output.cfunctions the file calls are recording stubs: actual start and stop,can_begin_data_capture,initialize_encodersandbegin_data_capture. So are the delay callback and thestarting/stoppingsignals.os_gettime_ns()is renamed to a test clock, so no case depends on real time or sleeps.obs_encoder_packet_release().obs_encoder_packet_create_instance()is hidden, so the test has a copy of it. Teardown checksbnum_allocs(), so a packet the delay fails to release fails the test.tests.d/test_output_delay.cmakefragment, with the same include and link lines astest_scene_blend, plus the Cargo C-test manifest entry. cmocka executables are C compatibility tests, outside the Rust test-binary budget; no Rust harness is added.delay_startruns, in order, the data capture check, setsstarting, initializes the encoders, then begins capture, with no signal of its own. It queues the real start and takes a restart reference. A failed check or encoder initialization queues nothing and clearsstartingagain;starting;stoppingis signalled at once;delay_cur_flags), not the setting, and only its bit counts;Characterized, not endorsed (comments in the test):
obs_output_get_delay()andobs_output_get_active_delay()log a NULL output under the setter's name (obs_output_set_delay: Null 'output' parameter);obs_output_get_active_delay()casts touint32_t, so it wraps pastUINT32_MAXseconds;0 > 0is false;os_gettime_ns()is monotonic, so this is not reached in practice);obs_output_begin_data_capture()fails,delay_startcleans up the delay but leavesstartingset, unlike the failed encoder initialization path. Before that call,delay_starthas just checkedobs_output_can_begin_data_capture(), so this needs the output's state to change in between. No bug filed.RED → GREEN
libobs-with-rustuntil the port.test_output_delay: 20/20, run 3 times against each oflibobsandlibobs-with-rustin both lanes, all passing. It also passes 20/20 when built with ASan and UBSan (leak detection on).obs-output-delay.c.hfail it. The mutants were:>=for>in the pop;startingnot cleared on failed encoder initialization;startingorstoppingsignal;ENABLE_RUST_LIBOBS=OFFandON), headless (private Xvfb, private D-Bus, fresh HOME). Each runs the full cmocka suite againstlibobsand againstlibobs-with-rust:ENABLE_RUST_LIBOBS=OFF)ENABLE_RUST_LIBOBS=ON)None of the four runs skipped or failed to run a test. The export lists are also identical across the two lanes.
test_output_delaypasses in all four runs.uv run ci/local_gate.py --lane lint: passed (45 s). clang-format 22.1.3 and gersemi 0.25.0 are clean on the new files.Windows/macOS: not built there. The test is portable C with no host conditionals. It builds against
libobs.pch.hwith the same includes and libraries astest_scene_blend. It defines the functions it stubs, astest_hotkey_loaddoes with its compiled-in file.Checklist
masterdocs/features.mdis added or updated (not applicable: no user-visible change)-W..., ratchets): not applicable