diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-10-24 10:22:25 +0200 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-10-25 12:08:02 +0000 |
| commit | 9a199dec544ca9f1560a7352d0d003cf9206d8c5 (patch) | |
| tree | 589d3c30946513dc5d1349d781ef82b67dcd4279 /pkg/mgrconfig/load.go | |
| parent | 479141f703a43adab07cba7f8b3c99399fbbeb68 (diff) | |
pkg/mgrconfig, syz-manager: support focus areas
Switch from the CoverageFilter to the more flexible mechanism of focus
areas.
Diffstat (limited to 'pkg/mgrconfig/load.go')
| -rw-r--r-- | pkg/mgrconfig/load.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/pkg/mgrconfig/load.go b/pkg/mgrconfig/load.go index 792802e60..4529f8ec0 100644 --- a/pkg/mgrconfig/load.go +++ b/pkg/mgrconfig/load.go @@ -198,6 +198,9 @@ func Complete(cfg *Config) error { if err != nil { return err } + if err := cfg.completeFocusAreas(); err != nil { + return err + } cfg.initTimeouts() cfg.VMLess = cfg.Type == "none" return nil @@ -324,6 +327,41 @@ func (cfg *Config) completeBinaries() error { return nil } +func (cfg *Config) completeFocusAreas() error { + names := map[string]bool{} + seenEmptyFilter := false + for i, area := range cfg.Experimental.FocusAreas { + if area.Name != "" { + if names[area.Name] { + return fmt.Errorf("duplicate focus area name: %q", area.Name) + } + names[area.Name] = true + } + if area.Weight <= 0 { + return fmt.Errorf("focus area #%d: negative weight", i) + } + if area.Filter.Empty() { + if seenEmptyFilter { + return fmt.Errorf("there must be only one focus area with an empty filter") + } + seenEmptyFilter = true + } + } + if !cfg.CovFilter.Empty() { + if len(cfg.Experimental.FocusAreas) > 0 { + return fmt.Errorf("you cannot use both cov_filter and focus_areas") + } + cfg.Experimental.FocusAreas = []FocusArea{ + { + Name: "filtered", + Filter: cfg.CovFilter, + Weight: 1.0, + }, + } + } + return nil +} + func splitTarget(target string) (string, string, string, error) { if target == "" { return "", "", "", fmt.Errorf("target is empty") |
