diff --git a/examples/outputs/arg-reuse/autofuzzchain_test.go b/examples/outputs/arg-reuse/autofuzzchain_test.go index 45e2ac0..60a1d64 100644 --- a/examples/outputs/arg-reuse/autofuzzchain_test.go +++ b/examples/outputs/arg-reuse/autofuzzchain_test.go @@ -1,6 +1,7 @@ -package argexamplefuzz // rename if needed +package argexamplefuzz + +// Edit if desired. Code generated by "fzgen -chain github.com/thepudds/fzgen/examples/inputs/arg-reuse". -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -17,19 +18,21 @@ func Fuzz_New_Chain(f *testing.F) { target := argexample.New(i) steps := []fuzzer.Step{ - fuzzer.Step{ + { Name: "Fuzz_PanicOnArgReuse_Step1", Func: func(a int64, b int64) { target.Step1(a, b) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_PanicOnArgReuse_Step2", Func: func(a int64, b int64) { target.Step2(a, b) - }}, + }, + }, } // Execute a specific chain of steps, with the count, sequence and arguments controlled by fz.Chain - fz.Chain(steps, nil) + fz.Chain(steps) }) } diff --git a/examples/outputs/go.mod b/examples/outputs/go.mod index 7c5912f..d9e952e 100644 --- a/examples/outputs/go.mod +++ b/examples/outputs/go.mod @@ -8,25 +8,18 @@ go 1.18 replace ( github.com/thepudds/fzgen => ./../.. github.com/thepudds/fzgen/examples/inputs/race-xsync-map => ./../../examples/inputs/race-xsync-map - github.com/thepudds/fzgen/examples/inputs/race-xsync-mpmcqueue => ./../../examples/inputs/race-xsync-mpmcqueue ) require ( + github.com/RoaringBitmap/roaring v0.9.4 github.com/google/uuid v1.3.0 github.com/thepudds/fzgen v0.0.0-00010101000000-000000000000 github.com/thepudds/fzgen/examples/inputs/race-xsync-map v0.0.0-00010101000000-000000000000 - github.com/thepudds/fzgen/examples/inputs/race-xsync-mpmcqueue v0.0.0-00010101000000-000000000000 - golang.zx2c4.com/go118/netip v0.0.0-20211111135330-a4a02eeacf9d - inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 ) require ( - github.com/RoaringBitmap/roaring v0.9.4 // indirect github.com/bits-and-blooms/bitset v1.2.0 // indirect - github.com/google/gofuzz v1.2.0 // indirect github.com/mschoch/smat v0.2.0 // indirect github.com/puzpuzpuz/xsync v1.0.1-0.20210823092703-32778049b5f5 // indirect github.com/sanity-io/litter v1.5.1 // indirect - go4.org/intern v0.0.0-20211027215823-ae77deb06f29 // indirect - go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37 // indirect ) diff --git a/examples/outputs/go.sum b/examples/outputs/go.sum index 6df3c82..e9ee5db 100644 --- a/examples/outputs/go.sum +++ b/examples/outputs/go.sum @@ -3,56 +3,24 @@ github.com/RoaringBitmap/roaring v0.9.4/go.mod h1:icnadbWcNyfEHlYdr+tDlOTih1Bf/h github.com/bits-and-blooms/bitset v1.2.0 h1:Kn4yilvwNtMACtf1eYDlG8H77R07mZSPbMjLyS07ChA= github.com/bits-and-blooms/bitset v1.2.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dvyukov/go-fuzz v0.0.0-20210103155950-6a8e9d1f2415/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= -github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= -github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0 h1:GD+A8+e+wFkqje55/2fOVnZPkoDIu1VooBWfNrnY8Uo= github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/puzpuzpuz/xsync v1.0.1-0.20210823092703-32778049b5f5 h1:ZoUoiy+1+jwi9B2+5F0Mh4HMlI/q01Nqt+qN9T2h5lA= github.com/puzpuzpuz/xsync v1.0.1-0.20210823092703-32778049b5f5/go.mod h1:GF6mnc4fZ1Vit0eWBHPcthv2l1nE81+iZvLsexB/HM4= github.com/sanity-io/litter v1.5.1 h1:dwnrSypP6q56o3lFxTU+t2fwQ9A+U5qrXVO4Qg9KwVU= github.com/sanity-io/litter v1.5.1/go.mod h1:5Z71SvaYy5kcGtyglXOC9rrUi3c1E8CamFWjQsazTh0= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312 h1:UsFdQ3ZmlzS0BqZYGxvYaXvFGUbCmPGy8DM7qWJJiIQ= github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go4.org/intern v0.0.0-20211027215823-ae77deb06f29 h1:UXLjNohABv4S58tHmeuIZDO6e3mHpW2Dx33gaNt03LE= -go4.org/intern v0.0.0-20211027215823-ae77deb06f29/go.mod h1:cS2ma+47FKrLPdXFpr7CuxiTW3eyJbWew4qx0qtQWDA= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37 h1:Tx9kY6yUkLge/pFG7IEMwDZy6CS2ajFc9TvQdPCW0uA= -go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37/go.mod h1:FftLjUGFEDu5k8lt0ddY+HcrH/qU/0qk+H8j9/nTl3E= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.zx2c4.com/go118/netip v0.0.0-20211111135330-a4a02eeacf9d h1:9+v0G0naRhLPOJEeJOL6NuXTtAHHwmkyZlgQJ0XcQ8I= -golang.zx2c4.com/go118/netip v0.0.0-20211111135330-a4a02eeacf9d/go.mod h1:5yyfuiqVIJ7t+3MqrpTQ+QqRkMWiESiyDvPNvKYCecg= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6 h1:acCzuUSQ79tGsM/O50VRFySfMm19IoMKL+sZztZkCxw= -inet.af/netaddr v0.0.0-20211027220019-c74959edd3b6/go.mod h1:y3MGhcFMlh0KZPMuXXow8mpjxxAk3yoDNsp4cQz54i8= diff --git a/examples/outputs/google-uuid/autofuzz_test.go b/examples/outputs/google-uuid/autofuzz_test.go index 0ba3afd..fd2e202 100644 --- a/examples/outputs/google-uuid/autofuzz_test.go +++ b/examples/outputs/google-uuid/autofuzz_test.go @@ -1,6 +1,7 @@ -package uuidfuzz // rename if needed +package uuidfuzz + +// Edit if desired. Code generated by "fzgen -ctor=^FromBytes$ github.com/google/uuid". -// if needed, fill in imports or run 'goimports' import ( "io" "testing" diff --git a/examples/outputs/google-uuid/autofuzzchain_test.go b/examples/outputs/google-uuid/autofuzzchain_test.go index 2f08997..166f898 100644 --- a/examples/outputs/google-uuid/autofuzzchain_test.go +++ b/examples/outputs/google-uuid/autofuzzchain_test.go @@ -1,5 +1,7 @@ package uuidfuzz +// Edit if desired. Code generated by "fzgen -chain -ctor=^FromBytes$ github.com/google/uuid". + import ( "database/sql/driver" "fmt" @@ -10,9 +12,6 @@ import ( "github.com/thepudds/fzgen/fuzzer" ) -// Automatically generated via: -// fzgen -chain -ctor=FromBytes github.com/google/uuid - func Fuzz_FromBytes_Chain(f *testing.F) { f.Fuzz(func(t *testing.T, data []byte) { var b []byte @@ -26,6 +25,7 @@ func Fuzz_FromBytes_Chain(f *testing.F) { steps := []fuzzer.Step{ // skipping Fuzz_UUID_Scan because parameters include unsupported interface: interface{} + { Name: "Fuzz_UUID_UnmarshalBinary", Func: func(d1 []byte) { diff --git a/examples/outputs/race-xsync-map/autofuzzchain_test.go b/examples/outputs/race-xsync-map/autofuzzchain_test.go index 3076321..2090063 100644 --- a/examples/outputs/race-xsync-map/autofuzzchain_test.go +++ b/examples/outputs/race-xsync-map/autofuzzchain_test.go @@ -1,7 +1,6 @@ package xsyncmapfuzz -// generated via: -// fzgen -chain -parallel github.com/thepudds/fzgen/examples/inputs/race-xsyncmap +// Edit if desired. Code generated by "fzgen -chain -parallel github.com/thepudds/fzgen/examples/inputs/race-xsync-map". import ( "testing" @@ -52,6 +51,6 @@ func Fuzz_NewXSyncMap_Chain(f *testing.F) { } // Execute a specific chain of steps, with the count, sequence and arguments controlled by fz.Chain - fz.Chain(steps, fuzzer.ChainOptParallel) + fz.Chain(steps, fuzzer.ChainParallel) }) } diff --git a/examples/outputs/race/autofuzzchain_test.go b/examples/outputs/race/autofuzzchain_test.go index 16bce6e..f9cce1c 100644 --- a/examples/outputs/race/autofuzzchain_test.go +++ b/examples/outputs/race/autofuzzchain_test.go @@ -1,7 +1,6 @@ package raceexamplefuzz -// Automatically generated by: -// fzgen -chain -parallel github.com/thepudds/fzgen/examples/inputs/race +// Edit if desired. Code generated by "fzgen -chain -parallel github.com/thepudds/fzgen/examples/inputs/race". import ( "testing" diff --git a/examples/outputs/roaring/autofuzzchain_test.go b/examples/outputs/roaring/autofuzzchain_test.go index feece70..1870380 100644 --- a/examples/outputs/roaring/autofuzzchain_test.go +++ b/examples/outputs/roaring/autofuzzchain_test.go @@ -1,8 +1,11 @@ -package roaringfuzz // rename if needed +package roaringfuzz + +// Edit if desired. Code generated by "fzgen -chain -ctor=^NewBitmap$ github.com/RoaringBitmap/roaring". -// if needed, fill in imports or run 'goimports' import ( + "fmt" "io" + "reflect" "testing" "github.com/RoaringBitmap/roaring" @@ -16,278 +19,351 @@ func Fuzz_NewBitmap_Chain(f *testing.F) { target := roaring.NewBitmap() steps := []fuzzer.Step{ - fuzzer.Step{ + { Name: "Fuzz_Bitmap_Add", Func: func(x uint32) { target.Add(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_AddInt", Func: func(x int) { target.AddInt(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_AddMany", Func: func(dat []uint32) { target.AddMany(dat) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_AddRange", Func: func(rangeStart uint64, rangeEnd uint64) { target.AddRange(rangeStart, rangeEnd) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_And", Func: func(x2 *roaring.Bitmap) { target.And(x2) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_AndAny", Func: func(bitmaps []*roaring.Bitmap) { target.AndAny(bitmaps...) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_AndCardinality", Func: func(x2 *roaring.Bitmap) uint64 { return target.AndCardinality(x2) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_AndNot", Func: func(x2 *roaring.Bitmap) { target.AndNot(x2) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_CheckedAdd", Func: func(x uint32) bool { return target.CheckedAdd(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_CheckedRemove", Func: func(x uint32) bool { return target.CheckedRemove(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Clear", Func: func() { target.Clear() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Clone", Func: func() *roaring.Bitmap { return target.Clone() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_CloneCopyOnWriteContainers", Func: func() { target.CloneCopyOnWriteContainers() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Contains", Func: func(x uint32) bool { return target.Contains(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ContainsInt", Func: func(x int) bool { return target.ContainsInt(x) - }}, + }, + }, // skipping Fuzz_Bitmap_Equals because parameters include unsupported interface: interface{} - fuzzer.Step{ + { Name: "Fuzz_Bitmap_Flip", Func: func(rangeStart uint64, rangeEnd uint64) { target.Flip(rangeStart, rangeEnd) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_FlipInt", Func: func(rangeStart int, rangeEnd int) { target.FlipInt(rangeStart, rangeEnd) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Freeze", Func: func() ([]byte, error) { return target.Freeze() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_FreezeTo", Func: func(buf []byte) (int, error) { return target.FreezeTo(buf) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_FromBase64", Func: func(str string) (int64, error) { return target.FromBase64(str) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_FromBuffer", Func: func(buf []byte) (int64, error) { return target.FromBuffer(buf) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_FrozenView", Func: func(buf []byte) { target.FrozenView(buf) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_GetCardinality", Func: func() uint64 { return target.GetCardinality() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_GetCopyOnWrite", Func: func() bool { return target.GetCopyOnWrite() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_GetFrozenSizeInBytes", Func: func() uint64 { return target.GetFrozenSizeInBytes() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_GetSerializedSizeInBytes", Func: func() uint64 { return target.GetSerializedSizeInBytes() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_GetSizeInBytes", Func: func() uint64 { return target.GetSizeInBytes() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_HasRunCompression", Func: func() bool { return target.HasRunCompression() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Intersects", Func: func(x2 *roaring.Bitmap) bool { return target.Intersects(x2) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_IsEmpty", Func: func() bool { return target.IsEmpty() - }}, + }, + }, // skipping Fuzz_Bitmap_Iterate because parameters include unsupported func or chan: func(x uint32) bool - fuzzer.Step{ + { Name: "Fuzz_Bitmap_Iterator", Func: func() roaring.IntPeekable { return target.Iterator() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ManyIterator", Func: func() roaring.ManyIntIterable { return target.ManyIterator() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_MarshalBinary", Func: func() ([]byte, error) { return target.MarshalBinary() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Maximum", Func: func() uint32 { return target.Maximum() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Minimum", Func: func() uint32 { return target.Minimum() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Or", Func: func(x2 *roaring.Bitmap) { target.Or(x2) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_OrCardinality", Func: func(x2 *roaring.Bitmap) uint64 { return target.OrCardinality(x2) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Rank", Func: func(x uint32) uint64 { return target.Rank(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ReadFrom", Func: func(reader io.Reader, cookieHeader []byte) (int64, error) { return target.ReadFrom(reader, cookieHeader...) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Remove", Func: func(x uint32) { target.Remove(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_RemoveRange", Func: func(rangeStart uint64, rangeEnd uint64) { target.RemoveRange(rangeStart, rangeEnd) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ReverseIterator", Func: func() roaring.IntIterable { return target.ReverseIterator() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_RunOptimize", Func: func() { target.RunOptimize() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Select", Func: func(x uint32) (uint32, error) { return target.Select(x) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_SetCopyOnWrite", Func: func(val bool) { target.SetCopyOnWrite(val) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Stats", Func: func() roaring.Statistics { return target.Stats() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_String", Func: func() string { return target.String() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ToArray", Func: func() []uint32 { return target.ToArray() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ToBase64", Func: func() (string, error) { return target.ToBase64() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_ToBytes", Func: func() ([]byte, error) { return target.ToBytes() - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_UnmarshalBinary", Func: func(d1 []byte) { target.UnmarshalBinary(d1) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_WriteTo", Func: func(stream io.Writer) (int64, error) { return target.WriteTo(stream) - }}, - fuzzer.Step{ + }, + }, + { Name: "Fuzz_Bitmap_Xor", Func: func(x2 *roaring.Bitmap) { target.Xor(x2) - }}, + }, + }, } // Execute a specific chain of steps, with the count, sequence and arguments controlled by fz.Chain fz.Chain(steps) + + // Validate with some roundtrip checks. These can be edited or deleted if not appropriate for your target. + // Check MarshalBinary. + result2, err := target.MarshalBinary() + if err != nil { + // Some targets should never return an error here for an object created by a constructor. + // If that is the case for your target, you can change this to a panic(err) or t.Fatal. + return + } + + // Check UnmarshalBinary. + var tmp2 *roaring.Bitmap + err = tmp2.UnmarshalBinary(result2) + if err != nil { + panic(fmt.Sprintf("UnmarshalBinary failed after successful MarshalBinary. original: %v %#v marshalled: %q error: %v", target, target, result2, err)) + } + if !reflect.DeepEqual(target, tmp2) { + panic(fmt.Sprintf("MarshalBinary/UnmarshalBinary roundtrip equality failed. original: %v %#v marshalled: %q unmarshalled: %v %#v", + target, target, result2, tmp2, tmp2)) + } }) } diff --git a/examples/outputs/stdlib-encoding-ascii85/autofuzz_test.go b/examples/outputs/stdlib-encoding-ascii85/autofuzz_test.go index 6d9e602..8050f82 100644 --- a/examples/outputs/stdlib-encoding-ascii85/autofuzz_test.go +++ b/examples/outputs/stdlib-encoding-ascii85/autofuzz_test.go @@ -1,6 +1,7 @@ -package ascii85fuzz // rename if needed +package ascii85fuzz + +// Edit if desired. Code generated by "fzgen encoding/ascii85". -// if needed, fill in imports or run 'goimports' import ( "encoding/ascii85" "io" diff --git a/gen/fzgen.go b/gen/fzgen.go index 0081ba0..37451d2 100644 --- a/gen/fzgen.go +++ b/gen/fzgen.go @@ -52,7 +52,10 @@ as are functions that have unsupported parameters such as a channel. ` -var debugForceLocal bool +var ( + debugForceLocal bool + debugForceNoTopComment bool +) func FzgenMain() int { // handle flags @@ -65,7 +68,7 @@ func FzgenMain() int { chainFlag := flag.Bool("chain", false, "loop over the methods of an object, which requires finding a suitable constructor in the same package and which is controllable via the -ctor flag.") parallelFlag := flag.Bool("parallel", false, "indicates an emitted chain can be run in parallel. requires -chain") outFileFlag := flag.String("o", "autofuzz_test.go", "output file name. defaults to autofuzz_test.go or autofuzzchain_test.go") - constructorPatternFlag := flag.String("ctor", "^New", "regexp to use if searching for constructors to automatically use.") + constructorPatternFlag := flag.String("ctor", ".", "regexp to use if searching for constructors to automatically use.") // Less commonly used: funcPatternFlag := flag.String("func", ".", "function regex, defaults to matching all candidate functions") @@ -88,7 +91,7 @@ func FzgenMain() int { } if *parallelFlag && !*chainFlag { - fmt.Fprint(os.Stderr, "fzgen: error: -parallel flag requires -chain\n") + fmt.Fprint(os.Stderr, "fzgen: -parallel flag requires -chain\n") return 2 } @@ -103,13 +106,13 @@ func FzgenMain() int { } pkgs, err := findFuncsGrouped(pkgPattern, *funcPatternFlag, *constructorPatternFlag, options) if err != nil { - fmt.Fprintf(os.Stderr, "fzgen: error: %v\n", err) + fmt.Fprintf(os.Stderr, "fzgen: %v\n", err) return 1 } // Check if we are looking at one package vs. multiple. if len(pkgs) > 1 && hasPath(*outFileFlag) { - fmt.Fprint(os.Stderr, "fzgen: error: -o can only specify a file name and not a path when the package pattern matches multiple packages\n") + fmt.Fprint(os.Stderr, "fzgen:-o can only specify a file name and not a path when the package pattern matches multiple packages\n") return 2 } @@ -118,6 +121,13 @@ func FzgenMain() int { fail(err) } + var topComment string + if !debugForceNoTopComment { + args := os.Args[1 : len(os.Args)-flag.NArg()] + args = append(args, []string{pkgPattern}...) + topComment = fmt.Sprintf(topCommentTmpl, strings.Join(args, " ")) + } + // Loop over our packages, and start our real work. var generatedFiles int for i := range pkgs { @@ -168,6 +178,7 @@ func FzgenMain() int { qualifyAll: qualifyAll, insertConstructors: *constructorFlag, parallel: *parallelFlag, + topComment: topComment, } // Do the actual work of emitting our wrappers. @@ -313,5 +324,19 @@ func init() { debugForceLocal = true } } + if strings.HasPrefix(f, "notopcomment=") { + debugVal, err := strconv.Atoi(strings.TrimPrefix(f, "notopcomment=")) + if err != nil || debugVal > 1 { + panic("unexpected notopcomment value in FZDEBUG env var") + } + if debugVal == 1 { + debugForceNoTopComment = true + } + } } } + +var topCommentTmpl string = ` +// Edit if desired. Code generated by "fzgen %s". + +` diff --git a/gen/genfuncs.go b/gen/genfuncs.go index 9d97a9a..00e35a8 100644 --- a/gen/genfuncs.go +++ b/gen/genfuncs.go @@ -14,9 +14,10 @@ import ( ) type wrapperOptions struct { - qualifyAll bool // qualify all variables with package name - insertConstructors bool // attempt to insert suitable constructors when wrapping methods - parallel bool // set the Parallel flag in the emitted code, which allows steps of a chain to run in parallel + qualifyAll bool // qualify all variables with package name + insertConstructors bool // attempt to insert suitable constructors when wrapping methods + parallel bool // set the Parallel flag in the emitted code, which allows steps of a chain to run in parallel + topComment string // additional comment for top of generated file. } type emitFunc func(format string, args ...interface{}) @@ -47,7 +48,7 @@ func emitIndependentWrappers(pkgPath string, pkgFuncs *pkg, wrapperPkgName strin // emit the intro material emit("package %s\n\n", wrapperPkgName) - emit("// if needed, fill in imports or run 'goimports'\n") + emit(options.topComment) emit("import (\n") emit("\t\"testing\"\n") if options.qualifyAll { @@ -72,8 +73,17 @@ func emitIndependentWrappers(pkgPath string, pkgFuncs *pkg, wrapperPkgName strin for _, function := range pkgFuncs.functions { var constructors []mod.Func if options.insertConstructors { - constructors = pkgFuncs.constructors + for _, constructor := range pkgFuncs.constructors { + // Skip over any candidate constructors with unsupported params. + ctorInputParams := params(constructor.TypesFunc) + support, _ := checkParamSupport(ctorInputParams) + if support == noSupport { + continue + } + constructors = append(constructors, constructor) + } } + err := emitIndependentWrapper(emit, function, constructors, options.qualifyAll) if err != nil && firstErr == nil { firstErr = err @@ -182,10 +192,12 @@ func emitIndependentWrapper(emit emitFunc, function mod.Func, constructors []mod // Check if we have an interface or function pointer in our desired parameters, // which we can't fill with values during fuzzing. - support, unsupportedParam := checkParamSupport(emit, inputParams, wrapperName) + + support, unsupportedParam := checkParamSupport(inputParams) if support == noSupport { - // skip this wrapper. disallowedParams emitted a comment with more details. - return fmt.Errorf("%w: %s", errUnsupportedParams, unsupportedParam) + // skip this wrapper. + emit("// skipping %s because parameters include func, chan, or unsupported interface: %v\n\n", wrapperName, unsupportedParam) + return fmt.Errorf("%w: %s takes %s", errUnsupportedParams, function.FuncName, unsupportedParam) } // Start emitting the wrapper function! @@ -374,7 +386,7 @@ const ( // checkParamSupport reports the level of support across the input parameters. // It stops checking if it finds a param that is noSupport. // TODO: this is currently focuses on excluding the most common problems, and defaults to trying nativeSupport (which might cause cmd/go to complain). -func checkParamSupport(emit emitFunc, allWrapperParams []*types.Var, wrapperName string) (paramSupport, string) { +func checkParamSupport(allWrapperParams []*types.Var) (paramSupport, string) { res := unknown if len(allWrapperParams) == 0 { // An easy case that is handled by cmd/go is no params at all. @@ -438,12 +450,10 @@ func checkParamSupport(emit emitFunc, allWrapperParams []*types.Var, wrapperName switch t.Underlying().(type) { case *types.Interface: if !fuzzer.SupportedInterfaces[t.String()] { - emit("// skipping %s because parameters include unsupported interface: %v\n\n", wrapperName, v.Type()) return noSupport, v.Type().String() } res = min(fillRequired, res) case *types.Signature, *types.Chan: - emit("// skipping %s because parameters include unsupported func or chan: %v\n\n", wrapperName, v.Type()) return noSupport, v.Type().String() } @@ -665,6 +675,23 @@ func receiver(f *types.Func) *types.Named { return n } +// params expects a *types.Func that is type *types.Signature, +// and returns a []*types.Var for the parameters. +// This does not include the receiver for a method. +// params returns nil if f is not type *types.Signature. +func params(f *types.Func) []*types.Var { + wrappedSig, ok := f.Type().(*types.Signature) + if !ok { + return nil + } + var inputParams []*types.Var + for i := 0; i < wrappedSig.Params().Len(); i++ { + v := wrappedSig.Params().At(i) + inputParams = append(inputParams, v) + } + return inputParams +} + // constructorResult expects a *types.Func that is type *types.Signature, // and returns the *types.Named for the first returned result. It allows // a single return result or two returned results if the second is of type error. diff --git a/gen/genfuncsloop.go b/gen/genfuncsloop.go index fafcb12..8f260cd 100644 --- a/gen/genfuncsloop.go +++ b/gen/genfuncsloop.go @@ -86,8 +86,7 @@ func emitChainWrappers(pkgPath string, pkgFuncs *pkg, wrapperPkgName string, opt // Emit the intro material emit("package %s\n\n", wrapperPkgName) - // TODO: also remove this trailing comment, probably - emit("// if needed, fill in imports or run 'goimports'\n") + emit(options.topComment) emit("import (\n") emit("\t\"testing\"\n") if options.qualifyAll { @@ -323,10 +322,11 @@ func emitChainTarget(emit emitFunc, function mod.Func, qualifyAll bool) error { // Check if we have an interface or function pointer in our desired parameters, // which we can't fill with values during fuzzing. - support, _ := checkParamSupport(emit, inputParams, wrapperName) + support, unsupportedParam := checkParamSupport(inputParams) if support == noSupport { // we can't emit this chain target. - return errUnsupportedParams + emit("// skipping %s because parameters include func, chan, or unsupported interface: %v\n\n", wrapperName, unsupportedParam) + return fmt.Errorf("%w: %s takes %s", errUnsupportedParams, function.FuncName, unsupportedParam) } // Start emitting the wrapper function! @@ -467,9 +467,10 @@ func emitChainStep(emit emitFunc, function mod.Func, constructor mod.Func, quali // Check if we have an interface or function pointer in our desired parameters, // which we can't fill with values during fuzzing. - support, _ := checkParamSupport(emit, inputParams, wrapperName) + support, unsupportedParam := checkParamSupport(inputParams) if support == noSupport { - // skip this wrapper. disallowedParams emitted a comment with more details. + // skip this wrapper. + emit("// skipping %s because parameters include func, chan, or unsupported interface: %v\n\n", wrapperName, unsupportedParam) return errSilentSkip } diff --git a/testdata/exported_and_private_local_pkg.go b/testdata/exported_and_private_local_pkg.go index 1590727..98a075c 100644 --- a/testdata/exported_and_private_local_pkg.go +++ b/testdata/exported_and_private_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "testing" @@ -124,7 +123,7 @@ func Fuzz_FuncExportedUsesSupportedInterface(f *testing.F) { }) } -// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface +// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include func, chan, or unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface func Fuzz_funcNotExported(f *testing.F) { f.Fuzz(func(t *testing.T, i int) { diff --git a/testdata/exported_and_private_not_local_pkg.go b/testdata/exported_and_private_not_local_pkg.go index c36027a..ce3a1f1 100644 --- a/testdata/exported_and_private_not_local_pkg.go +++ b/testdata/exported_and_private_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "testing" @@ -125,7 +124,7 @@ func Fuzz_FuncExportedUsesSupportedInterface(f *testing.F) { }) } -// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface +// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include func, chan, or unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface func Fuzz_funcNotExported(f *testing.F) { f.Fuzz(func(t *testing.T, i int) { diff --git a/testdata/exported_local_pkg.go b/testdata/exported_local_pkg.go index 02b8c4b..8dc16c2 100644 --- a/testdata/exported_local_pkg.go +++ b/testdata/exported_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "testing" @@ -49,4 +48,4 @@ func Fuzz_FuncExportedUsesSupportedInterface(f *testing.F) { }) } -// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface +// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include func, chan, or unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface diff --git a/testdata/exported_not_local_pkg.go b/testdata/exported_not_local_pkg.go index 8726bcb..ce363ea 100644 --- a/testdata/exported_not_local_pkg.go +++ b/testdata/exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "testing" @@ -50,4 +49,4 @@ func Fuzz_FuncExportedUsesSupportedInterface(f *testing.F) { }) } -// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface +// skipping Fuzz_FuncExportedUsesUnsupportedInterface because parameters include func, chan, or unsupported interface: github.com/thepudds/fzgen/examples/inputs/test-exported.ExportedInterface diff --git a/testdata/inject_ctor_false_exported_local_pkg.go b/testdata/inject_ctor_false_exported_local_pkg.go index a2c04e6..71f9055 100644 --- a/testdata/inject_ctor_false_exported_local_pkg.go +++ b/testdata/inject_ctor_false_exported_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "bufio" "testing" diff --git a/testdata/inject_ctor_false_exported_not_local_pkg.go b/testdata/inject_ctor_false_exported_not_local_pkg.go index bced099..2ec53b1 100644 --- a/testdata/inject_ctor_false_exported_not_local_pkg.go +++ b/testdata/inject_ctor_false_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "bufio" "testing" diff --git a/testdata/inject_ctor_true_exported_local_pkg.go b/testdata/inject_ctor_true_exported_local_pkg.go index c8ed2c0..b9d6a23 100644 --- a/testdata/inject_ctor_true_exported_local_pkg.go +++ b/testdata/inject_ctor_true_exported_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "bufio" "testing" diff --git a/testdata/inject_ctor_true_exported_not_local_pkg.go b/testdata/inject_ctor_true_exported_not_local_pkg.go index dca1dcf..63d0e68 100644 --- a/testdata/inject_ctor_true_exported_not_local_pkg.go +++ b/testdata/inject_ctor_true_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "bufio" "testing" diff --git a/testdata/nil_checks_exported_not_local_pkg.go b/testdata/nil_checks_exported_not_local_pkg.go index 79e7cac..7bc3417 100644 --- a/testdata/nil_checks_exported_not_local_pkg.go +++ b/testdata/nil_checks_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "testing" diff --git a/testdata/race_exported_local_pkg.go b/testdata/race_exported_local_pkg.go index a86081f..4578c79 100644 --- a/testdata/race_exported_local_pkg.go +++ b/testdata/race_exported_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "testing" diff --git a/testdata/race_exported_not_local_pkg.go b/testdata/race_exported_not_local_pkg.go index 70678d8..084d8d7 100644 --- a/testdata/race_exported_not_local_pkg.go +++ b/testdata/race_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "testing" diff --git a/testdata/strings_inject_ctor_false_exported_local_pkg.go b/testdata/strings_inject_ctor_false_exported_local_pkg.go index 03b1b22..daba29f 100644 --- a/testdata/strings_inject_ctor_false_exported_local_pkg.go +++ b/testdata/strings_inject_ctor_false_exported_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "testing" @@ -280,7 +279,7 @@ func Fuzz_Fields(f *testing.F) { }) } -// skipping Fuzz_FieldsFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_FieldsFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_HasPrefix(f *testing.F) { f.Fuzz(func(t *testing.T, s string, prefix string) { @@ -312,7 +311,7 @@ func Fuzz_IndexByte(f *testing.F) { }) } -// skipping Fuzz_IndexFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_IndexFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_IndexRune(f *testing.F) { f.Fuzz(func(t *testing.T, s string, r rune) { @@ -349,9 +348,9 @@ func Fuzz_LastIndexByte(f *testing.F) { }) } -// skipping Fuzz_LastIndexFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_LastIndexFunc because parameters include func, chan, or unsupported interface: func(rune) bool -// skipping Fuzz_Map because parameters include unsupported func or chan: func(rune) rune +// skipping Fuzz_Map because parameters include func, chan, or unsupported interface: func(rune) rune func Fuzz_NewReader(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { @@ -480,7 +479,7 @@ func Fuzz_Trim(f *testing.F) { }) } -// skipping Fuzz_TrimFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimLeft(f *testing.F) { f.Fuzz(func(t *testing.T, s string, cutset string) { @@ -488,7 +487,7 @@ func Fuzz_TrimLeft(f *testing.F) { }) } -// skipping Fuzz_TrimLeftFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimLeftFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimPrefix(f *testing.F) { f.Fuzz(func(t *testing.T, s string, prefix string) { @@ -502,7 +501,7 @@ func Fuzz_TrimRight(f *testing.F) { }) } -// skipping Fuzz_TrimRightFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimRightFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimSpace(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { diff --git a/testdata/strings_inject_ctor_false_exported_not_local_pkg.go b/testdata/strings_inject_ctor_false_exported_not_local_pkg.go index 879d73b..9c5a54d 100644 --- a/testdata/strings_inject_ctor_false_exported_not_local_pkg.go +++ b/testdata/strings_inject_ctor_false_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "strings" @@ -353,7 +352,7 @@ func Fuzz_Fields(f *testing.F) { }) } -// skipping Fuzz_FieldsFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_FieldsFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_HasPrefix(f *testing.F) { f.Fuzz(func(t *testing.T, s string, prefix string) { @@ -385,7 +384,7 @@ func Fuzz_IndexByte(f *testing.F) { }) } -// skipping Fuzz_IndexFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_IndexFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_IndexRune(f *testing.F) { f.Fuzz(func(t *testing.T, s string, r rune) { @@ -422,9 +421,9 @@ func Fuzz_LastIndexByte(f *testing.F) { }) } -// skipping Fuzz_LastIndexFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_LastIndexFunc because parameters include func, chan, or unsupported interface: func(rune) bool -// skipping Fuzz_Map because parameters include unsupported func or chan: func(rune) rune +// skipping Fuzz_Map because parameters include func, chan, or unsupported interface: func(rune) rune func Fuzz_NewReader(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { @@ -553,7 +552,7 @@ func Fuzz_Trim(f *testing.F) { }) } -// skipping Fuzz_TrimFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimLeft(f *testing.F) { f.Fuzz(func(t *testing.T, s string, cutset string) { @@ -561,7 +560,7 @@ func Fuzz_TrimLeft(f *testing.F) { }) } -// skipping Fuzz_TrimLeftFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimLeftFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimPrefix(f *testing.F) { f.Fuzz(func(t *testing.T, s string, prefix string) { @@ -575,7 +574,7 @@ func Fuzz_TrimRight(f *testing.F) { }) } -// skipping Fuzz_TrimRightFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimRightFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimSpace(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { diff --git a/testdata/strings_inject_ctor_true_exported_not_local_pkg.go b/testdata/strings_inject_ctor_true_exported_not_local_pkg.go index e764be6..fdaa949 100644 --- a/testdata/strings_inject_ctor_true_exported_not_local_pkg.go +++ b/testdata/strings_inject_ctor_true_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "io" "strings" @@ -281,7 +280,7 @@ func Fuzz_Fields(f *testing.F) { }) } -// skipping Fuzz_FieldsFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_FieldsFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_HasPrefix(f *testing.F) { f.Fuzz(func(t *testing.T, s string, prefix string) { @@ -313,7 +312,7 @@ func Fuzz_IndexByte(f *testing.F) { }) } -// skipping Fuzz_IndexFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_IndexFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_IndexRune(f *testing.F) { f.Fuzz(func(t *testing.T, s string, r rune) { @@ -350,9 +349,9 @@ func Fuzz_LastIndexByte(f *testing.F) { }) } -// skipping Fuzz_LastIndexFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_LastIndexFunc because parameters include func, chan, or unsupported interface: func(rune) bool -// skipping Fuzz_Map because parameters include unsupported func or chan: func(rune) rune +// skipping Fuzz_Map because parameters include func, chan, or unsupported interface: func(rune) rune func Fuzz_NewReader(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { @@ -481,7 +480,7 @@ func Fuzz_Trim(f *testing.F) { }) } -// skipping Fuzz_TrimFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimLeft(f *testing.F) { f.Fuzz(func(t *testing.T, s string, cutset string) { @@ -489,7 +488,7 @@ func Fuzz_TrimLeft(f *testing.F) { }) } -// skipping Fuzz_TrimLeftFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimLeftFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimPrefix(f *testing.F) { f.Fuzz(func(t *testing.T, s string, prefix string) { @@ -503,7 +502,7 @@ func Fuzz_TrimRight(f *testing.F) { }) } -// skipping Fuzz_TrimRightFunc because parameters include unsupported func or chan: func(rune) bool +// skipping Fuzz_TrimRightFunc because parameters include func, chan, or unsupported interface: func(rune) bool func Fuzz_TrimSpace(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { diff --git a/testdata/types_exported_not_local_pkg.go b/testdata/types_exported_not_local_pkg.go index 944f0e3..30860fb 100644 --- a/testdata/types_exported_not_local_pkg.go +++ b/testdata/types_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "context" "io" @@ -61,7 +60,7 @@ func Fuzz_Std_ListenPacket(f *testing.F) { }) } -// skipping Fuzz_Discard because parameters include unsupported interface: []interface{} +// skipping Fuzz_Discard because parameters include func, chan, or unsupported interface: []interface{} func Fuzz_Discard2(f *testing.F) { f.Fuzz(func(t *testing.T, data []byte) { @@ -114,7 +113,7 @@ func Fuzz_InterfacesShortList(f *testing.F) { }) } -// skipping Fuzz_InterfacesSkip because parameters include unsupported interface: net.Conn +// skipping Fuzz_InterfacesSkip because parameters include func, chan, or unsupported interface: net.Conn func Fuzz_Short1(f *testing.F) { f.Fuzz(func(t *testing.T, x1 int) { @@ -233,6 +232,6 @@ func Fuzz_TypesShortListNoFill(f *testing.F) { }) } -// skipping Fuzz_TypesShortListSkip1 because parameters include unsupported func or chan: chan bool +// skipping Fuzz_TypesShortListSkip1 because parameters include func, chan, or unsupported interface: chan bool -// skipping Fuzz_TypesShortListSkip2 because parameters include unsupported func or chan: func(int) +// skipping Fuzz_TypesShortListSkip2 because parameters include func, chan, or unsupported interface: func(int) diff --git a/testdata/uuid_exported_local_pkg.go b/testdata/uuid_exported_local_pkg.go index ebd13ab..da02e12 100644 --- a/testdata/uuid_exported_local_pkg.go +++ b/testdata/uuid_exported_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "fmt" "reflect" diff --git a/testdata/uuid_exported_not_local_pkg.go b/testdata/uuid_exported_not_local_pkg.go index 54fccd1..897ccca 100644 --- a/testdata/uuid_exported_not_local_pkg.go +++ b/testdata/uuid_exported_not_local_pkg.go @@ -1,6 +1,5 @@ package examplefuzz -// if needed, fill in imports or run 'goimports' import ( "fmt" "reflect" diff --git a/testscripts/external_tailscale.txt b/testscripts/external_tailscale.txt index ebf9591..eed71c6 100644 --- a/testscripts/external_tailscale.txt +++ b/testscripts/external_tailscale.txt @@ -23,10 +23,10 @@ exec gotip mod tidy exec gotip get github.com/thepudds/fzgen/fuzzer exec gotip get -d ./... fzgen ./... -# stdout 'fzgen: created 108 files' +stdout 'fzgen: created 91 files' exec gotip test -exec=true ./... fzgen -chain -ctor=. ./... -# stdout 'fzgen: created 23 files' +stdout 'fzgen: created 23 files' exec gotip test -exec=true ./... exec bash -c 'find . -name "autofuzz_test.go" -exec egrep -L "^W*func" {} \; | wc -l' stdout '^0$' diff --git a/testscripts/external_terraform_chain.txt b/testscripts/external_terraform_chain.txt index 20133e8..17df1db 100644 --- a/testscripts/external_terraform_chain.txt +++ b/testscripts/external_terraform_chain.txt @@ -22,7 +22,7 @@ exec gotip mod tidy exec gotip get github.com/thepudds/fzgen/fuzzer exec gotip get -d ./... fzgen -chain -ctor=. ./... -# stdout 'fzgen: created 37 files' +stdout 'fzgen: created 37 files' exec gotip test -exec=true ./... exec bash -c 'find . -name "autofuzzchain_test.go" -exec egrep -L "^W*func" {} \; | wc -l' stdout '^0$' diff --git a/testscripts/external_terraform_nochain.txt b/testscripts/external_terraform_nochain.txt index bc77aa9..0ea2ca0 100644 --- a/testscripts/external_terraform_nochain.txt +++ b/testscripts/external_terraform_nochain.txt @@ -22,7 +22,7 @@ exec gotip mod tidy exec gotip get github.com/thepudds/fzgen/fuzzer exec gotip get -d ./... fzgen ./... -# stdout 'fzgen: created 109 files' +stdout 'fzgen: created 100 files' exec gotip test -exec=true ./... exec bash -c 'find . -name "autofuzz_test.go" -exec egrep -L "^W*func" {} \; | wc -l' stdout '^0$' diff --git a/testscripts/package_patterns.txt b/testscripts/package_patterns.txt index 0e03605..9ff0092 100644 --- a/testscripts/package_patterns.txt +++ b/testscripts/package_patterns.txt @@ -5,6 +5,10 @@ # To update the golden files: # go test -run=./patterns -end2end -update +# Disable emitting the command line arguments in a comment +# to make it easier to compare golden files created in different ways. +env FZDEBUG=notopcomment=1 + # No arguments creates an autofuzz_test.go in the current directory. fzgen cmp autofuzz_test.go testdata/outer/autofuzz_test.go @@ -130,7 +134,6 @@ func (i InnerInt2) Foo(a InnerInt2) {} -- testdata/outer/autofuzz_test.go -- package outer -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -150,7 +153,6 @@ func Fuzz_OuterInt_Foo(f *testing.F) { -- testdata/inner1/autofuzz_test.go -- package inner1 -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -170,7 +172,6 @@ func Fuzz_InnerInt1_Foo(f *testing.F) { -- testdata/inner2/autofuzz_test.go -- package inner2 -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -190,7 +191,6 @@ func Fuzz_InnerInt2_Foo(f *testing.F) { -- testdata/outer/autofuzzchain_test.go -- package outer -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -219,7 +219,6 @@ func Fuzz_New_Chain(f *testing.F) { -- testdata/inner1/autofuzzchain_test.go -- package inner1 -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -248,7 +247,6 @@ func Fuzz_New_Chain(f *testing.F) { -- testdata/inner2/autofuzzchain_test.go -- package inner2 -// if needed, fill in imports or run 'goimports' import ( "testing" @@ -277,7 +275,6 @@ func Fuzz_New_Chain(f *testing.F) { -- testdata/inner1_not_local/autofuzz_test.go -- package outer -// if needed, fill in imports or run 'goimports' import ( "example/inner1" "testing" @@ -298,7 +295,6 @@ func Fuzz_InnerInt1_Foo(f *testing.F) { -- testdata/inner1_not_local_dest_is_empty/autofuzz_test.go -- package inner1fuzz -// if needed, fill in imports or run 'goimports' import ( "example/inner1" "testing"