diff options
Diffstat (limited to 'pkg/subsystem')
| -rw-r--r-- | pkg/subsystem/linux/subsystems_test.go | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/pkg/subsystem/linux/subsystems_test.go b/pkg/subsystem/linux/subsystems_test.go index 4a1ff9f0d..b4f0818ff 100644 --- a/pkg/subsystem/linux/subsystems_test.go +++ b/pkg/subsystem/linux/subsystems_test.go @@ -9,6 +9,7 @@ import ( "testing/fstest" "github.com/google/syzkaller/pkg/subsystem/entity" + "github.com/google/syzkaller/pkg/subsystem/match" "github.com/stretchr/testify/assert" ) @@ -70,6 +71,67 @@ func TestCustomCallRules(t *testing.T) { } } +func TestLinuxSubsystemPaths(t *testing.T) { + // For the list of subsystems, see TestLinuxSubsystemsList. + // Here we rely on the same ones. + repo := prepareTestLinuxRepo(t, []byte(testMaintainers)) + subsystems, err := listFromRepoInner(repo, testRules) + if err != nil { + t.Fatal(err) + } + matcher := match.MakePathMatcher(subsystems) + tests := []struct { + path string + list []string + }{ + { + path: `fs/internal.h`, + list: []string{"kernel", "fs"}, + }, + { + path: `fs/ext4/mmp.c`, + list: []string{"kernel", "fs", "ext4"}, + }, + { + // The subsystem is not present in our test MAINTAINERS. + path: `fs/fat/inode.c`, + list: []string{"kernel", "fs"}, + }, + { + path: `fs/freevxfs/vxfs_olt.c`, + list: []string{"kernel", "fs"}, + }, + { + path: `mm/memory.c`, + list: []string{"kernel", "mm"}, + }, + { + path: `mm/shmem.c`, + list: []string{"kernel", "mm"}, + }, + { + path: `include/net/ah.h`, + list: []string{"kernel"}, + }, + { + path: `include/linux/mm.h`, + list: []string{"kernel", "mm"}, + }, + { + path: `include/linux/fs.h`, + list: []string{"kernel", "fs"}, + }, + } + for _, test := range tests { + retList := []string{} + for _, s := range matcher.Match(test.path) { + retList = append(retList, s.Name) + } + assert.ElementsMatchf(t, retList, test.list, + "invalid subsystems for %#v", test.path) + } +} + func prepareTestLinuxRepo(t *testing.T, maintainers []byte) fs.FS { return fstest.MapFS{ `fs/ext4/fsync.c`: {}, |
