Skip to content

Commit

Permalink
Better error message in testcase_score.rs pt.2 (#2863)
Browse files Browse the repository at this point in the history
* msg

* l
  • Loading branch information
tokatoka authored Jan 18, 2025
1 parent 019c71a commit 2e26af9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
15 changes: 8 additions & 7 deletions libafl/src/schedulers/testcase_score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,13 +312,14 @@ where
None => 0.0,
};

let avg_top_size =
match state.metadata::<TopRatedsMetadata>() {
Ok(m) => m.map().len() as f64,
Err(_) => return Err(Error::key_not_found(
"TopRatedsMetadata not found! You have to use Minimizer scheduler with this.",
)),
};
let avg_top_size = match state.metadata::<TopRatedsMetadata>() {
Ok(m) => m.map().len() as f64,
Err(e) => {
return Err(Error::key_not_found(format!(
"{e:?} You have to use Minimizer scheduler with this.",
)))
}
};

weight *= 1.0 + (tc_ref / avg_top_size);

Expand Down
6 changes: 5 additions & 1 deletion libafl_targets/src/cmps/stages/aflpptracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ impl<E, EM, TE, S, Z> Stage<E, EM, S, Z> for AFLppCmplogTracingStage<'_, EM, TE,
where
TE: HasObservers + Executor<EM, BytesInput, S, Z>,
TE::Observers: MatchNameRef + ObserversTuple<BytesInput, S>,
S: HasCorpus<BytesInput> + HasCurrentTestcase<BytesInput> + HasMetadata + HasNamedMetadata + HasCurrentCorpusId,
S: HasCorpus<BytesInput>
+ HasCurrentTestcase<BytesInput>
+ HasMetadata
+ HasNamedMetadata
+ HasCurrentCorpusId,
{
#[inline]
fn perform(
Expand Down

0 comments on commit 2e26af9

Please sign in to comment.