Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 5 additions & 3 deletions src/virt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ mod ui;

use std::{
iter,
sync::mpsc::{self, Receiver, Sender},
sync::mpsc::{self, Receiver, Sender, TryRecvError},
thread,
time::Duration,
};

use rand_chacha::ChaCha8Rng;
Expand Down Expand Up @@ -110,15 +111,16 @@ impl<'a, I: 'static, C> Runner<'a, I, C> {
I: Send + Sync,
F: FnOnce() -> R,
{
let (stop_tx, stop_rx) = mpsc::channel();
let mut service = Service::with_dispatch(platform, dispatch);
thread::scope(|s| {
let (stop_tx, stop_rx) = mpsc::channel();
s.spawn(move || {
let mut eps = self.eps;
while stop_rx.try_recv().is_err() {
while stop_rx.try_recv() == Err(TryRecvError::Empty) {
if self.syscall_rx.try_recv().is_ok() {
service.process(&mut eps);
}
thread::sleep(Duration::from_millis(1));
}
});
let result = f();
Expand Down
9 changes: 9 additions & 0 deletions tests/virt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,12 @@ fn test1() {
fn test2() {
run_test(2);
}

#[test]
#[should_panic]
fn test_panic() {
// panicking tests should return and not run forever
virt::with_client(virt::StoreConfig::ram(), "test", |_| {
panic!();
})
}
Loading