github.com/cockroachdb/cockroachdb-parser@v0.23.3-0.20240213214944-911057d40c9a/pkg/util/uuid/fuzz.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Use of this software is governed by the Business Source License 4 // included in the file licenses/BSL.txt. 5 // 6 // As of the Change Date specified in that file, in accordance with 7 // the Business Source License, use of this software will be governed 8 // by the Apache License, Version 2.0, included in the file 9 // licenses/APL.txt. 10 11 // Copyright (c) 2018 Andrei Tudor Călin <mail@acln.ro> 12 // Use of this source code is governed by a MIT-style 13 // license that can be found in licenses/MIT-gofrs.txt. 14 15 // This code originated in github.com/gofrs/uuid. 16 17 //go:build gofuzz 18 // +build gofuzz 19 20 package uuid 21 22 // Fuzz implements a simple fuzz test for FromString / UnmarshalText. 23 // 24 // To run: 25 // 26 // $ go get github.com/dvyukov/go-fuzz/... 27 // $ cd $GOPATH/src/github.com/gofrs/uuid 28 // $ go-fuzz-build github.com/gofrs/uuid 29 // $ go-fuzz -bin=uuid-fuzz.zip -workdir=./testdata 30 // 31 // If you make significant changes to FromString / UnmarshalText and add 32 // new cases to fromStringTests (in codec_test.go), please run 33 // 34 // $ go test -seed_fuzz_corpus 35 // 36 // to seed the corpus with the new interesting inputs, then run the fuzzer. 37 func Fuzz(data []byte) int { 38 _, err := FromString(string(data)) 39 if err != nil { 40 return 0 41 } 42 return 1 43 }