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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
e07b8e4e
Commit
e07b8e4e
authored
Mar 12, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
25f5ea2f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
18 deletions
+30
-18
wcfs/wcfs_test.py
wcfs/wcfs_test.py
+30
-18
No files found.
wcfs/wcfs_test.py
View file @
e07b8e4e
...
...
@@ -159,16 +159,29 @@ class tDB:
raise
RuntimeError
(
"wcsync #%d: wczhead (%s) != zhead (%s)"
%
(
i
,
wchead
,
t
.
_headv
[
i
]))
t
.
_wc_zheadv
.
append
(
wchead
)
# path returns path joined with wcfs root
def
path
(
t
,
path
):
return
os
.
path
.
join
(
t
.
wc
.
mountpoint
,
path
)
# path returns path for object on wcfs.
# - str: wcfs root + obj;
# - Persistent: wcfs root + (head|@<rev>)/bigfile/obj
def
path
(
t
,
obj
,
rev
=
None
):
if
isinstance
(
obj
,
Persistent
):
head
=
"head/"
if
rev
is
None
else
(
"@%s/"
%
h
(
rev
))
obj
=
"%s/bigfile/%s"
%
(
head
,
h
(
obj
.
_p_oid
))
rev
=
None
# fpath returns wcfs path for file corresponding to object ID.
# By default head/... is returned. If rev != None - @<rev>/... is returned.
# XXX -> filepath? fpath?
def
filepath
(
t
,
obj
,
rev
=
None
):
head
=
"head/"
if
rev
is
None
else
(
"@%s/"
%
h
(
rev
))
return
t
.
path
(
"%s/bigfile/%s"
%
(
head
,
h
(
obj
.
_p_oid
)))
assert
isinstance
(
obj
,
str
)
assert
rev
is
None
# must not be used with str
return
os
.
path
.
join
(
t
.
wc
.
mountpoint
,
obj
)
# read reads file corresponding to obj on wcfs
def
read
(
t
,
obj
,
rev
=
None
):
path
=
t
.
path
(
obj
,
rev
=
rev
)
return
readfile
(
path
)
# stat stats file corresponding to obj on wcfs
def
stat
(
t
,
obj
,
rev
=
None
):
path
=
t
.
path
(
obj
,
rev
=
rev
)
return
os
.
stat
(
path
)
# XXX text ...
...
...
@@ -188,13 +201,10 @@ def test_wcfs():
# lookup to non-BigFile - must be rejected
with
raises
(
OSError
)
as
exc
:
os
.
stat
(
t
.
filepath
(
nonfile
)
)
t
.
stat
(
nonfile
)
assert
exc
.
value
.
errno
==
EINVAL
# path to f under wcfs
fpath
=
t
.
filepath
(
f
)
st
=
os
.
stat
(
fpath
)
st
=
t
.
stat
(
f
)
assert
st
.
st_size
==
0
assert
st
.
st_mtime
==
tidtime
(
tid1
)
...
...
@@ -217,12 +227,12 @@ def test_wcfs():
# we wrote "hello world" after hole'th block, but size is always mutiple of blksize.
fsize
=
(
hole
+
1
)
*
blksize
st
=
os
.
stat
(
fpath
)
st
=
t
.
stat
(
f
)
assert
st
.
st_size
==
fsize
assert
st
.
st_mtime
==
tidtime
(
t
.
head
)
assert
readfile
(
t
.
path
(
"head/at"
))
==
h
(
t
.
head
)
data
=
readfile
(
fpath
)
data
=
t
.
read
(
f
)
assert
len
(
data
)
==
fsize
for
i
in
range
(
hole
):
assert
data
[
i
*
blksize
:(
i
+
1
)
*
blksize
]
==
b'
\
0
'
*
blksize
...
...
@@ -248,12 +258,13 @@ def test_wcfs():
fsize1
=
fsize
fsize
=
fsize1
+
blksize
# we added one more block
st
=
os
.
stat
(
fpath
)
st
=
t
.
stat
(
f
)
assert
st
.
st_size
==
fsize
assert
st
.
st_mtime
==
tidtime
(
t
.
head
)
assert
t
.
read
(
"head/at"
)
==
h
(
t
.
head
)
assert
readfile
(
t
.
path
(
"head/at"
))
==
h
(
t
.
head
)
data
=
readfile
(
fpath
)
data
=
t
.
read
(
f
)
assert
len
(
data
)
==
fsize
for
i
in
range
(
hole
):
assert
data
[
i
*
blksize
:(
i
+
1
)
*
blksize
]
==
b'
\
0
'
*
blksize
...
...
@@ -274,6 +285,7 @@ def test_wcfs():
#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
,
rev
=
tcommit1
)
data
=
readfile
(
fpath1
)
assert
len
(
data
)
==
fsize1
for
i
in
range
(
hole
):
...
...
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