Skip to content

Commit

Permalink
Write tests for timers' set_callback_under_group methods
Browse files Browse the repository at this point in the history
  • Loading branch information
patjed41 committed Mar 8, 2023
1 parent 09db395 commit 218686a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions seastar/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,24 @@ mod tests {
assert!(*calls.borrow() == 2);
}

#[seastar::test]
async fn [<test_ $timer _set_callback_under_group>]() {
let mut timer = <$Timer>::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);

[<check_ $timer>](&mut timer, duration, calls).await;
}

#[seastar::test]
async fn [<test_ $timer _arm_at>]() {
let (mut timer, duration, calls) = [<set_up_ $timer _test>]();
Expand Down

0 comments on commit 218686a

Please sign in to comment.