tests: move FuzzParse to separate file
Co-authored-by: Lovro Sviben <46844730+lsviben@users.noreply.github.com> Signed-off-by: Philippe Scorsolini <p.scorsolini@gmail.com>
This commit is contained in:
parent
e0b2108c51
commit
d95d8e0cca
|
|
@ -0,0 +1,20 @@
|
|||
package parser
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
)
|
||||
|
||||
func FuzzParse(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
objScheme := runtime.NewScheme()
|
||||
metaScheme := runtime.NewScheme()
|
||||
p := New(metaScheme, objScheme)
|
||||
r := io.NopCloser(bytes.NewReader(data))
|
||||
_, _ = p.Parse(context.Background(), r)
|
||||
})
|
||||
}
|
||||
|
|
@ -19,7 +19,6 @@ package parser
|
|||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/google/go-cmp/cmp"
|
||||
|
|
@ -179,13 +178,3 @@ func TestParser(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func FuzzParse(f *testing.F) {
|
||||
f.Fuzz(func(t *testing.T, data []byte) {
|
||||
objScheme := runtime.NewScheme()
|
||||
metaScheme := runtime.NewScheme()
|
||||
p := New(metaScheme, objScheme)
|
||||
r := io.NopCloser(bytes.NewReader(data))
|
||||
_, _ = p.Parse(context.Background(), r)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
#!/bin/bash -eu
|
||||
#
|
||||
# IMPORTANT: Fuzz* test cases should be in a dedicated file, conventionally
|
||||
# called `fuzz_test.go`, but that's not a requirement. Otherwise once the file
|
||||
# name is changed to have the _test_fuzz.go termination instead of _test.go as
|
||||
# required by oss-fuzz, the code won't compile as other Test* test cases might
|
||||
# not find some requirements given that they are not in a _test.go file.
|
||||
#
|
||||
# DO NOT DELETE: this script is used from oss-fuzz. You can find more details
|
||||
# in the official documentation:
|
||||
# https://google.github.io/oss-fuzz/getting-started/new-project-guide/go-lang/
|
||||
|
|
|
|||
Loading…
Reference in New Issue