mirror of
https://github.com/reactos/syzkaller.git
synced 2024-11-23 19:39:40 +00:00
pkg/ipc: create default config based on target
Pass actual target to DefaultConfig, that's what we really want, not the stray ipc flag.
This commit is contained in:
parent
2c6c896b36
commit
bc1210b614
@ -12,7 +12,6 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
@ -68,7 +67,6 @@ var (
|
||||
flagAbortSignal = flag.Int("abort_signal", 0, "initial signal to send to executor"+
|
||||
" in error conditions; upgrades to SIGKILL if executor does not exit")
|
||||
flagBufferSize = flag.Uint64("buffer_size", 0, "internal buffer size (in bytes) for executor output")
|
||||
flagIPC = flag.String("ipc", "", "ipc scheme (pipe/shmem)")
|
||||
)
|
||||
|
||||
type ExecOpts struct {
|
||||
@ -103,7 +101,7 @@ type Config struct {
|
||||
BufferSize uint64
|
||||
}
|
||||
|
||||
func DefaultConfig() (*Config, *ExecOpts, error) {
|
||||
func DefaultConfig(target *prog.Target) (*Config, *ExecOpts, error) {
|
||||
c := &Config{
|
||||
Executor: *flagExecutor,
|
||||
Timeout: *flagTimeout,
|
||||
@ -126,22 +124,13 @@ func DefaultConfig() (*Config, *ExecOpts, error) {
|
||||
return nil, nil, fmt.Errorf("flag sandbox must contain one of none/setuid/namespace")
|
||||
}
|
||||
|
||||
sysTarget := targets.Get(runtime.GOOS, runtime.GOARCH)
|
||||
sysTarget := targets.Get(target.OS, target.Arch)
|
||||
if sysTarget.ExecutorUsesShmem {
|
||||
c.Flags |= FlagUseShmem
|
||||
}
|
||||
if sysTarget.ExecutorUsesForkServer {
|
||||
c.Flags |= FlagUseForkServer
|
||||
}
|
||||
switch *flagIPC {
|
||||
case "":
|
||||
case "pipe":
|
||||
c.Flags &^= FlagUseShmem
|
||||
case "shmem":
|
||||
c.Flags |= FlagUseShmem
|
||||
default:
|
||||
return nil, nil, fmt.Errorf("unknown ipc scheme: %v", *flagIPC)
|
||||
}
|
||||
|
||||
opts := &ExecOpts{
|
||||
Flags: FlagDedupCover,
|
||||
|
@ -41,7 +41,7 @@ func initTest(t *testing.T) (*prog.Target, rand.Source, int, EnvFlags) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cfg, _, err := DefaultConfig()
|
||||
cfg, _, err := DefaultConfig(target)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -94,6 +94,7 @@ func main() {
|
||||
|
||||
var (
|
||||
flagName = flag.String("name", "test", "unique name for manager")
|
||||
flagOS = flag.String("os", runtime.GOOS, "target OS")
|
||||
flagArch = flag.String("arch", runtime.GOARCH, "target arch")
|
||||
flagManager = flag.String("manager", "", "manager rpc address")
|
||||
flagProcs = flag.Int("procs", 1, "number of parallel test processes")
|
||||
@ -118,12 +119,12 @@ func main() {
|
||||
}
|
||||
log.Logf(0, "fuzzer started")
|
||||
|
||||
target, err := prog.GetTarget(runtime.GOOS, *flagArch)
|
||||
target, err := prog.GetTarget(*flagOS, *flagArch)
|
||||
if err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
|
||||
config, execOpts, err := ipc.DefaultConfig()
|
||||
config, execOpts, err := ipc.DefaultConfig(target)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to create default ipc config: %v", err)
|
||||
}
|
||||
|
@ -61,8 +61,7 @@ func main() {
|
||||
if _, err = host.Setup(features); err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
|
||||
config, execOpts := createConfig(entries, features)
|
||||
config, execOpts := createConfig(target, entries, features)
|
||||
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(*flagProcs)
|
||||
@ -206,8 +205,9 @@ func loadPrograms(target *prog.Target, files []string) []*prog.LogEntry {
|
||||
return entries
|
||||
}
|
||||
|
||||
func createConfig(entries []*prog.LogEntry, features *host.Features) (*ipc.Config, *ipc.ExecOpts) {
|
||||
config, execOpts, err := ipc.DefaultConfig()
|
||||
func createConfig(target *prog.Target, entries []*prog.LogEntry, features *host.Features) (
|
||||
*ipc.Config, *ipc.ExecOpts) {
|
||||
config, execOpts, err := ipc.DefaultConfig(target)
|
||||
if err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func main() {
|
||||
prios := target.CalculatePriorities(corpus)
|
||||
ct := target.BuildChoiceTable(prios, calls)
|
||||
|
||||
config, execOpts, err := ipc.DefaultConfig()
|
||||
config, execOpts, err := ipc.DefaultConfig(target)
|
||||
if err != nil {
|
||||
log.Fatalf("%v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user