internal/fuzz: add fuzzers for prototext and protojson packages
Change-Id: Iee065070e6a983c303a3551a67fc32f0e94b649e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/212219
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/fuzz/textfuzz/fuzz_test.go b/internal/fuzz/textfuzz/fuzz_test.go
new file mode 100644
index 0000000..a0e9d0c
--- /dev/null
+++ b/internal/fuzz/textfuzz/fuzz_test.go
@@ -0,0 +1,34 @@
+// Copyright 2019 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package textfuzz
+
+import (
+ "io/ioutil"
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+func Test(t *testing.T) {
+ dir, err := os.Open("corpus")
+ if err != nil {
+ t.Fatal(err)
+ }
+ infos, err := dir.Readdir(0)
+ if err != nil {
+ t.Fatal(err)
+
+ }
+ for _, info := range infos {
+ name := info.Name()
+ t.Run(name, func(t *testing.T) {
+ b, err := ioutil.ReadFile(filepath.Join("corpus", name))
+ if err != nil {
+ t.Fatal(err)
+ }
+ Fuzz(b)
+ })
+ }
+}