From f979ee3873e3cc7ac50c6f2cb7c37aeef8a473d9 Mon Sep 17 00:00:00 2001 From: Kris Alder Date: Tue, 22 Oct 2019 10:52:01 -0700 Subject: [PATCH] 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 --- cc/androidmk.go | 5 +++++ cc/fuzz.go | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/cc/androidmk.go b/cc/androidmk.go index cdd8e9201..f278d6f41 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -317,6 +317,11 @@ func (fuzz *fuzzBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa 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 { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) { fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(fuzzFiles, " ")) diff --git a/cc/fuzz.go b/cc/fuzz.go index a99b0bb12..4d3852684 100644 --- a/cc/fuzz.go +++ b/cc/fuzz.go @@ -15,6 +15,7 @@ package cc import ( + "encoding/json" "path/filepath" "strings" @@ -24,12 +25,35 @@ import ( "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 { // Optional list of seed files to be installed to the fuzz target's output // directory. Corpus []string `android:"path"` // Optional dictionary to be installed to the fuzz target's output directory. Dictionary *string `android:"path"` + // Config for running the target on fuzzing infrastructure. + Fuzz_config *FuzzConfig } func init() { @@ -57,6 +81,7 @@ type fuzzBinary struct { dictionary android.Path corpus android.Paths corpusIntermediateDir android.Path + config android.Path } func (fuzz *fuzzBinary) linkerProps() []interface{} { @@ -122,6 +147,19 @@ func (fuzz *fuzzBinary) install(ctx ModuleContext, file android.Path) { 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 { @@ -234,6 +272,12 @@ func (s *fuzzPackager) GenerateBuildActions(ctx android.SingletonContext) { archDirs[archDir] = append(archDirs[archDir], 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 {