aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2025-07-21 14:08:15 +0200
committerAleksandr Nogikh <nogikh@google.com>2025-07-23 10:08:31 +0000
commite0b9ac936f136a5a03a40283b911bc4802d98bef (patch)
treeeb6d22026987409b7909248a8d673854acf2a641 /tools
parent4aa75a1288d3ac4aa13407f4ad0fb29ed136955e (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 'tools')
-rw-r--r--tools/syz-query-subsystems/generator.go9
-rw-r--r--tools/syz-query-subsystems/query_subsystems.go14
2 files changed, 14 insertions, 9 deletions
diff --git a/tools/syz-query-subsystems/generator.go b/tools/syz-query-subsystems/generator.go
index 058c63d2a..a7db17d3f 100644
--- a/tools/syz-query-subsystems/generator.go
+++ b/tools/syz-query-subsystems/generator.go
@@ -15,9 +15,10 @@ import (
"github.com/google/syzkaller/pkg/serializer"
"github.com/google/syzkaller/pkg/subsystem"
+ "github.com/google/syzkaller/pkg/vcs"
)
-func generateSubsystemsFile(name string, list []*subsystem.Subsystem, commitInfo string) ([]byte, error) {
+func generateSubsystemsFile(name string, list []*subsystem.Subsystem, commit *vcs.Commit) ([]byte, error) {
// Set names first -- we'll need them for filling in the Parents array.
objToName := map[*subsystem.Subsystem]string{}
for _, entry := range list {
@@ -31,7 +32,8 @@ func generateSubsystemsFile(name string, list []*subsystem.Subsystem, commitInfo
// Prepare the template data.
vars := &templateVars{
Name: name,
- CommitInfo: commitInfo,
+ CommitInfo: fmt.Sprintf(`Commit %s, "%.32s"`, commit.Hash, commit.Title),
+ Version: commit.Date.Year()*10000 + int(commit.Date.Month())*100 + commit.Date.Day(),
Hierarchy: hierarchyList(list),
}
for _, entry := range list {
@@ -126,6 +128,7 @@ type templateSubsystem struct {
type templateVars struct {
Name string
+ Version int
CommitInfo string
List []*templateSubsystem
Hierarchy []string
@@ -141,7 +144,7 @@ package lists
import . "github.com/google/syzkaller/pkg/subsystem"
func init() {
- RegisterList("{{.Name}}", subsystems_{{.Name}}())
+ RegisterList("{{.Name}}", subsystems_{{.Name}}(), {{.Version}})
}
// The subsystem list:
diff --git a/tools/syz-query-subsystems/query_subsystems.go b/tools/syz-query-subsystems/query_subsystems.go
index 41a4a7a74..8f0fbae76 100644
--- a/tools/syz-query-subsystems/query_subsystems.go
+++ b/tools/syz-query-subsystems/query_subsystems.go
@@ -58,7 +58,10 @@ func main() {
if err = osutil.MkdirAll(folder); err != nil {
tool.Failf("failed to create %s: %v", folder, err)
}
- commitInfo := determineCommitInfo(*flagKernelRepo)
+ commitInfo, err := determineCommitInfo(*flagKernelRepo)
+ if err != nil {
+ tool.Failf("failed to fetch commit info: %v", err)
+ }
code, err := generateSubsystemsFile(*flagName, list, commitInfo)
if err != nil {
tool.Failf("failed to generate code: %s", err)
@@ -95,15 +98,14 @@ func prepareFilter() func(*subsystem.Subsystem) bool {
}
}
-func determineCommitInfo(dir string) string {
- // Best effort only.
+func determineCommitInfo(dir string) (*vcs.Commit, error) {
repo, err := vcs.NewRepo(*flagOS, "", dir, vcs.OptPrecious, vcs.OptDontSandbox)
if err != nil {
- return fmt.Sprintf("failed to open repo: %v", err)
+ return nil, fmt.Errorf("failed to open repo: %w", err)
}
commit, err := repo.Commit(vcs.HEAD)
if err != nil {
- return fmt.Sprintf("failed to get HEAD commit: %v", err)
+ return nil, fmt.Errorf("failed to get HEAD commit: %w", err)
}
- return fmt.Sprintf(`Commit %s, "%.32s"`, commit.Hash, commit.Title)
+ return commit, err
}