diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2023-02-03 18:14:33 +0100 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2023-02-10 14:34:44 +0100 |
| commit | 9fabcd5358c5e2df6f3936739fd726ed12d86b3a (patch) | |
| tree | 61948381d3c06d42684c233151b25ee46c0b0dac /pkg/subsystem/linux/subsystems_test.go | |
| parent | ba1c7407eaa0c09e93d8f319c9e7e65bdf0187d3 (diff) | |
pkg/subsystem/linux: add custom call lists
This information will let us extract subsystems from reproducers.
Diffstat (limited to 'pkg/subsystem/linux/subsystems_test.go')
| -rw-r--r-- | pkg/subsystem/linux/subsystems_test.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/pkg/subsystem/linux/subsystems_test.go b/pkg/subsystem/linux/subsystems_test.go index caf675244..4a1ff9f0d 100644 --- a/pkg/subsystem/linux/subsystems_test.go +++ b/pkg/subsystem/linux/subsystems_test.go @@ -47,6 +47,29 @@ func TestGroupLinuxSubsystems(t *testing.T) { assert.ElementsMatch(t, subsystems, expected) } +func TestCustomCallRules(t *testing.T) { + subsystems, err := listFromRepoInner( + prepareTestLinuxRepo(t, []byte(testMaintainers)), + testRules, + ) + if err != nil { + t.Fatal(err) + } + expectCalls := map[string][]string{ + "ext4": []string{"syz_mount_image$ext4"}, + } + gotCalls := map[string][]string{} + for _, s := range subsystems { + if len(s.Syscalls) > 0 { + gotCalls[s.Name] = s.Syscalls + } + } + assert.Equal(t, len(expectCalls), len(gotCalls)) + for name, expect := range expectCalls { + assert.ElementsMatchf(t, expect, gotCalls[name], "syscalls of %s", name) + } +} + func prepareTestLinuxRepo(t *testing.T, maintainers []byte) fs.FS { return fstest.MapFS{ `fs/ext4/fsync.c`: {}, @@ -64,6 +87,13 @@ func prepareTestLinuxRepo(t *testing.T, maintainers []byte) fs.FS { } var ( + testRules = &customRules{ + subsystemCalls: map[string][]string{ + "ext4": []string{"syz_mount_image$ext4"}, + "vxfs": []string{"syz_mount_image$vxfs"}, + "tmpfs": []string{"syz_mount_image$tmpfs"}, + }, + } testMaintainers = ` Maintainers List ---------------- |
