aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/subsystem/extractor_test.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2023-03-28 15:03:50 +0200
committerAleksandr Nogikh <wp32pw@gmail.com>2023-03-28 18:07:01 +0200
commitfc067f05bce8156101e90f93fe87e702114b863f (patch)
treef230df37293dd7afc370eec1eba5521e60ebd1df /pkg/subsystem/extractor_test.go
parent5232cf0254feea67f22bebab12e4302bb37f74f6 (diff)
pkg/subsystem: disambiguate subsystems by reproducers
There are some minor subsystems (e.g. PAGE CACHE in Linux) that are parts of several big subsystems. At the same time, a reproducer can clearly disambiguate such case. If subsystems from reproducers and subsystems from guilty files intersect, only proceed with the results of the intersection.
Diffstat (limited to 'pkg/subsystem/extractor_test.go')
-rw-r--r--pkg/subsystem/extractor_test.go30
1 files changed, 27 insertions, 3 deletions
diff --git a/pkg/subsystem/extractor_test.go b/pkg/subsystem/extractor_test.go
index a78509e0f..ec725a556 100644
--- a/pkg/subsystem/extractor_test.go
+++ b/pkg/subsystem/extractor_test.go
@@ -12,11 +12,13 @@ import (
func TestExtractor(t *testing.T) {
// Objects used in tests.
- fsPath := "fs/"
+ fsPath, mmFsPath := "fs/", "mm/fs.c"
extProg, nfsProg, extNfsProg := []byte("ext"), []byte("nfs"), []byte("ext nfs")
- fs := &Subsystem{Name: "fs"}
+ all := &Subsystem{Name: "fs"}
+ fs := &Subsystem{Name: "fs", Parents: []*Subsystem{all}}
ext := &Subsystem{Name: "ext", Parents: []*Subsystem{fs}}
nfs := &Subsystem{Name: "nfs", Parents: []*Subsystem{fs}}
+ mm := &Subsystem{Name: "mm", Parents: []*Subsystem{all}}
// Tests themselves.
tests := []struct {
name string
@@ -79,11 +81,33 @@ func TestExtractor(t *testing.T) {
},
want: []*Subsystem{ext},
},
+ {
+ name: `Reproducer supporting one of guilty paths`,
+ crashes: []*Crash{
+ // The guilty paths correspond both to mm and fs.
+ {
+ GuiltyPath: mmFsPath,
+ },
+ {
+ GuiltyPath: mmFsPath,
+ },
+ {
+ GuiltyPath: mmFsPath,
+ },
+ {
+ // But one reproducer points clearly to fs.
+ GuiltyPath: mmFsPath,
+ SyzRepro: extProg,
+ },
+ },
+ want: []*Subsystem{ext},
+ },
}
extractor := &Extractor{
raw: &testRawExtractor{
perPath: map[string][]*Subsystem{
- fsPath: {fs},
+ fsPath: {fs},
+ mmFsPath: {mm, fs},
},
perProg: []progSubsystems{
{extProg, []*Subsystem{ext}},