Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
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
Joshua
wendelin.core
Commits
48c38201
Commit
48c38201
authored
Mar 15, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
d6640f97
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletion
+32
-1
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+32
-1
No files found.
wcfs/wcfs_test.py
View file @
48c38201
...
...
@@ -233,6 +233,14 @@ class tFile:
mm
.
unmap
(
t
.
fmmap
)
t
.
f
.
close
()
# sizeblk returns file size in blocks.
def
sizeblk
(
t
):
st
=
os
.
fstat
(
t
.
f
.
fileno
())
assert
st
.
st_size
%
t
.
blksize
==
0
assert
st
.
st_size
//
t
.
blksize
<=
t
.
_max_tracked
return
st
.
st_size
//
t
.
blksize
"""
# readblk reads ZBigFile[blk] from wcfs.
# XXX not needed?
...
...
@@ -258,7 +266,9 @@ class tFile:
#
# incorev is [] of 1/0 representing whether block data is present or not.
def
assertCache
(
t
,
incorev
):
pass
# TODO
pass
# XXX todo
#mm.incore(
# blk returns bytearray connected to view of file[blk].
...
...
@@ -266,6 +276,24 @@ class tFile:
assert
blk
<=
t
.
_max_tracked
return
bytearray
(
t
.
fmmap
[
blk
*
t
.
blksize
:(
blk
+
1
)
*
t
.
blksize
])
# cached returns [] with indicating whether of file block is cached or not.
# 1 - cached, 0 - not cached, fractional (0,1) - some pages of the block are cached some not.
def
cached
(
t
):
l
=
t
.
sizeblk
()
incorev
=
mm
.
incore
(
t
.
fmmap
[:
l
*
t
.
blksize
])
# incorev is in pages; convert to in blocks
assert
t
.
blksize
%
mm
.
PAGE_SIZE
==
0
blkpages
=
t
.
blksize
//
mm
.
PAGE_SIZE
cachev
=
[
0.
]
*
l
for
i
,
v
in
enumerate
(
incorev
):
blk
=
i
//
blkpages
cachev
[
blk
]
+=
bool
(
v
)
for
blk
in
range
(
l
):
cachev
[
blk
]
/=
blkpages
if
cachev
[
blk
]
==
int
(
cachev
[
blk
]):
cachev
[
blk
]
=
int
(
cachev
[
blk
])
# 0.0 -> 0, 1.0 -> 1
return
cachev
# assertBlk asserts that file block #blk has data as expected.
#
# Expected data may be given with size < t.blksize. In such case the data
...
...
@@ -280,6 +308,9 @@ class tFile:
assert
t
.
blk
(
blk
)
==
data
,
(
"#blk: %d"
%
blk
)
# we just accessed the block - it has to be in OS cache
assert
t
.
cached
()[
blk
]
==
1
# assertData asserts that file has data blocks as specified.
#
...
...
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