From a27e7c2e2aeb41af99d4903a0f34031acc8e070c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20J=C4=99drzejczak?= Date: Wed, 22 Feb 2023 10:55:10 +0100 Subject: [PATCH] Write tests for timers' set_callback_under_group methods --- seastar/src/timer.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/seastar/src/timer.rs b/seastar/src/timer.rs index c4a857a..3d7c9c2 100644 --- a/seastar/src/timer.rs +++ b/seastar/src/timer.rs @@ -304,6 +304,24 @@ mod tests { assert!(*calls.borrow() == 2); } + #[seastar::test] + async fn []() { + let mut timer = Timer::<$Clock>::new(); + + let calls = Rc::new(RefCell::new(0)); + let calls_cloned = calls.clone(); + let callback = move || { + *calls_cloned.borrow_mut() += 1; + }; + let sg = SchedulingGroup::create("sg", 100.).await; + timer.set_callback_under_group(callback, &sg); + + let duration = Duration::from_millis(100); + timer.arm(duration); + + [](&mut timer, duration, calls).await; + } + #[seastar::test] async fn []() { let (mut timer, duration, calls) = []();