From 6ad55e3b2981eaff4b6bcdbf7ac8689cb3cb2a39 Mon Sep 17 00:00:00 2001 From: Alwin Berger Date: Mon, 12 Dec 2022 15:16:45 +0100 Subject: [PATCH] fixup --- fuzzers/FRET/src/clock.rs | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/fuzzers/FRET/src/clock.rs b/fuzzers/FRET/src/clock.rs index efb2e59843..3fff2dcd8e 100644 --- a/fuzzers/FRET/src/clock.rs +++ b/fuzzers/FRET/src/clock.rs @@ -155,17 +155,19 @@ impl Default for QemuClockObserver { //========== Feedback /// Nop feedback that annotates execution time in the new testcase, if any -/// for this Feedback, the testcase is never interesting (use with an OR) +/// for this Feedback, the testcase is never interesting (use with an OR). +/// It decides, if the given [`QemuClockObserver`] value of a run is interesting. #[derive(Serialize, Deserialize, Clone, Debug)] -pub struct ClockFeedback { - exec_time: Option, +pub struct ClockTimeFeedback { + exec_time: Option, name: String, } -impl Feedback for ClockFeedback +impl Feedback for ClockTimeFeedback where S: UsesInput + HasClientPerfMonitor, { + #[allow(clippy::wrong_self_convention)] fn is_interesting( &mut self, _state: &mut S, @@ -180,17 +182,18 @@ where { // TODO Replace with match_name_type when stable let observer = observers.match_name::(self.name()).unwrap(); - self.exec_time = Some(observer.last_runtime()); + self.exec_time = Some(Duration::from_nanos(observer.last_runtime() << 3)); // Assume a somewhat realistic multiplier of clock, it does not matter Ok(false) } /// Append to the testcase the generated metadata in case of a new corpus item #[inline] - fn append_metadata(&mut self, _state: &mut S, testcase: &mut Testcase) -> Result<(), Error> { - *testcase.exec_time_mut() = match self.exec_time { - Some(s) => Some(Duration::from_nanos(s << 3)), //emulated time is << 3, real time more like * 360 - None => None, - }; + fn append_metadata( + &mut self, + _state: &mut S, + testcase: &mut Testcase, + ) -> Result<(), Error> { + *testcase.exec_time_mut() = self.exec_time; self.exec_time = None; Ok(()) } @@ -203,15 +206,15 @@ where } } -impl Named for ClockFeedback { +impl Named for ClockTimeFeedback { #[inline] fn name(&self) -> &str { self.name.as_str() } } -impl ClockFeedback { - /// Creates a new [`ClockFeedback`], deciding if the value of a [`TimeObserver`] with the given `name` of a run is interesting. +impl ClockTimeFeedback { + /// Creates a new [`ClockFeedback`], deciding if the value of a [`QemuClockObserver`] with the given `name` of a run is interesting. #[must_use] pub fn new(name: &'static str) -> Self { Self { @@ -220,7 +223,7 @@ impl ClockFeedback { } } - /// Creates a new [`ClockFeedback`], deciding if the given [`TimeObserver`] value of a run is interesting. + /// Creates a new [`ClockFeedback`], deciding if the given [`QemuClockObserver`] value of a run is interesting. #[must_use] pub fn new_with_observer(observer: &QemuClockObserver) -> Self { Self {