Skip to content

Searching longer

A run tries each property a hundred times or so, at random. Some bugs need an input random tries almost never draw: a header whose first four bytes are a magic number, an option three levels deep. proptastic fuzz searches for as long as you give it, starting from the corpus, and stops at the first counterexample.

Each output here is what the command printed searching a header reader that divides by a count of blocks only the magic bytes CA FE BA BE reach: the one Coverage-guided fuzzing follows through ten searches, at random and guided.

Terminal window
proptastic fuzz --for=20s --only=anyBytesReadAsAHeaderOrNone
Found ─────────────────────────────────────────────────────────────────
✗ HeaderTest#anyBytesReadAsAHeaderOrNone counterexample c657fb13a
anyBytesReadAsAHeaderOrNone failed after 3,112 tries of a search (seed 0xcd66f10181a3a6e4)
shrunk counterexample: bytes = HexFormat.of().parseHex("cafebabe0000")
pin it: .example(HexFormat.of().parseHex("cafebabe0000"))
rerun: proptastic run --only='codec.HeaderTest#anyBytesReadAsAHeaderOrNone()' --seed=0xcd66f10181a3a6e4
Next: proptastic example c657fb13a · or propose: proptastic example c657fb13a --propose --reason="<why>"
Reports build/proptastic/report/report.json · build/proptastic/report/index.html
searched 1.0s · 3,112 tries · found c657fb13a

Where it can start its worker, the search is coverage-guided: proptastic’s agent counts the branches the code under test reaches, in the properties’ own packages unless --cover says others, and the search keeps and changes the inputs that reach a branch none before them did. So it climbs into the code rather than sampling around its entrance. It needs a test JDK of 24 or later, and proptastic-fuzz and proptastic-agent at the project’s proptastic version.

What it found is saved and shrunk as any failure is, so the next run replays it, and proptastic example can pin it.

Terminal window
proptastic fuzz --for=4s
searched 1.0s · 83,645 tries · 11 of 43 branches in codec · nothing found

A search that finds nothing says what it searched, and never that the property passed: a count of branches reached is over the branches loaded, never a share of code it didn’t load.

Without --for, it searches until you stop it. The first Ctrl-C tells the worker to stop, and fuzz says what it searched; a second ends it at once:

Terminal window
proptastic fuzz --only=aShortHeaderIsNone
searched 1.0s · 30,123 tries · 3 of 43 branches in codec · stopped with Ctrl-C, nothing found

Where the agent can’t run, below JDK 24, fuzz runs your build in rounds instead, a fresh seed each, and its first line says it isn’t coverage-guided, and why:

Terminal window
proptastic fuzz --for=20s --only=aShortHeaderIsNone
! host rounds, not coverage-guided: the test JDK is 17, and the agent needs 24
Reports build/proptastic/report/report.json · build/proptastic/report/index.html
searched 1.0s · 40.8M tries · nothing found

The inputs a worker keeps go into .proptastic/fuzz/, beside the corpus, and the next search of the property starts from them, even after a clean; they aren’t added to the corpus. Keep the directory between nightly searches, as the CI examples do, and each night’s search starts where the last one stopped. Rounds add each counterexample they find to the corpus. proptastic fuzz has every option.

Privacy