From 5798cdddb54482eef86ecc5d6b98c19b079b370e Mon Sep 17 00:00:00 2001 From: Ferenc Szabo Date: Wed, 20 Feb 2019 13:06:35 +0100 Subject: [PATCH] swarm/network: run TestFileRetrieval with fewer nodes with -race Otherwise we get a failure due to extensive memory usage, as the CGO runtime cannot allocate more bytes. === RUN TestFileRetrieval ==7366==ERROR: ThreadSanitizer failed to allocate 0x80000 (524288) bytes of clock allocator (error code: 12) FATAL: ThreadSanitizer CHECK failed: ./gotsan.cc:6976 "((0 && "unable to mmap")) != (0)" (0x0, 0x0) FAIL github.com/ethereum/go-ethereum/swarm/network/stream 155.165s --- .../network/stream/snapshot_retrieval_test.go | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/swarm/network/stream/snapshot_retrieval_test.go b/swarm/network/stream/snapshot_retrieval_test.go index afb023ae29..5bdd851068 100644 --- a/swarm/network/stream/snapshot_retrieval_test.go +++ b/swarm/network/stream/snapshot_retrieval_test.go @@ -22,6 +22,8 @@ import ( "testing" "time" + "github.com/ethereum/go-ethereum/swarm/testutil" + "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/p2p/enode" "github.com/ethereum/go-ethereum/p2p/simulations/adapters" @@ -43,23 +45,24 @@ const ( //Files are uploaded to nodes, other nodes try to retrieve the file //Number of nodes can be provided via commandline too. func TestFileRetrieval(t *testing.T) { + var nodeCount []int + if *nodes != 0 { - err := runFileRetrievalTest(*nodes) - if err != nil { - t.Fatal(err) - } + nodeCount = []int{*nodes} } else { - nodeCnt := []int{16} - //if the `longrunning` flag has been provided - //run more test combinations + nodeCount = []int{16} + if *longrunning { - nodeCnt = append(nodeCnt, 32, 64, 128) + nodeCount = append(nodeCount, 32, 64, 128) + } else if testutil.RaceEnabled { + nodeCount = []int{4} } - for _, n := range nodeCnt { - err := runFileRetrievalTest(n) - if err != nil { - t.Fatal(err) - } + + } + + for _, nc := range nodeCount { + if err := runFileRetrievalTest(nc); err != nil { + t.Error(err) } } }