diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2026-01-12 22:47:10 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <nogikh@google.com> | 2026-01-13 14:18:14 +0000 |
| commit | 393201ac23707dff38037f4961f955db7e413b67 (patch) | |
| tree | ba9ad0823a72fcfb92dd90fa6e8a215c39076e4d /syz-cluster/pkg/triage/commit_test.go | |
| parent | 85894026b1b003844e8fda94056d80d88294b0be (diff) | |
syz-cluster: prioritize blob-based base commits
Consider Cc'd mailing lists when selecting the exact base commit.
Among the base commits determined based on blob sha value from the git
patch, first select the ones that match both the trees of the Cc'd
subsystems and their primary branches.
If it gives no exact match, select a base commit that comes from a tree
of a Cc'd subsystem. As fallback, take any subsystem tree.
This should prevent valid, but suprising patch series triage results.
Diffstat (limited to 'syz-cluster/pkg/triage/commit_test.go')
| -rw-r--r-- | syz-cluster/pkg/triage/commit_test.go | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/syz-cluster/pkg/triage/commit_test.go b/syz-cluster/pkg/triage/commit_test.go index d510d5b9b..80f6b99b2 100644 --- a/syz-cluster/pkg/triage/commit_test.go +++ b/syz-cluster/pkg/triage/commit_test.go @@ -87,6 +87,80 @@ func TestCommitSelector(t *testing.T) { } } +func TestFromBaseCommits(t *testing.T) { + trees := []*api.Tree{ + { + Name: "A", + Branch: "master", + EmailLists: []string{"list_A"}, + }, + { + Name: "B", + Branch: "master", + EmailLists: []string{"list_B"}, + }, + { + Name: "C", + Branch: "main", + EmailLists: []string{"list_C"}, + }, + { + Name: "D", + Branch: "main", + EmailLists: nil, + }, + } + commits := []*vcs.BaseCommit{ + { + Commit: &vcs.Commit{Hash: "first"}, + Branches: []string{"C/main"}, + }, + { + Commit: &vcs.Commit{Hash: "second"}, + Branches: []string{"A/other", "B/other"}, + }, + { + Commit: &vcs.Commit{Hash: "third"}, + Branches: []string{"A/master", "A/other"}, + }, + } + t.Run("best branch", func(t *testing.T) { + tree, commit := FromBaseCommits(&api.Series{ + Cc: []string{"list_A"}, + }, commits, trees) + assert.Equal(t, "A", tree.Name) + assert.Equal(t, "third", commit) + }) + t.Run("best tree", func(t *testing.T) { + // Even though C/main matches perfectly, there's a commit + // in the higher prio tree B. + tree, commit := FromBaseCommits(&api.Series{ + Cc: []string{"list_B", "list_C"}, + }, commits, trees) + assert.Equal(t, "B", tree.Name) + assert.Equal(t, "second", commit) + }) + t.Run("any tree", func(t *testing.T) { + // If no trees matching by Cc'd list are in the base commit list, + // consider all trees. + commits := []*vcs.BaseCommit{ + { + Commit: &vcs.Commit{Hash: "first"}, + Branches: []string{"B/main"}, + }, + { + Commit: &vcs.Commit{Hash: "second"}, + Branches: []string{"C/main"}, + }, + } + tree, commit := FromBaseCommits(&api.Series{ + Cc: []string{"list_A"}, + }, commits, trees) + assert.Equal(t, "B", tree.Name) + assert.Equal(t, "first", commit) + }) +} + func date(date string) time.Time { t, err := time.Parse("2006-Jan-02", date) if err != nil { |
