diff --git a/.clusterfuzzlite/build.sh b/.clusterfuzzlite/build.sh index 7db9375..8c7bc09 100644 --- a/.clusterfuzzlite/build.sh +++ b/.clusterfuzzlite/build.sh @@ -2,5 +2,16 @@ # undocumented dependency go install github.com/AdamKorcz/go-118-fuzz-build@latest go get github.com/AdamKorcz/go-118-fuzz-build/utils + +# workaround https://github.com/AdamKorcz/go-118-fuzz-build/issues/2 +mv testonly/constants.go testonly/constants_fuzz.go +mv testonly/reference_test.go testonly/reference_test_fuzz.go +mv testonly/tree_test.go testonly/tree_test_fuzz.go +mv testonly/tree.go testonly/tree_fuzz.go + # necessary to list each fuzz test explicitly compile_native_go_fuzzer github.com/transparency-dev/merkle/compact FuzzRangeNodes FuzzRangeNodes +compile_native_go_fuzzer github.com/transparency-dev/merkle/testonly FuzzConsistencyProofAndVerify FuzzConsistencyProofAndVerify +compile_native_go_fuzzer github.com/transparency-dev/merkle/testonly FuzzInclusionProofAndVerify FuzzInclusionProofAndVerify +compile_native_go_fuzzer github.com/transparency-dev/merkle/testonly FuzzHashAtAgainstReferenceImplementation FuzzHashAtAgainstReferenceImplementation +compile_native_go_fuzzer github.com/transparency-dev/merkle/testonly FuzzInclusionProofAgainstReferenceImplementation FuzzInclusionProofAgainstReferenceImplementation diff --git a/testonly/tree_fuzz_test.go b/testonly/tree_fuzz_test.go index 9fcbbff..f884017 100644 --- a/testonly/tree_fuzz_test.go +++ b/testonly/tree_fuzz_test.go @@ -4,6 +4,7 @@ package testonly import ( "bytes" + "math" "testing" "github.com/google/go-cmp/cmp" @@ -12,7 +13,7 @@ import ( ) // Compute and verify consistency proofs -func FuzzConsistencyProof(f *testing.F) { +func FuzzConsistencyProofAndVerify(f *testing.F) { for size := 0; size <= 8; size++ { for end := 0; end <= size; end++ { for begin := 0; begin <= end; begin++ { @@ -21,6 +22,10 @@ func FuzzConsistencyProof(f *testing.F) { } } f.Fuzz(func(t *testing.T, size, begin, end uint64) { + // necessary to restrict size for compile_native_go_fuzzer + if size >= math.MaxUint16 { + return + } t.Logf("size=%d, begin=%d, end=%d", size, begin, end) if begin > end || end > size { return @@ -39,13 +44,16 @@ func FuzzConsistencyProof(f *testing.F) { } // Compute and verify inclusion proofs -func FuzzInclusionProof(f *testing.F) { +func FuzzInclusionProofAndVerify(f *testing.F) { for size := 0; size <= 8; size++ { for index := 0; index <= size; index++ { f.Add(uint64(index), uint64(size)) } } f.Fuzz(func(t *testing.T, index, size uint64) { + if size >= math.MaxUint16 { + return + } t.Logf("index=%d, size=%d", index, size) if index >= size { return @@ -70,6 +78,9 @@ func FuzzHashAtAgainstReferenceImplementation(f *testing.F) { } } f.Fuzz(func(t *testing.T, index, size uint64) { + if size >= math.MaxUint16 { + return + } t.Logf("index=%d, size=%d", index, size) if index >= size { return @@ -91,6 +102,9 @@ func FuzzInclusionProofAgainstReferenceImplementation(f *testing.F) { } } f.Fuzz(func(t *testing.T, index, size uint64) { + if size >= math.MaxUint16 { + return + } t.Logf("index=%d, size=%d", index, size) if index >= size { return