github.com/divyam234/rclone@v1.64.1/fs/fspath/fuzz.go (about) 1 //go:build gofuzz 2 // +build gofuzz 3 4 /* 5 Fuzz test the Parse function 6 7 Generate corpus 8 9 go test -v -make-corpus 10 11 Install go fuzz 12 13 go get -u github.com/dvyukov/go-fuzz/go-fuzz github.com/dvyukov/go-fuzz/go-fuzz-build 14 15 Compile and fuzz 16 17 go-fuzz-build 18 go-fuzz 19 20 Tidy up 21 22 rm -rf corpus/ crashers/ suppressions/ 23 git co ../../go.mod ../../go.sum 24 */ 25 26 package fspath 27 28 func Fuzz(data []byte) int { 29 path := string(data) 30 parsed, err := Parse(path) 31 if err != nil { 32 return 0 33 } 34 if parsed.Name == "" { 35 if parsed.ConfigString != "" { 36 panic("bad ConfigString") 37 } 38 if parsed.Path != path { 39 panic("local path not preserved") 40 } 41 } else { 42 if parsed.ConfigString+":"+parsed.Path != path { 43 panic("didn't split properly") 44 } 45 } 46 return 0 47 }