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
7c543380
Commit
7c543380
authored
Sep 10, 2015
by
Aaron Jacobs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for the newly-documented behavior on Darwin.
parent
81c3047f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
22 deletions
+85
-22
fuseops/ops.go
fuseops/ops.go
+3
-1
samples/statfs/statfs_darwin_test.go
samples/statfs/statfs_darwin_test.go
+79
-21
samples/statfs/statfs_test.go
samples/statfs/statfs_test.go
+3
-0
No files found.
fuseops/ops.go
View file @
7c543380
...
@@ -69,7 +69,9 @@ type StatFSOp struct {
...
@@ -69,7 +69,9 @@ type StatFSOp struct {
BlocksAvailable
uint64
BlocksAvailable
uint64
// The preferred size of writes to and reads from the file system, in bytes.
// The preferred size of writes to and reads from the file system, in bytes.
// This may affect clients that use statfs(2) to size buffers correctly.
// This may affect clients that use statfs(2) to size buffers correctly. It
// does not appear to influence the size of writes sent from the kernel to
// the file system daemon.
//
//
// On Linux this is surfaced as statfs::f_bsize, and on OS X as
// On Linux this is surfaced as statfs::f_bsize, and on OS X as
// statfs::f_iosize. Both are documented in `man 2 statfs` as "optimal
// statfs::f_iosize. Both are documented in `man 2 statfs` as "optimal
...
...
samples/statfs/statfs_darwin_test.go
View file @
7c543380
...
@@ -16,6 +16,7 @@ package statfs_test
...
@@ -16,6 +16,7 @@ package statfs_test
import
(
import
(
"fmt"
"fmt"
"math"
"regexp"
"regexp"
"syscall"
"syscall"
...
@@ -81,6 +82,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
...
@@ -81,6 +82,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
// Set up the canned response.
// Set up the canned response.
canned
:=
fuseops
.
StatFSOp
{
canned
:=
fuseops
.
StatFSOp
{
BlockSize
:
1
<<
15
,
BlockSize
:
1
<<
15
,
IoSize
:
1
<<
16
,
Blocks
:
1
<<
51
+
3
,
Blocks
:
1
<<
51
+
3
,
BlocksFree
:
1
<<
43
+
5
,
BlocksFree
:
1
<<
43
+
5
,
...
@@ -97,7 +99,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
...
@@ -97,7 +99,7 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
AssertEq
(
nil
,
err
)
AssertEq
(
nil
,
err
)
ExpectEq
(
canned
.
BlockSize
,
stat
.
Bsize
)
ExpectEq
(
canned
.
BlockSize
,
stat
.
Bsize
)
ExpectEq
(
canned
.
Block
Size
,
stat
.
Iosize
)
ExpectEq
(
canned
.
Io
Size
,
stat
.
Iosize
)
ExpectEq
(
canned
.
Blocks
,
stat
.
Blocks
)
ExpectEq
(
canned
.
Blocks
,
stat
.
Blocks
)
ExpectEq
(
canned
.
BlocksFree
,
stat
.
Bfree
)
ExpectEq
(
canned
.
BlocksFree
,
stat
.
Bfree
)
ExpectEq
(
canned
.
BlocksAvailable
,
stat
.
Bavail
)
ExpectEq
(
canned
.
BlocksAvailable
,
stat
.
Bavail
)
...
@@ -108,30 +110,35 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
...
@@ -108,30 +110,35 @@ func (t *StatFSTest) Syscall_NonZeroValues() {
ExpectEq
(
fsName
,
convertName
(
stat
.
Mntfromname
[
:
]))
ExpectEq
(
fsName
,
convertName
(
stat
.
Mntfromname
[
:
]))
}
}
func
(
t
*
StatFSTest
)
Unsupported
BlockSizes
()
{
func
(
t
*
StatFSTest
)
BlockSizes
()
{
var
err
error
var
err
error
// Test a bunch of block sizes that the OS does
n't support faithfully,
// Test a bunch of block sizes that the OS does
or doesn't support
// checking what it transforms them too.
//
faithfully,
checking what it transforms them too.
testCases
:=
[]
struct
{
testCases
:=
[]
struct
{
fsBlockSize
uint32
fsBlockSize
uint32
expectedBsize
uint32
expectedBsize
uint32
expectedIosize
uint32
}{
}{
0
:
{
0
,
4096
,
65536
},
0
:
{
0
,
4096
},
1
:
{
1
,
512
,
512
},
1
:
{
1
,
512
},
2
:
{
3
,
512
,
512
},
2
:
{
3
,
512
},
3
:
{
511
,
512
,
512
},
3
:
{
511
,
512
},
4
:
{
513
,
1024
,
1024
},
4
:
{
512
,
512
},
5
:
{
1023
,
1024
,
1024
},
5
:
{
513
,
1024
},
6
:
{
4095
,
4096
,
4096
},
6
:
{
1023
,
1024
},
7
:
{
1
<<
17
-
1
,
1
<<
17
,
131072
},
7
:
{
1024
,
1024
},
8
:
{
1
<<
17
+
1
,
1
<<
17
,
1
<<
18
},
8
:
{
4095
,
4096
},
9
:
{
1
<<
18
+
1
,
1
<<
17
,
1
<<
19
},
9
:
{
1
<<
16
,
1
<<
16
},
10
:
{
1
<<
19
+
1
,
1
<<
17
,
1
<<
20
},
10
:
{
1
<<
17
-
1
,
1
<<
17
},
11
:
{
1
<<
20
+
1
,
1
<<
17
,
1
<<
20
},
11
:
{
1
<<
17
,
1
<<
17
},
12
:
{
1
<<
21
,
1
<<
17
,
1
<<
20
},
12
:
{
1
<<
17
+
1
,
1
<<
17
},
13
:
{
1
<<
30
,
1
<<
17
,
1
<<
20
},
13
:
{
1
<<
18
,
1
<<
17
},
14
:
{
1
<<
20
,
1
<<
17
},
15
:
{
math
.
MaxInt32
-
1
,
1
<<
17
},
16
:
{
math
.
MaxInt32
,
1
<<
17
},
17
:
{
math
.
MaxInt32
+
1
,
512
},
18
:
{
math
.
MaxInt32
+
1
<<
15
,
1
<<
15
},
19
:
{
math
.
MaxUint32
,
1
<<
17
},
}
}
for
i
,
tc
:=
range
testCases
{
for
i
,
tc
:=
range
testCases
{
...
@@ -151,6 +158,57 @@ func (t *StatFSTest) UnsupportedBlockSizes() {
...
@@ -151,6 +158,57 @@ func (t *StatFSTest) UnsupportedBlockSizes() {
AssertEq
(
nil
,
err
)
AssertEq
(
nil
,
err
)
ExpectEq
(
tc
.
expectedBsize
,
stat
.
Bsize
,
"%s"
,
desc
)
ExpectEq
(
tc
.
expectedBsize
,
stat
.
Bsize
,
"%s"
,
desc
)
}
}
func
(
t
*
StatFSTest
)
IoSizes
()
{
var
err
error
// Test a bunch of io sizes that the OS does or doesn't support faithfully,
// checking what it transforms them too.
testCases
:=
[]
struct
{
fsIoSize
uint32
expectedIosize
uint32
}{
0
:
{
0
,
4096
},
1
:
{
1
,
512
},
2
:
{
3
,
512
},
3
:
{
511
,
512
},
4
:
{
512
,
512
},
5
:
{
513
,
1024
},
6
:
{
1023
,
1024
},
7
:
{
1024
,
1024
},
8
:
{
4095
,
4096
},
9
:
{
1
<<
16
,
1
<<
16
},
10
:
{
1
<<
17
-
1
,
1
<<
17
},
11
:
{
1
<<
17
,
1
<<
17
},
12
:
{
1
<<
17
+
1
,
1
<<
18
},
13
:
{
1
<<
20
-
1
,
1
<<
20
},
14
:
{
1
<<
20
,
1
<<
20
},
15
:
{
1
<<
20
+
1
,
1
<<
20
},
16
:
{
math
.
MaxInt32
-
1
,
1
<<
20
},
17
:
{
math
.
MaxInt32
,
1
<<
20
},
18
:
{
math
.
MaxInt32
+
1
,
512
},
19
:
{
math
.
MaxInt32
+
1
<<
15
,
1
<<
15
},
20
:
{
math
.
MaxUint32
,
1
<<
20
},
}
for
i
,
tc
:=
range
testCases
{
desc
:=
fmt
.
Sprintf
(
"Case %d: IO size %d"
,
i
,
tc
.
fsIoSize
)
// Set up.
canned
:=
fuseops
.
StatFSOp
{
IoSize
:
tc
.
fsIoSize
,
Blocks
:
10
,
}
t
.
fs
.
SetStatFSResponse
(
canned
)
// Check.
var
stat
syscall
.
Statfs_t
err
=
syscall
.
Statfs
(
t
.
Dir
,
&
stat
)
AssertEq
(
nil
,
err
)
ExpectEq
(
tc
.
expectedIosize
,
stat
.
Iosize
,
"%s"
,
desc
)
ExpectEq
(
tc
.
expectedIosize
,
stat
.
Iosize
,
"%s"
,
desc
)
}
}
}
}
samples/statfs/statfs_test.go
View file @
7c543380
...
@@ -146,6 +146,8 @@ func (t *StatFSTest) CapacityAndFreeSpace() {
...
@@ -146,6 +146,8 @@ func (t *StatFSTest) CapacityAndFreeSpace() {
Blocks
:
1024
,
Blocks
:
1024
,
BlocksFree
:
896
,
BlocksFree
:
896
,
BlocksAvailable
:
768
,
BlocksAvailable
:
768
,
IoSize
:
1024
,
// Shouldn't matter.
}
}
// Check that df agrees with us about a range of block sizes.
// Check that df agrees with us about a range of block sizes.
...
@@ -173,6 +175,7 @@ func (t *StatFSTest) WriteSize() {
...
@@ -173,6 +175,7 @@ func (t *StatFSTest) WriteSize() {
// Set up a smallish block size.
// Set up a smallish block size.
canned
:=
fuseops
.
StatFSOp
{
canned
:=
fuseops
.
StatFSOp
{
BlockSize
:
8192
,
BlockSize
:
8192
,
IoSize
:
16384
,
Blocks
:
1234
,
Blocks
:
1234
,
BlocksFree
:
1234
,
BlocksFree
:
1234
,
BlocksAvailable
:
1234
,
BlocksAvailable
:
1234
,
...
...
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