From a4050c39f67db2b93a4070a87f637c14b7e35919 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Sat, 21 Nov 2020 08:50:43 +0100 Subject: 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. --- pkg/mgrconfig/load.go | 6 +++--- pkg/mgrconfig/mgrconfig_test.go | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'pkg') 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) -- cgit mrf-deployment