-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make test-util paused time fully deterministic #3492
Changes from 1 commit
4aac8df
b64a572
215ce30
9524503
6cb567f
8fec76b
86b0736
84dd3c5
413159c
6a372b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -162,13 +162,18 @@ pub(crate) struct Cfg { | |
pub(crate) enable_io: bool, | ||
pub(crate) enable_time: bool, | ||
pub(crate) enable_pause_time: bool, | ||
pub(crate) start_paused: bool, | ||
} | ||
|
||
impl Driver { | ||
pub(crate) fn new(cfg: Cfg) -> io::Result<(Self, Resources)> { | ||
let (io_stack, io_handle, signal_handle) = create_io_stack(cfg.enable_io)?; | ||
|
||
let clock = create_clock(cfg.enable_pause_time); | ||
if cfg.start_paused { | ||
clock.pause(); | ||
} | ||
|
||
let (time_driver, time_handle) = | ||
create_time_driver(cfg.enable_time, io_stack, clock.clone()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this makes it deterministic because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That, along with changing the ClockTime constructor to pull start_time out of the clock passed to it rather than going for the global clock (which isn't installed at that point so it falls back to the system clock). |
||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this panic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to
clock.pause
inClock::new
will panic when running on a multi threaded runtime.