Skip to content

Commit

Permalink
add timeout to thread_shutdown test
Browse files Browse the repository at this point in the history
  • Loading branch information
camshaft committed Jun 21, 2024
1 parent 0aa4d92 commit fbc6678
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions dc/s2n-quic-dc/src/path/secret/map/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,20 @@ fn thread_shutdown() {
let map = Map::new(signer);
let state = Arc::downgrade(&map.state);
drop(map);
// Nothing is holding on to the state, so the thread should shutdown (mpsc disconnects or on
// next loop around if that fails for some reason).
assert_eq!(state.strong_count(), 0);

let iterations = 10;
let max_time = core::time::Duration::from_secs(2);

for _ in 0..iterations {
// Nothing is holding on to the state, so the thread should shutdown (mpsc disconnects or on
// next loop around if that fails for some reason).
if state.strong_count() == 0 {
return;
}
std::thread::sleep(max_time / iterations);
}

panic!("thread did not shut down after {max_time:?}");
}

#[derive(Debug, Default)]
Expand Down

0 comments on commit fbc6678

Please sign in to comment.