ci: add a parser fuzzer step too (#7288)

pull/7292/head
Daniel Däschle 2020-12-12 14:20:38 +01:00 committed by GitHub
parent b76c91ec05
commit 7e3e30aa9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View File

@ -622,3 +622,32 @@ jobs:
./v test-parser examples/vmod.v
./v test-parser examples/regex_example.v
./v test-parser examples/2048/2048.v
parser-silent-fuzzing:
name: Parser silent mode fuzzing
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v2
- name: Build local v
run: make -j4
- name: Install zzuf
run: sudo apt install -qq zzuf
- name: Run test-parser
run: |
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/hello_world.v > examples/hello_world_fuzz.v
./v test-parser examples/hello_world_fuzz.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/hanoi.v > examples/hanoi_fuzz.v
./v test-parser examples/hanoi_fuzz.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/fibonacci.v > examples/fibonacci_fuzz.v
./v test-parser examples/fibonacci.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/cli.v > examples/cli_fuzz.v
./v test-parser examples/cli_fuzz.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/json.v > examples/json_fuzz.v
./v test-parser examples/json.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/vmod.v > examples/vmod_fuzz.v
./v test-parser examples/vmod.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/regex_example.v > examples/regex_example_fuzz.v
./v test-parser examples/regex_example_fuzz.v
zzuf -R '\x00-\x20\x7f-\xff' -r0.01 < examples/2048/2048.v > examples/2048/2048_fuzz.v
./v test-parser examples/2048/2048_fuzz.v

View File

@ -380,7 +380,7 @@ pub fn (mut p Parser) parse_generic_struct_inst_type(name string) table.Type {
bs_cname += '_T_'
mut generic_types := []table.Type{}
mut is_instance := false
for {
for p.tok.kind != .eof {
gt := p.parse_type()
if !gt.has_flag(.generic) {
is_instance = true

View File

@ -233,6 +233,9 @@ fn (mut s Scanner) ident_hex_number() string {
mut first_wrong_digit_pos := 0
mut first_wrong_digit := `\0`
start_pos := s.pos
if s.pos + 2 >= s.text.len {
return '0x'
}
s.pos += 2 // skip '0x'
if s.text[s.pos] == num_sep {
s.error('separator `_` is only valid between digits in a numeric literal')