Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go-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
Levin Zimmermann
go-fuse
Commits
1adb5bd3
Commit
1adb5bd3
authored
Nov 26, 2012
by
Han-Wen Nienhuys
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix int64 handlemap.
parent
92ccb1ff
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
32 deletions
+44
-32
fuse/handle.go
fuse/handle.go
+5
-4
fuse/handle_test.go
fuse/handle_test.go
+39
-28
No files found.
fuse/handle.go
View file @
1adb5bd3
...
...
@@ -285,6 +285,7 @@ func (m *int64HandleMap) Register(obj *Handled) (handle uint64) {
panic
(
_ALREADY_MSG
)
}
obj
.
check
=
check
obj
.
handle
=
handle
m
.
handles
[
handle
]
=
obj
}
else
{
handle
=
m
.
Handle
(
obj
)
...
...
fuse/handle_test.go
View file @
1adb5bd3
...
...
@@ -20,22 +20,6 @@ func markSeen(t *testing.T, substr string) {
}
}
func
TestHandleMapDoubleRegister
(
t
*
testing
.
T
)
{
if
unsafe
.
Sizeof
(
t
)
<
8
{
t
.
Log
(
"skipping test for 32 bits"
)
return
}
t
.
Log
(
"TestDoubleRegister"
)
defer
markSeen
(
t
,
"already has a handle"
)
hm
:=
NewHandleMap
(
false
)
obj
:=
&
Handled
{}
hm
.
Register
(
obj
)
v
:=
&
Handled
{}
hm
.
Register
(
v
)
hm
.
Register
(
v
)
t
.
Error
(
"Double register did not panic"
)
}
func
TestHandleMapUnaligned
(
t
*
testing
.
T
)
{
if
unsafe
.
Sizeof
(
t
)
<
8
{
t
.
Log
(
"skipping test for 32 bits"
)
...
...
@@ -51,19 +35,46 @@ func TestHandleMapUnaligned(t *testing.T) {
t
.
Error
(
"Unaligned register did not panic"
)
}
func
TestHandleMapPointerLayout
(
t
*
testing
.
T
)
{
if
unsafe
.
Sizeof
(
t
)
<
8
{
t
.
Log
(
"skipping test for 32 bits"
)
return
func
TestHandleMapLookupCount
(
t
*
testing
.
T
)
{
for
_
,
portable
:=
range
[]
bool
{
true
,
false
}
{
t
.
Log
(
"portable:"
,
portable
)
v
:=
new
(
Handled
)
hm
:=
NewHandleMap
(
portable
)
h1
:=
hm
.
Register
(
v
)
h2
:=
hm
.
Register
(
v
)
if
h1
!=
h2
{
t
.
Fatalf
(
"double register should reuse handle: got %d want %d."
,
h2
,
h1
)
}
hm
:=
NewHandleMap
(
false
)
bogus
:=
uint64
(
1
)
<<
uint32
((
8
*
(
unsafe
.
Sizeof
(
t
)
-
1
)))
p
:=
uintptr
(
bogus
)
v
:=
(
*
Handled
)(
unsafe
.
Pointer
(
p
))
defer
markSeen
(
t
,
"48"
)
hm
.
Register
(
v
)
t
.
Error
(
"bogus register did not panic"
)
forgotten
,
obj
:=
hm
.
Forget
(
h1
,
1
)
if
forgotten
{
t
.
Fatalf
(
"single forget unref forget object."
)
}
if
obj
!=
v
{
t
.
Fatalf
(
"should return input object."
)
}
if
!
hm
.
Has
(
h1
)
{
t
.
Fatalf
(
"handlemap.Has() returned false for live object."
)
}
forgotten
,
obj
=
hm
.
Forget
(
h1
,
2
)
if
!
forgotten
{
t
.
Fatalf
(
"unref did not forget object."
)
}
if
obj
!=
v
{
t
.
Fatalf
(
"should return input object."
)
}
if
hm
.
Has
(
h1
)
{
t
.
Fatalf
(
"handlemap.Has() returned false for live object."
)
}
}
}
func
TestHandleMapBasic
(
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