Commit 727946ee authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 1d9b44e5
......@@ -32,10 +32,6 @@ from zodbtools.test.gen_testdata import run_with_zodb3py2_compat
K = 1024
def rm_f(path):
if os.path.exists(path):
os.remove(path)
def main():
run_with_zodb3py2_compat(main2)
......@@ -47,10 +43,10 @@ def main2():
conn = db.open()
root = conn.root()
# one ZBigFile with two data blocks
root['zbigf'] = zf = ZBigFile(2*1024*K)
root['zblk0'] = z0 = ZBlk0()
root['zblk1'] = z1 = ZBlk1() # also covers ZData
root['zbigf'] = zf = ZBigFile(2*1024*K)
# zblk0 with small data
z0.setblkdata(brange32(16*K))
......@@ -61,11 +57,11 @@ def main2():
zf.blktab[0] = z0
zf.blktab[1] = z1
# make sure there is at least one bucket in Z1's chunktab
# make sure there is at least one bucket in z1's chunktab
#
# we need at least one bucket to verify how zblk.go handles chunktab bucket loading;
# more than 1 bucket just wastes space, however with only 1 bucket a tree
# is serialized to have leaf nodes diectly in the tree state.
# is serialized to have leaf nodes directly in the tree state.
# -> verify for ==2 buckets.
assertIOBTreeHas2Buckets(z1.chunktab)
......@@ -92,7 +88,7 @@ def main2():
db.close()
# brange32 returns bytes with big-endian uint32 seqence filling them.
# brange32 returns bytes with big-endian uint32 sequence filling them.
# returned bytes has len == size.
def brange32(size):
# 0, 1, 2, ... as u32
......@@ -122,6 +118,11 @@ def assertIOBTreeHas2Buckets(t):
assert isinstance(_[0][2], IOBucket), _[0][2] # bucket1
assert isinstance(_[1], IOBucket), _[1] # .firstbucket
# rm_f is like `rm -f` in shell.
def rm_f(path):
if os.path.exists(path):
os.remove(path)
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment