Skip to content

Commit 8cf04d9

Browse files
committed
Write tests for timers' set_callback_under_group methods
1 parent 4e2a260 commit 8cf04d9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

seastar/src/timer.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,24 @@ mod tests {
303303
assert!(*calls.borrow() == 2);
304304
}
305305

306+
#[seastar::test]
307+
async fn [<test_ $timer _set_callback_under_group>]() {
308+
let mut timer = Timer::<$Clock>::new();
309+
310+
let calls = Rc::new(RefCell::new(0));
311+
let calls_cloned = calls.clone();
312+
let callback = move || {
313+
*calls_cloned.borrow_mut() += 1;
314+
};
315+
let sg = SchedulingGroup::create("sg", 100.).await;
316+
timer.set_callback_under_group(callback, &sg);
317+
318+
let duration = Duration::from_millis(100);
319+
timer.arm(duration);
320+
321+
[<check_ $timer>](&mut timer, duration, calls).await;
322+
}
323+
306324
#[seastar::test]
307325
async fn [<test_ $timer _arm_at>]() {
308326
let (mut timer, duration, calls) = [<set_up_ $timer _test>]();

0 commit comments

Comments
 (0)