Skip to content

Commit

Permalink
fuzz lexer
Browse files Browse the repository at this point in the history
  • Loading branch information
boyter committed Jul 23, 2020
1 parent c72cd01 commit 8848fb0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
10 changes: 10 additions & 0 deletions check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ fi

echo "Running fuzz checks..."
pushd str || exit
echo "fuzzing str"
go-fuzz-build
go-fuzz &
sleep 60
pkill -9 go-fuzz
popd || exit

pushd processor || exit
echo "fuzzing processor"
go-fuzz-build
go-fuzz &
sleep 60
pkill -9 go-fuzz
popd || exit

pushd processor/parser || exit
echo "fuzzing processor/parser"
go-fuzz-build
go-fuzz &
sleep 60
Expand Down
4 changes: 4 additions & 0 deletions processor/parser/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
corpus
crashers
suppressions
parser-fuzz.zip
17 changes: 17 additions & 0 deletions processor/parser/fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package parser

// For fuzz testing...
// https://github.com/dvyukov/go-fuzz
// install both go-fuzz-build and go-fuzz
// go-fuzz-build && go-fuzz
func Fuzz(data []byte) int {
lex := NewLexer(string(data))

lex.Peek()
t := lex.NextToken()
for t.Type != "END" {
t = lex.NextToken()
}

return 1
}

0 comments on commit 8848fb0

Please sign in to comment.