From 85b1f93f8dbbc767c564e494a6353aa3517d5d49 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 16 Oct 2017 12:18:50 +0200 Subject: executor, pkg/ipc: unify ipc protocol between linux and other OSes We currently use more complex and functional protocol on linux, and a simple ad-hoc protocol on other OSes. This leads to code duplication in both ipc and executor. Linux supports coverage, shared memory communication and fork server, which would also be useful for most other OSes. Unify communication protocol and parametrize it by (1) use of shmem or only pipes, (2) use of fork server. This reduces duplication in ipc and executor and will allow to support the useful features for other OSes easily. Finally, this fixes akaros support as it currently uses syz-stress running on host (linux) and executor running on akaros. --- pkg/ipc/ipc_test.go | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) (limited to 'pkg/ipc/ipc_test.go') diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index ca0af1060..51e961119 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -42,7 +42,7 @@ func buildProgram(t *testing.T, target *prog.Target, src string) string { return bin } -func initTest(t *testing.T) (rand.Source, int) { +func initTest(t *testing.T) (*prog.Target, rand.Source, int, uint64) { t.Parallel() iters := 100 if testing.Short() { @@ -51,19 +51,26 @@ func initTest(t *testing.T) (rand.Source, int) { seed := int64(time.Now().UnixNano()) rs := rand.NewSource(seed) t.Logf("seed=%v", seed) - return rs, iters -} - -func TestEmptyProg(t *testing.T) { - target, err := prog.GetTarget("linux", runtime.GOARCH) + target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH) + if err != nil { + t.Fatal(err) + } + cfg, err := DefaultConfig() if err != nil { t.Fatal(err) } + flags := cfg.Flags & (FlagUseShmem | FlagUseForkServer) + return target, rs, iters, flags +} + +func TestEmptyProg(t *testing.T) { + target, _, _, flags0 := initTest(t) bin := buildExecutor(t, target) defer os.Remove(bin) cfg := Config{ + Flags: flags0, Timeout: timeout, } env, err := MakeEnv(bin, 0, cfg) @@ -87,21 +94,16 @@ func TestEmptyProg(t *testing.T) { } func TestExecute(t *testing.T) { - rs, iters := initTest(t) - flags := []uint64{0, FlagThreaded, FlagThreaded | FlagCollide} - - target, err := prog.GetTarget("linux", runtime.GOARCH) - if err != nil { - t.Fatal(err) - } + target, rs, iters, flags0 := initTest(t) bin := buildExecutor(t, target) defer os.Remove(bin) + flags := []uint64{0, FlagThreaded, FlagThreaded | FlagCollide} for _, flag := range flags { t.Logf("testing flags 0x%x\n", flag) cfg := Config{ - Flags: flag, + Flags: flag | flags0, Timeout: timeout, } env, err := MakeEnv(bin, 0, cfg) -- cgit mrf-deployment