diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-06-04 12:55:41 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-06-24 09:57:34 +0000 |
| commit | e16e2c9a4cb6937323e861b646792a6c4c978a3c (patch) | |
| tree | 6c513e98e5f465b44a98546d8984485d2c128582 /pkg/vminfo/vminfo_test.go | |
| parent | 90d67044dab68568e8f35bc14b68055dbd166eff (diff) | |
executor: add runner mode
Move all syz-fuzzer logic into syz-executor and remove syz-fuzzer.
Also restore syz-runtest functionality in the manager.
Update #4917 (sets most signal handlers to SIG_IGN)
Diffstat (limited to 'pkg/vminfo/vminfo_test.go')
| -rw-r--r-- | pkg/vminfo/vminfo_test.go | 66 |
1 files changed, 49 insertions, 17 deletions
diff --git a/pkg/vminfo/vminfo_test.go b/pkg/vminfo/vminfo_test.go index f58e3f7e5..2be23ca66 100644 --- a/pkg/vminfo/vminfo_test.go +++ b/pkg/vminfo/vminfo_test.go @@ -4,6 +4,8 @@ package vminfo import ( + "os" + "path/filepath" "runtime" "strings" "testing" @@ -11,9 +13,6 @@ import ( "github.com/google/syzkaller/pkg/flatrpc" "github.com/google/syzkaller/pkg/fuzzer/queue" - "github.com/google/syzkaller/pkg/host" - "github.com/google/syzkaller/pkg/ipc" - "github.com/google/syzkaller/pkg/mgrconfig" "github.com/google/syzkaller/prog" "github.com/google/syzkaller/sys/targets" ) @@ -121,29 +120,62 @@ func createSuccessfulResults(source queue.Source, stop chan struct{}) { func hostChecker(t *testing.T) (*Checker, []*flatrpc.FileInfo) { cfg := testConfig(t, runtime.GOOS, runtime.GOARCH) checker := New(cfg) - files := host.ReadFiles(checker.RequiredFiles()) + files := readFiles(checker.RequiredFiles()) return checker, files } -func testConfig(t *testing.T, OS, arch string) *mgrconfig.Config { +func testConfig(t *testing.T, OS, arch string) *Config { target, err := prog.GetTarget(OS, arch) if err != nil { t.Fatal(err) } - cfg := &mgrconfig.Config{ - Sandbox: ipc.FlagsToSandbox(0), - Derived: mgrconfig.Derived{ - TargetOS: OS, - TargetArch: arch, - TargetVMArch: arch, - Target: target, - SysTarget: targets.Get(OS, arch), - }, - } + var syscalls []int for id := range target.Syscalls { if !target.Syscalls[id].Attrs.Disabled { - cfg.Syscalls = append(cfg.Syscalls, id) + syscalls = append(syscalls, id) + } + } + return &Config{ + Target: target, + Features: flatrpc.AllFeatures, + Sandbox: flatrpc.ExecEnvSandboxNone, + Syscalls: syscalls, + } +} + +func readFiles(files []string) []*flatrpc.FileInfo { + var res []*flatrpc.FileInfo + for _, glob := range files { + glob = filepath.FromSlash(glob) + if !strings.Contains(glob, "*") { + res = append(res, readFile(glob)) + continue + } + matches, err := filepath.Glob(glob) + if err != nil { + res = append(res, &flatrpc.FileInfo{ + Name: glob, + Error: err.Error(), + }) + continue } + for _, file := range matches { + res = append(res, readFile(file)) + } + } + return res +} + +func readFile(file string) *flatrpc.FileInfo { + data, err := os.ReadFile(file) + exists, errStr := true, "" + if err != nil { + exists, errStr = !os.IsNotExist(err), err.Error() + } + return &flatrpc.FileInfo{ + Name: file, + Exists: exists, + Error: errStr, + Data: data, } - return cfg } |
