diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2025-07-21 14:08:15 +0200 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2025-07-23 10:08:31 +0000 |
| commit | e0b9ac936f136a5a03a40283b911bc4802d98bef (patch) | |
| tree | eb6d22026987409b7909248a8d673854acf2a641 /pkg/subsystem | |
| parent | 4aa75a1288d3ac4aa13407f4ad0fb29ed136955e (diff) | |
all: simplify subsystem revision updates
Don't specify the subsystem revision in the dashboard config and instead
let it be nested in the registered subsystems. This reduces the amount
of the manual work needed to switch syzbot to a newer subsystem list.
Diffstat (limited to 'pkg/subsystem')
| -rw-r--r-- | pkg/subsystem/list.go | 28 | ||||
| -rw-r--r-- | pkg/subsystem/lists/linux.go | 2 | ||||
| -rw-r--r-- | pkg/subsystem/service.go | 11 | ||||
| -rw-r--r-- | pkg/subsystem/service_test.go | 2 |
4 files changed, 30 insertions, 13 deletions
diff --git a/pkg/subsystem/list.go b/pkg/subsystem/list.go index d512a3fe1..c3650e7f9 100644 --- a/pkg/subsystem/list.go +++ b/pkg/subsystem/list.go @@ -3,6 +3,8 @@ package subsystem +import "fmt" + // In general, it's not correct to assume that subsystems are only determined by target.OS, // because subsystems are related not to the user interface of the OS kernel, but rather to // the OS kernel implementation. @@ -13,20 +15,36 @@ package subsystem // Therefore, subsystem lists have to be a completely different entity. var ( - lists = make(map[string][]*Subsystem) + lists = make(map[string]registeredSubsystem) ) -func RegisterList(name string, list []*Subsystem) { +type registeredSubsystem struct { + list []*Subsystem + revision int +} + +func RegisterList(name string, list []*Subsystem, revision int) { if _, ok := lists[name]; ok { panic(name + " subsystem list already exists!") } - lists[name] = list + lists[name] = registeredSubsystem{ + list: list, + revision: revision, + } } func GetList(name string) []*Subsystem { - return lists[name] + info, ok := lists[name] + if !ok { + panic(fmt.Sprintf("list %q is not registered", name)) + } + return info.list } func ListService(name string) *Service { - return MustMakeService(lists[name]) + info, ok := lists[name] + if !ok { + panic(fmt.Sprintf("list %q is not registered", name)) + } + return MustMakeService(info.list, info.revision) } diff --git a/pkg/subsystem/lists/linux.go b/pkg/subsystem/lists/linux.go index e94fdb9fb..274db98c0 100644 --- a/pkg/subsystem/lists/linux.go +++ b/pkg/subsystem/lists/linux.go @@ -6,7 +6,7 @@ package lists import . "github.com/google/syzkaller/pkg/subsystem" func init() { - RegisterList("linux", subsystems_linux()) + RegisterList("linux", subsystems_linux(), 20250720) } // The subsystem list: diff --git a/pkg/subsystem/service.go b/pkg/subsystem/service.go index 24f86dd54..a921cdfed 100644 --- a/pkg/subsystem/service.go +++ b/pkg/subsystem/service.go @@ -9,22 +9,20 @@ import ( type Service struct { *Extractor + Revision int perName map[string]*Subsystem perParent map[*Subsystem][]*Subsystem } -func MustMakeService(list []*Subsystem) *Service { - if len(list) == 0 { - panic("the subsystem list is empty") - } - service, err := MakeService(list) +func MustMakeService(list []*Subsystem, revision int) *Service { + service, err := MakeService(list, revision) if err != nil { panic(fmt.Sprintf("service creation failed: %s", err)) } return service } -func MakeService(list []*Subsystem) (*Service, error) { +func MakeService(list []*Subsystem, revision int) (*Service, error) { extractor := MakeExtractor(list) perName := map[string]*Subsystem{} perParent := map[*Subsystem][]*Subsystem{} @@ -42,6 +40,7 @@ func MakeService(list []*Subsystem) (*Service, error) { } return &Service{ Extractor: extractor, + Revision: revision, perName: perName, perParent: perParent, }, nil diff --git a/pkg/subsystem/service_test.go b/pkg/subsystem/service_test.go index 2a95b9558..d45a62806 100644 --- a/pkg/subsystem/service_test.go +++ b/pkg/subsystem/service_test.go @@ -14,6 +14,6 @@ func TestServiceChildren(t *testing.T) { parent := &Subsystem{Name: "parent"} childA := &Subsystem{Name: "childA", Parents: []*Subsystem{parent}} childB := &Subsystem{Name: "childB", Parents: []*Subsystem{parent}} - service := MustMakeService([]*Subsystem{unrelated, parent, childA, childB}) + service := MustMakeService([]*Subsystem{unrelated, parent, childA, childB}, 1) assert.ElementsMatch(t, service.Children(parent), []*Subsystem{childA, childB}) } |
