Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3-chunker
Commits
cbf45fd2
Commit
cbf45fd2
authored
Mar 26, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: avoid fuzzing while the race detector is enabled
It's too slow.
parent
03118146
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
33 deletions
+47
-33
buzhash_norace_test.go
buzhash_norace_test.go
+14
-0
buzhash_test.go
buzhash_test.go
+33
-33
No files found.
buzhash_norace_test.go
0 → 100644
View file @
cbf45fd2
//+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
)
}
}
buzhash_test.go
View file @
cbf45fd2
...
@@ -8,50 +8,50 @@ import (
...
@@ -8,50 +8,50 @@ 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
for
{
chunk
,
err
:=
r
.
NextBytes
()
for
{
if
err
!=
nil
{
chunk
,
err
:=
r
.
NextBytes
()
if
err
==
io
.
EOF
{
if
err
!=
nil
{
break
if
err
==
io
.
EOF
{
break
}
t
.
Fatal
(
err
)
}
}
t
.
Fatal
(
err
)
chunks
=
append
(
chunks
,
chunk
)
}
}
chunkCount
+=
len
(
chunks
)
for
i
,
chunk
:=
range
chunks
{
chunks
=
append
(
chunks
,
chunk
)
if
len
(
chunk
)
==
0
{
}
t
.
Fatalf
(
"chunk %d/%d is empty"
,
i
+
1
,
len
(
chunks
))
chunkCount
+=
len
(
chunks
)
}
}
for
i
,
chunk
:=
range
chunks
[
:
len
(
chunks
)
-
1
]
{
for
i
,
chunk
:=
range
chunks
{
if
len
(
chunk
)
<
buzMin
{
if
len
(
chunk
)
==
0
{
t
.
Fatalf
(
"chunk %d/%d is less than the minimum size"
,
i
+
1
,
len
(
chunks
))
t
.
Fatalf
(
"chunk %d/%d is empty"
,
i
+
1
,
len
(
chunks
))
}
}
}
}
un
chunk
ed
:=
bytes
.
Joi
n
(
chunks
,
nil
)
for
i
,
chunk
:=
range
chunks
[
:
le
n
(
chunks
)
-
1
]
{
if
!
bytes
.
Equal
(
unchunked
,
data
)
{
if
len
(
chunk
)
<
buzMin
{
t
.
Fatal
(
"
data was chunked incorrectly"
)
t
.
Fatal
f
(
"
chunk %d/%d is less than the minimum size"
,
i
+
1
,
len
(
chunks
)
)
}
}
}
}
t
.
Logf
(
"average block size: %d
\n
"
,
len
(
data
)
*
rounds
/
chunkCount
)
unchunked
:=
bytes
.
Join
(
chunks
,
nil
)
if
!
bytes
.
Equal
(
unchunked
,
buf
)
{
t
.
Fatal
(
"data was chunked incorrectly"
)
}
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment