From 94f0ff2885ee8076435fbe399be1a609fde57533 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 02:02:34 -0800 Subject: [PATCH 1/2] chore(quest): claim quest/m0/test-flakes-3/c-raw-track-options.md Quest-Claim: 18291d748e0f3bb4 From b098785927e0c7d73102dd3938a979e3d4bbad8e Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Tue, 17 Nov 2026 02:29:49 -0800 Subject: [PATCH 2/2] test(moq-c): raw track reads hold no wall-clock budget, and the update ends the read The options test's 25 ms max_us aged group one out whenever the suite took longer than that between publishing and subscribing, and the far open range (a time anchor, containing the newest group) then handed out two first. The time anchor test had the same dependence on a 1 s budget. Co-Authored-By: Claude Opus 5.5 --- quest/m0/test-flakes-3/c-raw-track-options.md | 30 ---- rs/moq-c/src/test.rs | 129 ++++++++---------- 2 files changed, 57 insertions(+), 102 deletions(-) delete mode 100644 quest/m0/test-flakes-3/c-raw-track-options.md diff --git a/quest/m0/test-flakes-3/c-raw-track-options.md b/quest/m0/test-flakes-3/c-raw-track-options.md deleted file mode 100644 index 385b789883d..00000000000 --- a/quest/m0/test-flakes-3/c-raw-track-options.md +++ /dev/null @@ -1,30 +0,0 @@ -# [S] moq-c's raw track options test reads its first group under load - -## Goal - -`rs/moq-c/src/test.rs::raw_track_subscription_options_and_update` passes -every run of the full moq-c suite. - -## Plan - -Found 2026-11-16 by `just check` on -[moq-dev/moq#8958](https://github.com/moq-dev/moq/pull/8958), whose change -does not reach this test's Absolute ranges. Run alone it passes. Running the -whole `moq-c` unit binary (`test::` filter) 20 times in a row fails it 6 -times at the base commit 949406e072: at `rs/moq-c/src/test.rs:2794`, it -receives `two` where it expects `one`, the group starting at 20 ms. - -The test publishes three groups 20 ms apart, then subscribes with a 25 ms -`max_us` and two ranges: `[20000, 20001)`, holding only group `one`, and an -open one from 100,000,000 µs. Group `two` (40,000 µs) is in neither, so a -stale skip of `one` under load would explain the read missing `one` but not -receiving `two`: that read should then wait on the open range. Trace how the -consumer hands out `two` first. If a path admits a group outside the -requested ranges (such as a read before the ranges resolve, a drop or skip -that widens the range, or moq-c's own frame pump), that is a range-delivery -bug in the library, and the fix belongs there with a regression test. Only -if the trace shows `two` arrives by a path the ranges allow is the fix in -the test, as the epic's rules ask: drive it on a paused or manual clock, or -give it a budget that does not depend on how fast the suite runs. - -Public API: none. Wire: none. diff --git a/rs/moq-c/src/test.rs b/rs/moq-c/src/test.rs index 45b44dcae47..5d206d3bab4 100644 --- a/rs/moq-c/src/test.rs +++ b/rs/moq-c/src/test.rs @@ -2674,6 +2674,10 @@ fn raw_track_and_group_abort_consume_their_handles() { assert_eq!(moq_publish_close(broadcast), 0); } +/// The subscription's ranges filter the read, and an update replaces them on the live read. +/// +/// No delivery budget runs on the wall clock (the track keeps its groups and the read waits +/// on them), so a slow suite cannot age group `one` out before the read reaches it. #[test] fn raw_track_subscription_options_and_update() { let origin = id(moq_origin_create()); @@ -2683,8 +2687,8 @@ fn raw_track_subscription_options_and_update() { let track_name = b"data"; let info = moq_track_info { priority: 3, - max_age_us: 1_000_000, - max_age_unlimited: false, + max_age_us: 0, + max_age_unlimited: true, timescale: 1_000_000, timescale_present: true, refresh: 0, @@ -2694,52 +2698,43 @@ fn raw_track_subscription_options_and_update() { let track = id(unsafe { moq_publish_track(broadcast, track_name.as_ptr() as *const c_char, track_name.len(), &info) }); - let payloads: [&[u8]; 3] = [b"zero", b"one", b"two"]; - for (i, payload) in payloads.into_iter().enumerate() { + let publish = |payload: &[u8], at: u64| { assert_eq!( - unsafe { moq_publish_track_frame(track, payload.as_ptr(), payload.len(), µs(i as u64 * 20_000)) }, + unsafe { moq_publish_track_frame(track, payload.as_ptr(), payload.len(), µs(at)) }, 0 ); - } + }; + publish(b"zero", 0); + publish(b"one", 20_000); + publish(b"two", 40_000); let consume = request_broadcast(origin, path); let frame_cb = Callback::new(); - // An absolute anchor is a group's start, in the track's microseconds. A read whose ranges - // all end ends once it read them, so an open range far ahead keeps this one open for the - // update. + let absolute = |group| moq_anchor { + kind: moq_anchor_kind::MOQ_ANCHOR_ABSOLUTE as u32, + group, + timestamp: moq_timestamp::default(), + }; + // An absolute anchor is a group's start, in the track's microseconds, and an absolute end + // is exclusive. The open range starts at the group containing 100 s, the newest one held: + // `two`, and every group after it. let ranges = [ moq_range { - start: moq_anchor { - kind: moq_anchor_kind::MOQ_ANCHOR_ABSOLUTE as u32, - group: 20_000, - timestamp: moq_timestamp::default(), - }, - end: moq_anchor { - kind: moq_anchor_kind::MOQ_ANCHOR_ABSOLUTE as u32, - group: 20_001, - timestamp: moq_timestamp::default(), - }, + start: absolute(20_000), + end: absolute(20_001), end_present: true, }, moq_range { - start: moq_anchor { - kind: moq_anchor_kind::MOQ_ANCHOR_ABSOLUTE as u32, - group: 100_000_000, - timestamp: moq_timestamp::default(), - }, - end: moq_anchor { - kind: moq_anchor_kind::MOQ_ANCHOR_ABSOLUTE as u32, - group: 0, - timestamp: moq_timestamp::default(), - }, + start: absolute(100_000_000), + end: absolute(0), end_present: false, }, ]; let subscription = moq_subscription { priority: 5, delay: moq_delay { - max_us: 25_000, + max_unlimited: true, ..moq_delay::default() }, ranges: ranges.as_ptr(), @@ -2757,52 +2752,42 @@ fn raw_track_subscription_options_and_update() { ) }); - let frame_id = id(frame_cb.recv()); - let mut frame = moq_frame { - payload: std::ptr::null(), - payload_size: 0, - timestamp: std::ptr::null(), - keyframe: false, + let expect = |payload: &[u8], at: u64| { + let frame_id = id(frame_cb.recv()); + let mut frame = moq_frame { + payload: std::ptr::null(), + payload_size: 0, + timestamp: std::ptr::null(), + keyframe: false, + }; + assert_eq!(unsafe { moq_consume_track_frame(frame_id, &mut frame) }, 0); + let received = unsafe { std::slice::from_raw_parts(frame.payload, frame.payload_size) }; + assert_eq!(received, payload); + assert_eq!(read_timestamp(frame.timestamp), micros(at)); + assert_eq!(moq_consume_track_frame_free(frame_id), 0); }; - assert_eq!(unsafe { moq_consume_track_frame(frame_id, &mut frame) }, 0); - let received = unsafe { std::slice::from_raw_parts(frame.payload, frame.payload_size) }; - assert_eq!(received, b"one"); - assert_eq!(read_timestamp(frame.timestamp), micros(20_000)); - assert_eq!(moq_consume_track_frame_free(frame_id), 0); + expect(b"one", 20_000); + expect(b"two", 40_000); - // Widen the bounded range but keep the open one, so the read stays open for the cancel. - let widened = [ - moq_range { - end: moq_anchor { - group: 40_001, - ..ranges[0].end - }, - ..ranges[0] - }, - ranges[1], - ]; + // Replace both ranges with one that ends at `three`, so the read ends once it reads it + // and never sees `four`. + let bounded = [moq_range { + end: absolute(60_001), + ..ranges[0] + }]; let update = moq_subscription { - ranges: widened.as_ptr(), - ranges_len: widened.len(), + ranges: bounded.as_ptr(), + ranges_len: bounded.len(), ..subscription }; assert_eq!(unsafe { moq_consume_track_update(consumer, &update) }, 0); - let frame_id = id(frame_cb.recv()); - let mut frame = moq_frame { - payload: std::ptr::null(), - payload_size: 0, - timestamp: std::ptr::null(), - keyframe: false, - }; - assert_eq!(unsafe { moq_consume_track_frame(frame_id, &mut frame) }, 0); - let received = unsafe { std::slice::from_raw_parts(frame.payload, frame.payload_size) }; - assert_eq!(received, b"two"); - assert_eq!(read_timestamp(frame.timestamp), micros(40_000)); - assert_eq!(moq_consume_track_frame_free(frame_id), 0); + publish(b"three", 60_000); + publish(b"four", 80_000); + expect(b"three", 60_000); + assert_eq!(frame_cb.recv_terminal(), 0, "the read ends with its ranges"); + assert!(moq_consume_track_cancel(consumer) < 0, "the ended read is gone"); - assert_eq!(moq_consume_track_cancel(consumer), 0); - assert_eq!(frame_cb.recv_terminal(), 0); assert_eq!(moq_publish_track_finish(track), 0); assert_eq!(moq_consume_close(consume), 0); assert_eq!(moq_publish_close(broadcast), 0); @@ -2810,7 +2795,7 @@ fn raw_track_subscription_options_and_update() { } /// A time anchor starts at the group containing that presentation time, given unscaled in the -/// track's timescale. +/// track's timescale. No budget runs on the wall clock, so a slow suite can't age `one` out. #[test] fn raw_track_time_anchor() { let origin = id(moq_origin_create()); @@ -2820,8 +2805,8 @@ fn raw_track_time_anchor() { let track_name = b"data"; let info = moq_track_info { priority: 3, - max_age_us: 1_000_000, - max_age_unlimited: false, + max_age_us: 0, + max_age_unlimited: true, timescale: 1_000_000, timescale_present: true, refresh: 0, @@ -2862,7 +2847,7 @@ fn raw_track_time_anchor() { let subscription = moq_subscription { priority: 5, delay: moq_delay { - max_us: 1_000_000, + max_unlimited: true, ..moq_delay::default() }, ranges: ranges.as_ptr(),