diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2019-01-02 11:55:53 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2019-01-02 11:57:53 +0100 |
| commit | 06a2b89fc3e93a6c381a5d9df229766f706b58d0 (patch) | |
| tree | 8c740a2bb437f491c4b49fd3db51909883ad6378 /pkg | |
| parent | f0491811f9ad8ca5b982cb7ed5aa0d9167f08e5f (diff) | |
prog, pkg/{csource,ifuzz,ipc,repro}: make tests deterministic on travis
Don't use random seed on travis as it produces flaky coverage reports,
and probably generally better for CI setting.
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/csource/csource_test.go | 3 | ||||
| -rw-r--r-- | pkg/ifuzz/ifuzz_test.go | 4 | ||||
| -rw-r--r-- | pkg/ipc/ipc_test.go | 3 | ||||
| -rw-r--r-- | pkg/repro/repro_test.go | 4 |
4 files changed, 14 insertions, 0 deletions
diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go index 4fccebd92..ce2db21c0 100644 --- a/pkg/csource/csource_test.go +++ b/pkg/csource/csource_test.go @@ -61,6 +61,9 @@ func TestGenerate(t *testing.T) { func testTarget(t *testing.T, target *prog.Target, full bool) { seed := int64(time.Now().UnixNano()) + if os.Getenv("TRAVIS") != "" { + seed = 0 // required for deterministic coverage reports + } rs := rand.NewSource(seed) t.Logf("seed=%v", seed) p := target.Generate(rs, 10, nil) diff --git a/pkg/ifuzz/ifuzz_test.go b/pkg/ifuzz/ifuzz_test.go index bc5408a6f..3758f08d2 100644 --- a/pkg/ifuzz/ifuzz_test.go +++ b/pkg/ifuzz/ifuzz_test.go @@ -6,6 +6,7 @@ package ifuzz_test import ( "encoding/hex" "math/rand" + "os" "testing" "time" @@ -36,6 +37,9 @@ func TestMode(t *testing.T) { func TestDecode(t *testing.T) { seed := int64(time.Now().UnixNano()) + if os.Getenv("TRAVIS") != "" { + seed = 0 // required for deterministic coverage reports + } t.Logf("seed=%v", seed) r := rand.New(rand.NewSource(seed)) diff --git a/pkg/ipc/ipc_test.go b/pkg/ipc/ipc_test.go index dba14b190..d168a2535 100644 --- a/pkg/ipc/ipc_test.go +++ b/pkg/ipc/ipc_test.go @@ -38,6 +38,9 @@ func initTest(t *testing.T) (*prog.Target, rand.Source, int, EnvFlags) { iters = 10 } seed := int64(time.Now().UnixNano()) + if os.Getenv("TRAVIS") != "" { + seed = 0 // required for deterministic coverage reports + } rs := rand.NewSource(seed) t.Logf("seed=%v", seed) target, err := prog.GetTarget(runtime.GOOS, runtime.GOARCH) diff --git a/pkg/repro/repro_test.go b/pkg/repro/repro_test.go index a62354ca0..349b412fc 100644 --- a/pkg/repro/repro_test.go +++ b/pkg/repro/repro_test.go @@ -5,6 +5,7 @@ package repro import ( "math/rand" + "os" "testing" "time" @@ -18,6 +19,9 @@ func initTest(t *testing.T) (*rand.Rand, int) { iters = 100 } seed := int64(time.Now().UnixNano()) + if os.Getenv("TRAVIS") != "" { + seed = 0 // required for deterministic coverage reports + } rs := rand.NewSource(seed) t.Logf("seed=%v", seed) return rand.New(rs), iters |
