Determine whether the current input is smaller than an existing entry in the queue that is favored for a particular bit.
(
state: &mut State,
store: &mut CorpusStore<MultiStream>,
)
| 504 | /// Determine whether the current input is smaller than an existing entry in the queue that is |
| 505 | /// favored for a particular bit. |
| 506 | pub(crate) fn current_state_is_favored( |
| 507 | state: &mut State, |
| 508 | store: &mut CorpusStore<MultiStream>, |
| 509 | ) -> bool { |
| 510 | let len = state.input.total_bytes(); |
| 511 | let mut improvement = false; |
| 512 | for idx in &state.hit_coverage { |
| 513 | let best = store.coverage_hits[idx] |
| 514 | .iter() |
| 515 | .map(|id| (id, &store.test_cases[*id].metadata)) |
| 516 | .min_by_key(|(_, metadata)| metadata.len); |
| 517 | |
| 518 | let Some((id, metadata)) = best |
| 519 | else { |
| 520 | tracing::warn!("No existing input for {idx:#x} but input was not considered new"); |
| 521 | return true; |
| 522 | }; |
| 523 | |
| 524 | if len as f32 * 1.1f32 < metadata.len as f32 { |
| 525 | tracing::debug!( |
| 526 | "new input length {len} is better than existing best input id={id}, len={}, for bit={idx:#x}", |
| 527 | metadata.len |
| 528 | ); |
| 529 | state.new_bits.push(*idx); |
| 530 | improvement = true; |
| 531 | } |
| 532 | } |
| 533 | improvement |
| 534 | } |
| 535 | |
| 536 | static GLOBAL_ID: std::sync::atomic::AtomicU64 = std::sync::atomic::AtomicU64::new(0); |
| 537 |
no test coverage detected