diff --git a/pkg/compressio/compressio_test.go b/pkg/compressio/compressio_test.go index 7b40a6f1d..02208c8ed 100644 --- a/pkg/compressio/compressio_test.go +++ b/pkg/compressio/compressio_test.go @@ -154,8 +154,6 @@ func doTest(t harness, opts testOpts) { var hashKey = []byte("01234567890123456789012345678901") func TestCompress(t *testing.T) { - rand.Seed(time.Now().Unix()) - var ( data = initTest(t, 10*1024*1024) data0 = data[:0] diff --git a/pkg/compressio/nocompressio_test.go b/pkg/compressio/nocompressio_test.go index 25c2ba322..ae2908a45 100644 --- a/pkg/compressio/nocompressio_test.go +++ b/pkg/compressio/nocompressio_test.go @@ -18,14 +18,10 @@ import ( "bytes" "fmt" "io" - "math/rand" "testing" - "time" ) func TestNoCompress(t *testing.T) { - rand.Seed(time.Now().Unix()) - var ( data = initTest(t, 10*1024*1024) data0 = data[:0] diff --git a/pkg/state/statefile/statefile_test.go b/pkg/state/statefile/statefile_test.go index af9049f4c..1e6423a9b 100644 --- a/pkg/state/statefile/statefile_test.go +++ b/pkg/state/statefile/statefile_test.go @@ -22,7 +22,6 @@ import ( "math/rand" "runtime" "testing" - "time" "gvisor.dev/gvisor/pkg/compressio" ) @@ -44,8 +43,6 @@ type testCase struct { } func TestStatefile(t *testing.T) { - rand.Seed(time.Now().Unix()) - compression := map[string]CompressionLevel{ "none": CompressionLevelNone, "compressed": CompressionLevelFlateBestSpeed, diff --git a/pkg/tcpip/sample/tun_tcp_connect/main.go b/pkg/tcpip/sample/tun_tcp_connect/main.go index fa47c233e..810f4c23d 100644 --- a/pkg/tcpip/sample/tun_tcp_connect/main.go +++ b/pkg/tcpip/sample/tun_tcp_connect/main.go @@ -45,11 +45,9 @@ import ( "bytes" "fmt" "log" - "math/rand" "net" "os" "strconv" - "time" "gvisor.dev/gvisor/pkg/rawfile" "gvisor.dev/gvisor/pkg/tcpip" @@ -100,8 +98,6 @@ func main() { remoteAddrName := os.Args[4] remotePortName := os.Args[5] - rand.Seed(time.Now().UnixNano()) - addr := tcpip.AddrFromSlice(net.ParseIP(addrName).To4()) remote := tcpip.FullAddress{ NIC: 1, diff --git a/pkg/tcpip/sample/tun_tcp_echo/main.go b/pkg/tcpip/sample/tun_tcp_echo/main.go index e53c7948d..2223a17d1 100644 --- a/pkg/tcpip/sample/tun_tcp_echo/main.go +++ b/pkg/tcpip/sample/tun_tcp_echo/main.go @@ -25,12 +25,10 @@ import ( "flag" "io" "log" - "math/rand" "net" "os" "strconv" "strings" - "time" "gvisor.dev/gvisor/pkg/rawfile" "gvisor.dev/gvisor/pkg/tcpip" @@ -113,8 +111,6 @@ func main() { addrName := flag.Arg(1) portName := flag.Arg(2) - rand.Seed(time.Now().UnixNano()) - // Parse the mac address. maddr, err := net.ParseMAC(*mac) if err != nil { diff --git a/runsc/boot/loader.go b/runsc/boot/loader.go index cc94d205c..f00810559 100644 --- a/runsc/boot/loader.go +++ b/runsc/boot/loader.go @@ -19,7 +19,6 @@ import ( "encoding/json" "errors" "fmt" - mrand "math/rand" "os" "runtime" "strconv" @@ -294,11 +293,6 @@ type FDMapping struct { Host int } -func init() { - // Initialize the random number generator. - mrand.Seed(gtime.Now().UnixNano()) -} - // Args are the arguments for New(). type Args struct { // Id is the sandbox ID. diff --git a/runsc/boot/loader_test.go b/runsc/boot/loader_test.go index 414e553c8..ab99ee5c2 100644 --- a/runsc/boot/loader_test.go +++ b/runsc/boot/loader_test.go @@ -41,7 +41,6 @@ import ( func init() { log.SetLevel(log.Debug) - rand.Seed(time.Now().UnixNano()) if err := fsgofer.OpenProcSelfFD("/proc/self/fd"); err != nil { panic(err) } diff --git a/test/benchmarks/tcp/tcp_proxy.go b/test/benchmarks/tcp/tcp_proxy.go index 47a4ec9fc..eef0a7f10 100644 --- a/test/benchmarks/tcp/tcp_proxy.go +++ b/test/benchmarks/tcp/tcp_proxy.go @@ -398,10 +398,6 @@ func main() { if *forward == "" { log.Fatalf("no forward provided") } - // Seed the random number generator to ensure that we are given MAC addresses that don't - // for the case of the client and server stack. - rand.Seed(time.Now().UTC().UnixNano()) - if *cpuprofile != "" { f, err := os.Create(*cpuprofile) if err != nil { diff --git a/test/fsstress/fsstress_test.go b/test/fsstress/fsstress_test.go index 120c1d204..4bef05d4a 100644 --- a/test/fsstress/fsstress_test.go +++ b/test/fsstress/fsstress_test.go @@ -24,17 +24,12 @@ import ( "strconv" "strings" "testing" - "time" "github.com/docker/docker/api/types/mount" "gvisor.dev/gvisor/pkg/test/dockerutil" "gvisor.dev/gvisor/pkg/test/testutil" ) -func init() { - rand.Seed(int64(time.Now().Nanosecond())) -} - func TestMain(m *testing.M) { dockerutil.EnsureSupportedDockerVersion() flag.Parse()