diff --git a/Makefile b/Makefile index 99126dfe..69335c8f 100644 --- a/Makefile +++ b/Makefile @@ -95,10 +95,13 @@ update-gomod: GOPROXY=direct go get -d github.com/wader/gojq@fq go mod tidy +# Usage: make fuzz # fuzz all foramts +# Usage: make fuzz GROUP=mp4 # fuzz a group (each format is a group also) # TODO: as decode recovers panic and "repanics" unrecoverable errors this is a bit hacky at the moment -# fuzz code is not suppose to print to stderr so log to file # Retrigger: +# try to decode crsash with all formats: # cat format/testdata/fuzz/FuzzFormats/... | go run dev/fuzzbytes.go | go run . -d raw '. as $b | formats | keys[] as $f | $b | decode($f)' +# convert crash into raw bytes: # cat format/testdata/fuzz/FuzzFormats/... | go run dev/fuzzbytes.go | fq -d raw 'tobytes | tobase64' # fq -n '"..." | frombase64 | ...' .PHONY: fuzz diff --git a/format/fuzz_test.go b/format/fuzz_test.go index e51952e3..783b3226 100644 --- a/format/fuzz_test.go +++ b/format/fuzz_test.go @@ -66,7 +66,7 @@ func (ft *fuzzTest) Readline(opts interp.ReadlineOpts) (string, error) { func FuzzFormats(f *testing.F) { if os.Getenv("FUZZTEST") == "" { - f.Skip("run with FUZZTEST=1 do fuzz") + f.Skip("run with FUZZTEST=1 to fuzz") } i := 0 @@ -103,7 +103,18 @@ func FuzzFormats(f *testing.F) { } gi := 0 - g := interp.DefaultRegistry.MustAll() + var g decode.Group + + if n := os.Getenv("GROUP"); n != "" { + var err error + g, err = interp.DefaultRegistry.FormatGroup(n) + if err != nil { + f.Fatal(err) + } + f.Logf("GROUP=%s", n) + } else { + g = interp.DefaultRegistry.MustAll() + } f.Fuzz(func(t *testing.T, b []byte) { fz := &fuzzTest{b: b, f: g[gi]}