From caddc6cbcef9933a4539a06714df006e0c5ac7b2 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Tue, 22 Nov 2022 12:03:55 +0100 Subject: pkg/testutil: add RandSource helper The code to send rand source is dublicated in several packages. Move it to testutil package. --- pkg/ipc/ipc_test.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'pkg/ipc') diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index 3456852c5..0734fbe6e 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -16,6 +16,7 @@ import ( . "github.com/google/syzkaller/pkg/ipc" "github.com/google/syzkaller/pkg/ipc/ipcconfig" "github.com/google/syzkaller/pkg/osutil" + "github.com/google/syzkaller/pkg/testutil" "github.com/google/syzkaller/prog" _ "github.com/google/syzkaller/sys" "github.com/google/syzkaller/sys/targets" @@ -36,12 +37,6 @@ func initTest(t *testing.T) (*prog.Target, rand.Source, int, bool, bool, targets if testing.Short() { iters = 10 } - seed := time.Now().UnixNano() - if os.Getenv("CI") != "" { - seed = 0 // required for deterministic coverage reports - } - rs := rand.NewSource(seed) - t.Logf("seed=%v", seed) target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH) if err != nil { t.Fatal(err) @@ -50,6 +45,7 @@ func initTest(t *testing.T) (*prog.Target, rand.Source, int, bool, bool, targets if err != nil { t.Fatal(err) } + rs := testutil.RandSource(t) return target, rs, iters, cfg.UseShmem, cfg.UseForkServer, cfg.Timeouts } -- cgit mrf-deployment