Permalink
Browse files

Commit fuzzer source and README

  • Loading branch information...
benhoyt committed Nov 14, 2018
1 parent 04bee51 commit 109e8a9d645cb454e13582ab34f0f9d6d3fbdcfd
Showing with 46 additions and 8 deletions.
  1. +3 −7 .gitignore
  2. +11 −0 fuzz/README.txt
  3. +17 −0 fuzz/interp/interp.go
  4. +15 −0 fuzz/parser/parser.go
  5. +0 −1 goawk.go
@@ -1,10 +1,6 @@
.DS_Store
goawk
_slow

fuzz-interp.zip
fuzz-parser.zip
workdir-interp/
workdir-parser/
fuzz-interp/
fuzz-parser/
fuzz/interp/workdir
fuzz/parser/workdir
fuzz-fuzz.zip
@@ -0,0 +1,11 @@
To run the fuzzer, first:

$ go get github.com/dvyukov/go-fuzz

Then build the fuzzer zip file:

$ go-fuzz-build github.com/benhoyt/goawk/fuzz/interp

And finally run the fuzzer (with 6 parallel processes in this example):

$ go-fuzz -bin=fuzz-fuzz.zip -workdir=fuzz/interp/workdir -procs=6
@@ -0,0 +1,17 @@
// +build gofuzz

package fuzz

import (
"bytes"
"github.com/benhoyt/goawk/interp"
)

func Fuzz(data []byte) int {
input := bytes.NewReader([]byte("foo bar\nbaz buz\n"))
err := interp.Exec(string(data), " ", input, &bytes.Buffer{})
if err != nil {
return 0
}
return 1
}
@@ -0,0 +1,15 @@
// +build gofuzz

package fuzz

import (
"github.com/benhoyt/goawk/parser"
)

func Fuzz(data []byte) int {
if _, err := parser.ParseProgram(data, nil); err != nil {
return 0
}

return 1
}
@@ -36,7 +36,6 @@ TODO:
+ benchmark against awk/gawk with some real awk scripts
+ do a bit more cpu and mem profiling
- do some more fuzz testing
+ commit fuzz testing code and scripts to repo
- release 1.0.0 (do anything for Go modules?)
- remove notice about "beta" from README.md

0 comments on commit 109e8a9

Please sign in to comment.