From b78b123e8c4a7f91f3a63695f0887301cd3ce2aa Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Thu, 15 Jun 2023 15:08:14 +0200 Subject: pkg/bisect: remember the most frequent report types This will later help in adjusting kernel configuration. Also, adjust how test() determines the crash report: pick the one with the most frequent type. Earlier we were taking the last crash report, but this seems to have a bias towards the crashes that take longer to appear (e.g. rcu stalls). --- pkg/bisect/bisect_test.go | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) (limited to 'pkg/bisect/bisect_test.go') diff --git a/pkg/bisect/bisect_test.go b/pkg/bisect/bisect_test.go index aeed167aa..80709c85e 100644 --- a/pkg/bisect/bisect_test.go +++ b/pkg/bisect/bisect_test.go @@ -15,6 +15,7 @@ import ( "github.com/google/syzkaller/pkg/instance" "github.com/google/syzkaller/pkg/mgrconfig" "github.com/google/syzkaller/pkg/report" + "github.com/google/syzkaller/pkg/report/crash" "github.com/google/syzkaller/pkg/vcs" "github.com/google/syzkaller/sys/targets" "github.com/stretchr/testify/assert" @@ -739,3 +740,85 @@ func TestBisectVerdict(t *testing.T) { }) } } + +// nolint: dupl +func TestMostFrequentReport(t *testing.T) { + tests := []struct { + name string + reports []*report.Report + report string + types []crash.Type + other bool + }{ + { + name: "one infrequent", + reports: []*report.Report{ + {Title: "A", Type: crash.KASAN}, + {Title: "B", Type: crash.KASAN}, + {Title: "C", Type: crash.Bug}, + {Title: "D", Type: crash.KASAN}, + {Title: "E", Type: crash.Bug}, + {Title: "F", Type: crash.KASAN}, + {Title: "G", Type: crash.LockdepBug}, + }, + // LockdepBug was too infrequent. + types: []crash.Type{crash.KASAN, crash.Bug}, + report: "A", + other: true, + }, + { + name: "ignore hangs", + reports: []*report.Report{ + {Title: "A", Type: crash.KASAN}, + {Title: "B", Type: crash.KASAN}, + {Title: "C", Type: crash.Hang}, + {Title: "D", Type: crash.KASAN}, + {Title: "E", Type: crash.Hang}, + {Title: "F", Type: crash.Hang}, + {Title: "G", Type: crash.Warning}, + }, + // Hang is not a preferred report type. + types: []crash.Type{crash.KASAN, crash.Warning}, + report: "A", + other: true, + }, + { + name: "take hangs", + reports: []*report.Report{ + {Title: "A", Type: crash.KASAN}, + {Title: "B", Type: crash.KASAN}, + {Title: "C", Type: crash.Hang}, + {Title: "D", Type: crash.Hang}, + {Title: "E", Type: crash.Hang}, + {Title: "F", Type: crash.Hang}, + }, + // There are so many Hangs that we can't ignore it. + types: []crash.Type{crash.Hang, crash.KASAN}, + report: "C", + }, + { + name: "take unknown", + reports: []*report.Report{ + {Title: "A", Type: crash.UnknownType}, + {Title: "B", Type: crash.UnknownType}, + {Title: "C", Type: crash.Hang}, + {Title: "D", Type: crash.UnknownType}, + {Title: "E", Type: crash.Hang}, + {Title: "F", Type: crash.UnknownType}, + }, + // UnknownType is also a type. + types: []crash.Type{crash.UnknownType}, + report: "A", + other: true, + }, + } + for _, test := range tests { + test := test + t.Run(test.name, func(t *testing.T) { + rep, types, other := mostFrequentReports(test.reports) + assert.ElementsMatch(t, types, test.types) + assert.Equal(t, rep.Title, test.report) + assert.Equal(t, other, test.other) + }) + } +} -- cgit mrf-deployment