syz-repro-automation: process logopts.yaml file
Added function to parse logopts.yaml file in repro.go.
BUG=b:193906330
TEST=go run repro.go
Change-Id: I126fe88696c825fd00e695408e99a27aab37c285
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/3058747
Commit-Queue: Grant Hugh <ghugh@chromium.org>
Tested-by: Grant Hugh <ghugh@chromium.org>
Reviewed-by: Zubin Mithra <zsm@chromium.org>
diff --git a/contrib/syz-repro-automation/repro.go b/contrib/syz-repro-automation/repro.go
index 678a02f..ace7747 100644
--- a/contrib/syz-repro-automation/repro.go
+++ b/contrib/syz-repro-automation/repro.go
@@ -16,6 +16,7 @@
"github.com/google/syz-repro-automation/cmd"
"github.com/google/syz-repro-automation/dut"
+ "gopkg.in/yaml.v2"
)
type dutConfig struct {
@@ -39,6 +40,20 @@
DUTConfig dutConfig `json:"vm"`
}
+type dutObj struct {
+ Model string `yaml:"model"`
+ ImageID string `yaml:"imageid"`
+}
+
+type bug struct {
+ ID string `yaml:"id"`
+ DUT dutObj `yaml:"dut"`
+}
+
+type logOpts struct {
+ Bugs []bug `yaml:"bugs"`
+}
+
const (
syzReproTimeout = 20 * time.Minute
)
@@ -105,6 +120,30 @@
return nil
}
+func processLogOpts(rootdir string) (map[dutObj][]string, error) {
+ logoptsFile := filepath.Join(rootdir, "logopts.yaml")
+ yamlFile, err := ioutil.ReadFile(logoptsFile)
+ if err != nil {
+ return nil, fmt.Errorf("unable to read logopts.yaml file: %v", err)
+ }
+
+ logopts := logOpts{}
+ err = yaml.Unmarshal(yamlFile, &logopts)
+ if err != nil {
+ return nil, fmt.Errorf("unable to unmarshal logopts.yaml: %v", err)
+ }
+
+ dutToBugs := make(map[dutObj][]string)
+
+ for _, bug := range logopts.Bugs {
+ if bug.DUT.Model != "" {
+ dutToBugs[bug.DUT] = append(dutToBugs[bug.DUT], bug.ID)
+ }
+ }
+
+ return dutToBugs, nil
+}
+
func run(model string, minutes int, imageID string, paths map[string]string) {
hostname, err := dut.Lease(model, minutes)
if err != nil {
@@ -159,5 +198,11 @@
if *logFile {
run(*model, *minutes, *imageID, paths)
+ } else {
+ dutToBugs, err := processLogOpts(flag.Arg(0))
+ if err != nil {
+ log.Panic(err)
+ }
+ fmt.Println(dutToBugs)
}
}