add with_timeout constructor for Observer

This commit is contained in:
toka 2021-03-15 10:20:13 +09:00
parent ae9486814e
commit ff759e2ca7
2 changed files with 15 additions and 11 deletions

View File

@ -71,11 +71,7 @@ where
#[inline]
fn run_target(&mut self, input: &I) -> Result<ExitKind, Error> {
let bytes = input.target_bytes();
let ret = (self.harness_fn)(self, bytes.as_slice());
#[cfg(unix)]
unsafe {
write_volatile(

View File

@ -128,6 +128,15 @@ impl TimeObserver {
}
}
pub fn with_timeout(name: &'static str, tmout: u64) -> Self {
Self {
name: name.to_string(),
start_time: Duration::from_secs(0),
last_runtime: None,
exec_tmout: Some(Duration::from_secs(tmout)),
}
}
pub fn last_runtime(&self) -> &Option<Duration> {
&self.last_runtime
}
@ -135,7 +144,6 @@ impl TimeObserver {
impl Observer for TimeObserver {
fn pre_exec(&mut self) -> Result<(), Error> {
#[cfg(unix)]
match self.exec_tmout {
Some(exec_tmout) => unsafe {