-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
- Loading branch information
1 parent
7c6c695
commit 54befcb
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package runner | ||
|
||
// corpusEntry is from the public go testing which references an internal structure. | ||
// corpusEntry is an alias to the same type as internal/fuzz.CorpusEntry. | ||
// We use a type alias because we don't want to export this type, and we can't | ||
// import internal/fuzz from testing. | ||
type corpusEntry = struct { | ||
Parent string | ||
Path string | ||
Data []byte | ||
Values []interface{} | ||
Generation int | ||
IsSeed bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package runner | ||
|
||
import ( | ||
"flag" | ||
"testing" | ||
|
||
"github.com/kyverno/chainsaw/pkg/apis/v1alpha1" | ||
) | ||
|
||
func Run(tests ...v1alpha1.Test) int { | ||
if len(tests) == 0 { | ||
return 0 | ||
} | ||
flag.Parse() | ||
testing.Init() | ||
// TODO: flags | ||
var testDeps testDeps | ||
m := testing.MainStart( | ||
&testDeps, | ||
[]testing.InternalTest{{ | ||
Name: "chainsaw", | ||
F: func(t *testing.T) { | ||
t.Helper() | ||
run(t, tests...) | ||
}, | ||
}}, | ||
nil, | ||
nil, | ||
nil, | ||
) | ||
return m.Run() | ||
} | ||
|
||
func run(t *testing.T, tests ...v1alpha1.Test) { | ||
t.Helper() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package runner | ||
|
||
import ( | ||
"io" | ||
"reflect" | ||
"regexp" | ||
"runtime/pprof" | ||
"time" | ||
) | ||
|
||
// testDeps implements the testDeps interface for MainStart. | ||
type testDeps struct { | ||
matchPat string | ||
matchRe *regexp.Regexp | ||
} | ||
|
||
func (d *testDeps) MatchString(pat, str string) (bool, error) { | ||
if d.matchRe == nil || d.matchPat != pat { | ||
d.matchPat = pat | ||
matchRe, err := regexp.Compile(d.matchPat) | ||
if err != nil { | ||
return false, err | ||
} | ||
d.matchRe = matchRe | ||
} | ||
return d.matchRe.MatchString(str), nil | ||
} | ||
|
||
func (*testDeps) SetPanicOnExit0(bool) {} | ||
|
||
func (*testDeps) StartCPUProfile(w io.Writer) error { | ||
return pprof.StartCPUProfile(w) | ||
} | ||
|
||
func (*testDeps) StopCPUProfile() { | ||
pprof.StopCPUProfile() | ||
} | ||
|
||
func (*testDeps) WriteProfileTo(name string, w io.Writer, debug int) error { | ||
return pprof.Lookup(name).WriteTo(w, debug) | ||
} | ||
|
||
func (*testDeps) ImportPath() string { | ||
return "" | ||
} | ||
|
||
func (*testDeps) StartTestLog(w io.Writer) {} | ||
|
||
func (*testDeps) StopTestLog() error { | ||
return nil | ||
} | ||
|
||
func (*testDeps) CoordinateFuzzing(time.Duration, int64, time.Duration, int64, int, []corpusEntry, []reflect.Type, string, string) error { | ||
return nil | ||
} | ||
|
||
func (*testDeps) RunFuzzWorker(func(corpusEntry) error) error { | ||
return nil | ||
} | ||
|
||
func (*testDeps) ReadCorpus(string, []reflect.Type) ([]corpusEntry, error) { | ||
return nil, nil | ||
} | ||
|
||
func (*testDeps) CheckCorpus([]interface{}, []reflect.Type) error { | ||
return nil | ||
} | ||
|
||
func (*testDeps) ResetCoverage() {} | ||
|
||
func (*testDeps) SnapshotCoverage() {} |