add additional fields to cc_fuzz build types
Specifically, this adds: * Owner * Disable (stop fuzzer from running in Haiku) * Bug Component * Bug Hotlist The fields are all inside a new 'options' struct. The values from these fields (if any) are written into a config file as json. Bug: 142551000 Test: ran locally with a modified build file and verified output in .zip Change-Id: I86edf74c2cebe9912ac0ad203f99028be4062c8b
This commit is contained in:
@@ -317,6 +317,11 @@ func (fuzz *fuzzBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
|
|||||||
filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
|
filepath.Dir(fuzz.dictionary.String())+":"+fuzz.dictionary.Base())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fuzz.config != nil {
|
||||||
|
fuzzFiles = append(fuzzFiles,
|
||||||
|
filepath.Dir(fuzz.config.String())+":config.json")
|
||||||
|
}
|
||||||
|
|
||||||
if len(fuzzFiles) > 0 {
|
if len(fuzzFiles) > 0 {
|
||||||
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
|
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
|
||||||
fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(fuzzFiles, " "))
|
fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(fuzzFiles, " "))
|
||||||
|
44
cc/fuzz.go
44
cc/fuzz.go
@@ -15,6 +15,7 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -24,12 +25,35 @@ import (
|
|||||||
"android/soong/cc/config"
|
"android/soong/cc/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type FuzzConfig struct {
|
||||||
|
// Email address of people to CC on bugs or contact about this fuzz target.
|
||||||
|
Cc []string `json:"cc,omitempty"`
|
||||||
|
// Boolean specifying whether to disable the fuzz target from running
|
||||||
|
// automatically in continuous fuzzing infrastructure.
|
||||||
|
Disable *bool `json:"disable,omitempty"`
|
||||||
|
// Component in Google's bug tracking system that bugs should be filed to.
|
||||||
|
Componentid *int64 `json:"componentid,omitempty"`
|
||||||
|
// Hotlists in Google's bug tracking system that bugs should be marked with.
|
||||||
|
Hotlists []string `json:"hotlists,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *FuzzConfig) String() string {
|
||||||
|
b, err := json.Marshal(f)
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(b)
|
||||||
|
}
|
||||||
|
|
||||||
type FuzzProperties struct {
|
type FuzzProperties struct {
|
||||||
// Optional list of seed files to be installed to the fuzz target's output
|
// Optional list of seed files to be installed to the fuzz target's output
|
||||||
// directory.
|
// directory.
|
||||||
Corpus []string `android:"path"`
|
Corpus []string `android:"path"`
|
||||||
// Optional dictionary to be installed to the fuzz target's output directory.
|
// Optional dictionary to be installed to the fuzz target's output directory.
|
||||||
Dictionary *string `android:"path"`
|
Dictionary *string `android:"path"`
|
||||||
|
// Config for running the target on fuzzing infrastructure.
|
||||||
|
Fuzz_config *FuzzConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@@ -57,6 +81,7 @@ type fuzzBinary struct {
|
|||||||
dictionary android.Path
|
dictionary android.Path
|
||||||
corpus android.Paths
|
corpus android.Paths
|
||||||
corpusIntermediateDir android.Path
|
corpusIntermediateDir android.Path
|
||||||
|
config android.Path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (fuzz *fuzzBinary) linkerProps() []interface{} {
|
func (fuzz *fuzzBinary) linkerProps() []interface{} {
|
||||||
@@ -122,6 +147,19 @@ func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) {
|
|||||||
fuzz.dictionary.String())
|
fuzz.dictionary.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if fuzz.Properties.Fuzz_config != nil {
|
||||||
|
configPath := android.PathForModuleOut(ctx, "config").Join(ctx, "config.txt")
|
||||||
|
ctx.Build(pctx, android.BuildParams{
|
||||||
|
Rule: android.WriteFile,
|
||||||
|
Description: "fuzzer infrastructure configuration",
|
||||||
|
Output: configPath,
|
||||||
|
Args: map[string]string{
|
||||||
|
"content": fuzz.Properties.Fuzz_config.String(),
|
||||||
|
},
|
||||||
|
})
|
||||||
|
fuzz.config = configPath
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewFuzz(hod android.HostOrDeviceSupported) *Module {
|
func NewFuzz(hod android.HostOrDeviceSupported) *Module {
|
||||||
@@ -234,6 +272,12 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
archDirs[archDir] = append(archDirs[archDir],
|
archDirs[archDir] = append(archDirs[archDir],
|
||||||
fileToZip{fuzzModule.dictionary, ccModule.Name()})
|
fileToZip{fuzzModule.dictionary, ccModule.Name()})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional fuzz config.
|
||||||
|
if fuzzModule.config != nil {
|
||||||
|
archDirs[archDir] = append(archDirs[archDir],
|
||||||
|
fileToZip{fuzzModule.config, ccModule.Name()})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
for archDir, filesToZip := range archDirs {
|
for archDir, filesToZip := range archDirs {
|
||||||
|
Reference in New Issue
Block a user