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
8287b988
Commit
8287b988
authored
Mar 13, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
e5203906
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
55 deletions
+24
-55
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+24
-55
No files found.
wcfs/wcfs_test.py
View file @
8287b988
...
...
@@ -116,6 +116,7 @@ def test_join_autostart():
# tDB is database/wcfs testing environment.
# XXX + tFile ?
class
tDB
:
def
__init__
(
t
):
t
.
root
=
testdb
.
dbopen
()
...
...
@@ -193,6 +194,7 @@ class tDB:
return
open
(
path
)
# readblk reads ZBigFile[blk] from wcfs.
# XXX not needed?
@
func
def
readblk
(
t
,
zf
,
blk
,
at
=
None
):
assert
isinstance
(
zf
,
ZBigFile
)
...
...
@@ -211,18 +213,28 @@ class tDB:
return
data
# assert
Data asserts that wcfs file corresponding to zf has data blocks as specified in expectv
.
# assert
File asserts that wcfs file corresponding to zf has data blocks as specified
.
#
# Expected blocks may be given with size < zf.blksize. In such case they
# are implicitly appended with trailing zeros.
def
assertData
(
t
,
zf
,
expectv
,
at
=
None
):
#
# It also check file size and optionally mtime.
#
# XXX also check pagecache state?
def
assertFile
(
t
,
zf
,
blkv
,
mtime
=
None
,
at
=
None
):
assert
isinstance
(
zf
,
ZBigFile
)
st
=
t
.
stat
(
zf
,
at
=
at
)
assert
st
.
st_size
==
len
(
blkv
)
*
zf
.
blksize
if
mtime
is
not
None
:
assert
st
.
st_mtime
==
tidtime
(
mtime
)
data
=
t
.
read
(
zf
,
at
=
at
)
assert
len
(
data
)
==
len
(
expect
v
)
*
zf
.
blksize
for
i
,
blk
in
enumerate
(
expect
v
):
assert
len
(
data
)
==
len
(
blk
v
)
*
zf
.
blksize
for
i
,
blk
in
enumerate
(
blk
v
):
assert
len
(
blk
)
<=
zf
.
blksize
blk
+=
b'
\
0
'
*
(
zf
.
blksize
-
len
(
blk
))
# trailing zeros
assert
data
[
i
*
zf
.
blksize
:(
i
+
1
)
*
zf
.
blksize
]
==
blk
assert
data
[
i
*
zf
.
blksize
:(
i
+
1
)
*
zf
.
blksize
]
==
blk
,
(
"#blk: %d"
%
i
)
...
...
@@ -262,25 +274,8 @@ def test_wcfs():
t
.
commit
()
t
.
wcsync
()
# sync wcfs to ZODB
fsize
=
(
hole
+
1
)
*
blksize
# size is always mutiple of blksize.
_
=
t
.
stat
(
f
)
assert
_
.
st_size
==
fsize
assert
_
.
st_mtime
==
tidtime
(
t
.
head
)
t
.
assertData
(
f
,
[
b''
]
*
hole
+
[
s
])
for
i
in
range
(
hole
):
assert
t
.
readblk
(
f
,
i
)
==
b'
\
0
'
*
blksize
assert
t
.
readblk
(
f
,
hole
)
==
s
+
b'
\
0
'
*
(
blksize
-
len
(
s
))
data
=
t
.
read
(
f
)
assert
len
(
data
)
==
fsize
for
i
in
range
(
hole
):
assert
data
[
i
*
blksize
:(
i
+
1
)
*
blksize
]
==
b'
\
0
'
*
blksize
tail
=
data
[
hole
*
blksize
:]
assert
tail
[:
len
(
s
)]
==
s
assert
tail
[
len
(
s
):]
==
b'
\
0
'
*
(
blksize
-
len
(
s
))
# XXX assert cache = ø
t
.
assertFile
(
f
,
[
b''
]
*
hole
+
[
s
],
mtime
=
t
.
head
)
# commit data again and make sure we can see both latest and snapshotted states.
...
...
@@ -297,39 +292,13 @@ def test_wcfs():
t
.
commit
()
t
.
wcsync
()
fsize1
=
fsize
fsize
=
fsize1
+
blksize
# we added one more block
_
=
t
.
stat
(
f
)
assert
_
.
st_size
==
fsize
assert
_
.
st_mtime
==
tidtime
(
t
.
head
)
data
=
t
.
read
(
f
)
assert
len
(
data
)
==
fsize
for
i
in
range
(
hole
):
assert
data
[
i
*
blksize
:(
i
+
1
)
*
blksize
]
==
b'
\
0
'
*
blksize
tail1
=
data
[
hole
*
blksize
:(
hole
+
1
)
*
blksize
]
assert
tail1
[:
len
(
s1
)]
==
s1
assert
tail1
[
len
(
s1
):
len
(
s
)]
==
"ld"
assert
tail1
[
len
(
s
):]
==
b'
\
0
'
*
(
blksize
-
len
(
s
))
tail2
=
data
[(
hole
+
1
)
*
blksize
:]
assert
tail2
[:
len
(
s2
)]
==
s2
assert
tail2
[
len
(
s2
):]
==
b'
\
0
'
*
(
blksize
-
len
(
s2
))
# f @head
# XXX assert cache
t
.
assertFile
(
f
,
[
b''
]
*
hole
+
[
s1
+
b'ld'
,
s2
],
mtime
=
t
.
head
)
# f @tcommit1
st
=
t
.
stat
(
f
,
at
=
tcommit1
)
assert
st
.
st_size
==
fsize1
#assert st.st_mtime == tidtime(tcommit1) FIXME mtime for @revX -> = revX ?
#assert readfile(fpath + "/at") == h(tcommit1) XXX do we need it?
data
=
t
.
read
(
f
,
at
=
tcommit1
)
assert
len
(
data
)
==
fsize1
for
i
in
range
(
hole
):
assert
data
[
i
*
blksize
:(
i
+
1
)
*
blksize
]
==
b'
\
0
'
*
blksize
tail
=
data
[
hole
*
blksize
:]
assert
tail
[:
len
(
s
)]
==
s
assert
tail
[
len
(
s
):]
==
b'
\
0
'
*
(
blksize
-
len
(
s
))
# XXX assert cache
t
.
assertFile
(
f
,
[
b''
]
*
hole
+
[
s
],
at
=
tcommit1
)
# XXX + mtime=tcommit1?
# TODO pagecache state after loading (via mincore)
...
...
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