aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/ipc/ipc_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-10-16 12:18:50 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-10-16 14:21:54 +0200
commit85b1f93f8dbbc767c564e494a6353aa3517d5d49 (patch)
tree702d2318a2ddcf1a576294a6a4981c58abcfcf61 /pkg/ipc/ipc_test.go
parentf78642861b4dbe396a67d5e2a750e22f83f3edd5 (diff)
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.
Diffstat (limited to 'pkg/ipc/ipc_test.go')
-rw-r--r--pkg/ipc/ipc_test.go30
1 files changed, 16 insertions, 14 deletions
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)