Fix metadata loss across state-restore. (#582)
* bug fix * fix * fix * remove getter
This commit is contained in:
parent
c88e38d9f4
commit
1167389149
@ -532,7 +532,9 @@ where
|
|||||||
{
|
{
|
||||||
/// Create a new [`StdMOptMutator`].
|
/// Create a new [`StdMOptMutator`].
|
||||||
pub fn new(state: &mut S, mutations: MT, swarm_num: usize) -> Result<Self, Error> {
|
pub fn new(state: &mut S, mutations: MT, swarm_num: usize) -> Result<Self, Error> {
|
||||||
state.add_metadata::<MOpt>(MOpt::new(mutations.len(), swarm_num)?);
|
if !state.has_metadata::<MOpt>() {
|
||||||
|
state.add_metadata::<MOpt>(MOpt::new(mutations.len(), swarm_num)?);
|
||||||
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
mode: MOptMode::Pilotfuzzing,
|
mode: MOptMode::Pilotfuzzing,
|
||||||
finds_before: 0,
|
finds_before: 0,
|
||||||
|
@ -263,7 +263,16 @@ where
|
|||||||
/// Creates a new [`CoverageAccountingScheduler`] that wraps a `base` [`Scheduler`]
|
/// Creates a new [`CoverageAccountingScheduler`] that wraps a `base` [`Scheduler`]
|
||||||
/// and has a default probability to skip non-faved [`Testcase`]s of [`DEFAULT_SKIP_NON_FAVORED_PROB`].
|
/// and has a default probability to skip non-faved [`Testcase`]s of [`DEFAULT_SKIP_NON_FAVORED_PROB`].
|
||||||
pub fn new(state: &mut S, base: CS, accounting_map: &'a [u32]) -> Self {
|
pub fn new(state: &mut S, base: CS, accounting_map: &'a [u32]) -> Self {
|
||||||
state.add_metadata(TopAccountingMetadata::new(accounting_map.len()));
|
match state.metadata().get::<TopAccountingMetadata>() {
|
||||||
|
Some(meta) => {
|
||||||
|
if meta.max_accounting.len() != accounting_map.len() {
|
||||||
|
state.add_metadata(TopAccountingMetadata::new(accounting_map.len()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
state.add_metadata(TopAccountingMetadata::new(accounting_map.len()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
accounting_map,
|
accounting_map,
|
||||||
inner: MinimizerScheduler::new(base),
|
inner: MinimizerScheduler::new(base),
|
||||||
@ -279,7 +288,16 @@ where
|
|||||||
skip_non_favored_prob: u64,
|
skip_non_favored_prob: u64,
|
||||||
accounting_map: &'a [u32],
|
accounting_map: &'a [u32],
|
||||||
) -> Self {
|
) -> Self {
|
||||||
state.add_metadata(TopAccountingMetadata::new(accounting_map.len()));
|
match state.metadata().get::<TopAccountingMetadata>() {
|
||||||
|
Some(meta) => {
|
||||||
|
if meta.max_accounting.len() != accounting_map.len() {
|
||||||
|
state.add_metadata(TopAccountingMetadata::new(accounting_map.len()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
state.add_metadata(TopAccountingMetadata::new(accounting_map.len()));
|
||||||
|
}
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
accounting_map,
|
accounting_map,
|
||||||
inner: MinimizerScheduler::with_skip_prob(base, skip_non_favored_prob),
|
inner: MinimizerScheduler::with_skip_prob(base, skip_non_favored_prob),
|
||||||
|
@ -182,7 +182,9 @@ where
|
|||||||
{
|
{
|
||||||
/// Creates a new [`PowerMutationalStage`]
|
/// Creates a new [`PowerMutationalStage`]
|
||||||
pub fn new(state: &mut S, mutator: M, map_observer_name: &O, strat: PowerSchedule) -> Self {
|
pub fn new(state: &mut S, mutator: M, map_observer_name: &O, strat: PowerSchedule) -> Self {
|
||||||
state.add_metadata::<PowerScheduleMetadata>(PowerScheduleMetadata::new(strat));
|
if !state.has_metadata::<PowerScheduleMetadata>() {
|
||||||
|
state.add_metadata::<PowerScheduleMetadata>(PowerScheduleMetadata::new(strat));
|
||||||
|
}
|
||||||
Self {
|
Self {
|
||||||
map_observer_name: map_observer_name.name().to_string(),
|
map_observer_name: map_observer_name.name().to_string(),
|
||||||
mutator,
|
mutator,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user