aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/bisect/bisect_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-06-15 15:08:14 +0200
committerAleksandr Nogikh <nogikh@google.com>2023-07-05 11:29:44 +0000
commitb78b123e8c4a7f91f3a63695f0887301cd3ce2aa (patch)
treed377b0594ba4e4e96b70627fd38f0c17aed1cd32 /pkg/bisect/bisect_test.go
parente6cd3005e289a9d82272bb20a7173a4dbe75e55c (diff)
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).
Diffstat (limited to 'pkg/bisect/bisect_test.go')
-rw-r--r--pkg/bisect/bisect_test.go83
1 files changed, 83 insertions, 0 deletions
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)
+ })
+ }
+}