Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions msim/src/sim/runtime/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,33 @@ mod tests {
use super::start_watchdog_with;
use crate::{runtime::Runtime, time};

#[test]
fn test_nested_watchdog_suppression() {
let runtime = Runtime::new();
let handle = runtime.handle();

assert!(!handle.is_watchdog_suppressed());

let outer_guard = handle.suppress_watchdog();
assert!(handle.is_watchdog_suppressed());

{
let inner_guard = handle.suppress_watchdog();
assert!(handle.is_watchdog_suppressed());

drop(inner_guard);

// Dropping the inner guard must not re-enable the watchdog
// while the outer guard is still active.
assert!(handle.is_watchdog_suppressed());
}

drop(outer_guard);

// The watchdog should resume only after all guards are dropped.
assert!(!handle.is_watchdog_suppressed());
}

#[test]
fn test_watchdog() {
// This test will panic if logging is enabled since the logging happens outside of a
Expand Down