class

Mica::Testing::FuzzCampaign

Inherits Reference < Object

Runs seeded fuzz cases through a format and tallies what happened.

The format's block parses one input and returns a Trial; anything the block raises is caught here. A case is:

  • accepted when the block returns without an error,
  • rejected when the trial carries a Mica::Error (the only acceptable failure),
  • a crash when the block raises anything that is not a Mica::Error, or returns a trial with failed checks.

Every case is also checked for:

  • budget overruns: operations above the allowance plus the format's check interval (the meter must stop work in time);
  • determinism (when enabled): the same bytes give the same outcome twice.
campaign = Mica::Testing::FuzzCampaign.new(mutator, seed: 7_i64, overrun_slack: 70_000_i64)
report = campaign.run(10_000) do |bytes|
  meter = Mica::Core::WorkMeter.new
  begin
    Mica::XML.parse(bytes, meter: meter)
    Mica::Testing::FuzzCampaign::Trial.new("ok", nil, meter)
  rescue error : Mica::Error
    Mica::Testing::FuzzCampaign::Trial.new(error.message.to_s, error, meter)
  end
end
report.list_of_crashes # => [] of String

Constructors

new(mutator : ByteMutator, seed : Int64, overrun_slack : Int64, check_determinism : Bool = false)

overrun_slack is the most work a format may do between two budget checks; check_determinism runs every case twice.

Source

Instance methods

report
Source
run(count : Int32, first : Int32 = 0, & : Bytes, Int32 -> Trial) : Report

Runs cases first to first + count - 1 and returns the report.

Source

Nested types