Commit cbf45fd2 authored by Steven Allen's avatar Steven Allen

test: avoid fuzzing while the race detector is enabled

It's too slow.
parent 03118146
//+build !race
package chunk
import (
"testing"
)
func TestFuzzBuzhashChunking(t *testing.T) {
buf := make([]byte, 1024*1024*16)
for i := 0; i < 100; i++ {
testBuzhashChunking(t, buf)
}
}
...@@ -8,16 +8,10 @@ import ( ...@@ -8,16 +8,10 @@ import (
util "github.com/ipfs/go-ipfs-util" util "github.com/ipfs/go-ipfs-util"
) )
func TestBuzhashChunking(t *testing.T) { func testBuzhashChunking(t *testing.T, buf []byte) (chunkCount int) {
data := make([]byte, 1024*1024*16) util.NewTimeSeededRand().Read(buf)
chunkCount := 0
rounds := 100
for i := 0; i < rounds; i++ { r := NewBuzhash(bytes.NewReader(buf))
util.NewTimeSeededRand().Read(data)
r := NewBuzhash(bytes.NewReader(data))
var chunks [][]byte var chunks [][]byte
...@@ -47,11 +41,17 @@ func TestBuzhashChunking(t *testing.T) { ...@@ -47,11 +41,17 @@ func TestBuzhashChunking(t *testing.T) {
} }
unchunked := bytes.Join(chunks, nil) unchunked := bytes.Join(chunks, nil)
if !bytes.Equal(unchunked, data) { if !bytes.Equal(unchunked, buf) {
t.Fatal("data was chunked incorrectly") t.Fatal("data was chunked incorrectly")
} }
}
t.Logf("average block size: %d\n", len(data)*rounds/chunkCount) return chunkCount
}
func TestBuzhashChunking(t *testing.T) {
buf := make([]byte, 1024*1024*16)
count := testBuzhashChunking(t, buf)
t.Logf("average block size: %d\n", len(buf)/count)
} }
func TestBuzhashChunkReuse(t *testing.T) { func TestBuzhashChunkReuse(t *testing.T) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment