Add testcase sampling rate (#2226)
* fuzzer: Add with_sampling_rate * Format * Fix clippy
This commit is contained in:
parent
79f3b69fa8
commit
f324c60b02
@ -290,6 +290,8 @@ where
|
||||
scheduler: CS,
|
||||
feedback: F,
|
||||
objective: OF,
|
||||
num_testcases: u64,
|
||||
testcase_sampling_rate: Option<u64>,
|
||||
phantom: PhantomData<OT>,
|
||||
}
|
||||
|
||||
@ -470,6 +472,13 @@ where
|
||||
let idx = state.corpus_mut().add(testcase)?;
|
||||
self.scheduler_mut().on_add(state, idx)?;
|
||||
|
||||
self.num_testcases += 1;
|
||||
let send_events = if let Some(sampling_rate) = self.testcase_sampling_rate {
|
||||
send_events && self.num_testcases % sampling_rate == 0
|
||||
} else {
|
||||
send_events
|
||||
};
|
||||
|
||||
if send_events {
|
||||
// TODO set None for fast targets
|
||||
let observers_buf = if manager.configuration() == EventConfig::AlwaysUnique {
|
||||
@ -770,6 +779,25 @@ where
|
||||
scheduler,
|
||||
feedback,
|
||||
objective,
|
||||
num_testcases: 0,
|
||||
testcase_sampling_rate: None,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new `StdFuzzer` with a specified `TestCase` sampling rate
|
||||
pub fn with_sampling_rate(
|
||||
scheduler: CS,
|
||||
feedback: F,
|
||||
objective: OF,
|
||||
sampling_rate: u64,
|
||||
) -> Self {
|
||||
Self {
|
||||
scheduler,
|
||||
feedback,
|
||||
objective,
|
||||
num_testcases: 0,
|
||||
testcase_sampling_rate: Some(sampling_rate),
|
||||
phantom: PhantomData,
|
||||
}
|
||||
}
|
||||
|
@ -2302,7 +2302,7 @@ impl AsanRuntime {
|
||||
Backtrace::new(),
|
||||
)));
|
||||
}
|
||||
original(s, p4, n)
|
||||
original(s, p4, n);
|
||||
}
|
||||
|
||||
#[cfg(target_vendor = "apple")]
|
||||
@ -2332,7 +2332,7 @@ impl AsanRuntime {
|
||||
Backtrace::new(),
|
||||
)));
|
||||
}
|
||||
original(s, p8, n)
|
||||
original(s, p8, n);
|
||||
}
|
||||
|
||||
#[cfg(target_vendor = "apple")]
|
||||
@ -2362,6 +2362,6 @@ impl AsanRuntime {
|
||||
Backtrace::new(),
|
||||
)));
|
||||
}
|
||||
original(s, p16, n)
|
||||
original(s, p16, n);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user