github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/compiler/fuzz.go (about)

     1  // Copyright 2017 syzkaller project authors. All rights reserved.
     2  // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
     3  
     4  package compiler
     5  
     6  import (
     7  	"github.com/google/syzkaller/pkg/ast"
     8  	"github.com/google/syzkaller/sys/targets"
     9  )
    10  
    11  func Fuzz(data []byte) int {
    12  	eh := func(pos ast.Pos, msg string) {}
    13  	desc := ast.Parse(data, "", eh)
    14  	if desc == nil {
    15  		return 0
    16  	}
    17  	prog := Compile(desc, fuzzConsts, fuzzTarget, eh)
    18  	if prog == nil {
    19  		return 0
    20  	}
    21  	return 1
    22  }
    23  
    24  var (
    25  	fuzzTarget = targets.Get(targets.TestOS, targets.TestArch64)
    26  	fuzzConsts = map[string]uint64{"A": 1, "B": 2, "C": 3, "SYS_A": 4, "SYS_B": 5, "SYS_C": 6}
    27  )