Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jacobsa-fuse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
jacobsa-fuse
Commits
ad658493
Commit
ad658493
authored
Dec 19, 2016
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for OutMessage.Grow.
parent
e329c0ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
1 deletion
+30
-1
internal/buffer/out_message_test.go
internal/buffer/out_message_test.go
+30
-1
No files found.
internal/buffer/out_message_test.go
View file @
ad658493
...
...
@@ -92,7 +92,10 @@ func TestOutMessageReset(t *testing.T) {
const
trials
=
100
for
i
:=
0
;
i
<
trials
;
i
++
{
fillWithGarbage
(
unsafe
.
Pointer
(
h
),
int
(
unsafe
.
Sizeof
(
*
h
)))
err
:=
fillWithGarbage
(
unsafe
.
Pointer
(
h
),
int
(
unsafe
.
Sizeof
(
*
h
)))
if
err
!=
nil
{
t
.
Fatalf
(
"fillWithGarbage: %v"
,
err
)
}
om
.
Reset
()
if
h
.
Len
!=
0
{
...
...
@@ -109,6 +112,32 @@ func TestOutMessageReset(t *testing.T) {
}
}
func
TestOutMessageGrow
(
t
*
testing
.
T
)
{
var
om
OutMessage
// Overwrite with garbage.
err
:=
fillWithGarbage
(
unsafe
.
Pointer
(
&
om
),
int
(
unsafe
.
Sizeof
(
om
)))
if
err
!=
nil
{
t
.
Fatalf
(
"fillWithGarbage: %v"
,
err
)
}
// Zero the header.
om
.
Reset
()
// Grow to the max size. This should zero the message.
if
p
:=
om
.
Grow
(
MaxReadSize
);
p
==
nil
{
t
.
Fatal
(
"Grow returned nil"
)
}
// Check that everything has been zeroed.
b
:=
om
.
Bytes
()
for
i
,
x
:=
range
b
{
if
x
!=
0
{
t
.
Fatalf
(
"non-zero byte 0x%02x at offset %d"
,
x
,
i
)
}
}
}
func
BenchmarkOutMessageReset
(
b
*
testing
.
B
)
{
// A single buffer, which should fit in some level of CPU cache.
b
.
Run
(
"Single buffer"
,
func
(
b
*
testing
.
B
)
{
...
...
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