diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-11-21 08:50:43 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-11-21 09:22:22 +0100 |
| commit | a4050c39f67db2b93a4070a87f637c14b7e35919 (patch) | |
| tree | b90113a7a18ca922dd236549ae0490f465a00b9b /pkg | |
| parent | 6c1496ae75762575108ba042f555f009d3777046 (diff) | |
pkg/mgrconfig: break import cycle in tests
A future change makes vm/* depend on pkg/report,
and pkg/report already depends on pkg/mgrconfig.
This introduces a cycle for mgrconfig tests.
Move tests into a separate package.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/mgrconfig/load.go | 6 | ||||
| -rw-r--r-- | pkg/mgrconfig/mgrconfig_test.go | 5 |
2 files changed, 6 insertions, 5 deletions
diff --git a/pkg/mgrconfig/load.go b/pkg/mgrconfig/load.go index ce710b96b..7e2efe82d 100644 --- a/pkg/mgrconfig/load.go +++ b/pkg/mgrconfig/load.go @@ -222,7 +222,7 @@ func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) ([]in for _, c := range enabled { n := 0 for _, call := range target.Syscalls { - if matchSyscall(call.Name, c) { + if MatchSyscall(call.Name, c) { syscalls[call.ID] = true n++ } @@ -244,7 +244,7 @@ func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) ([]in for _, c := range disabled { n := 0 for _, call := range target.Syscalls { - if matchSyscall(call.Name, c) { + if MatchSyscall(call.Name, c) { delete(syscalls, call.ID) n++ } @@ -263,7 +263,7 @@ func ParseEnabledSyscalls(target *prog.Target, enabled, disabled []string) ([]in return arr, nil } -func matchSyscall(name, pattern string) bool { +func MatchSyscall(name, pattern string) bool { if pattern == name || strings.HasPrefix(name, pattern+"$") { return true } diff --git a/pkg/mgrconfig/mgrconfig_test.go b/pkg/mgrconfig/mgrconfig_test.go index 1e4dc95fd..3b4d9cc7d 100644 --- a/pkg/mgrconfig/mgrconfig_test.go +++ b/pkg/mgrconfig/mgrconfig_test.go @@ -1,13 +1,14 @@ // Copyright 2017 syzkaller project authors. All rights reserved. // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -package mgrconfig +package mgrconfig_test import ( "path/filepath" "testing" "github.com/google/syzkaller/pkg/config" + . "github.com/google/syzkaller/pkg/mgrconfig" "github.com/google/syzkaller/vm/gce" "github.com/google/syzkaller/vm/qemu" ) @@ -55,7 +56,7 @@ func TestMatchSyscall(t *testing.T) { {"foo$*", "foo$BAR", true}, } for i, test := range tests { - res := matchSyscall(test.call, test.pattern) + res := MatchSyscall(test.call, test.pattern) if res != test.result { t.Errorf("#%v: pattern=%q call=%q want=%v got=%v", i, test.pattern, test.call, test.result, res) |
