Alien-Libjio
view release on metacpan or search on metacpan
libjio/tests/behaviour/t_normal.py view on Meta::CPAN
pass
else:
raise AssertionError
cleanup(n)
def test_n17():
"move journal to an existing dir"
import os
f, jf = bitmp()
n = f.name
p = tmppath()
os.mkdir(p)
open(p + '/x', 'w')
jf.write('x')
jf.jmove_journal(p)
jf.write('y')
del jf
os.unlink(p + '/x')
assert libjio.jfsck(n, p)['total'] == 0
os.unlink(n)
def test_n18():
"jtrans_rollback with norollback"
c = gencontent()
f, jf = bitmp(jflags = libjio.J_NOROLLBACK)
n = f.name
t = jf.new_trans()
t.add_w(c, 80)
t.commit()
try:
t.rollback()
except IOError:
pass
else:
raise AssertionError
assert content(n) == '\0' * 80 + c
fsck_verify(n)
cleanup(n)
def test_n19():
"jwrite in files opened with O_APPEND"
c1 = gencontent()
c2 = gencontent()
f, jf = bitmp(mode = 'a')
n = f.name
jf.write(c1)
jf.write(c2)
assert content(n) == c1 + c2
fsck_verify(n)
cleanup(n)
def test_n20():
"jtrans_add_w of 0 length"
f, jf = bitmp()
n = f.name
t = jf.new_trans()
try:
t.add_w('', 80)
except IOError:
pass
else:
raise AssertionError
del t
del jf
fsck_verify(n)
cleanup(n)
def test_n21():
"jwritev and jreadv"
f, jf = bitmp()
n = f.name
jf.writev(["hello ", "world"])
l = [bytearray("......"), bytearray(".....")]
jf.lseek(0, 0)
jf.readv(l)
assert content(n) == "hello world"
assert l[0] == "hello " and l[1] == "world"
fsck_verify(n)
cleanup(n)
def test_n22():
"jpread/jpwrite ~2mb"
c = gencontent(2 * 1024 * 1024 + 1465)
f, jf = bitmp(jflags = libjio.J_LINGER)
n = f.name
jf.pwrite(c, 2000)
assert content(n) == '\0' * 2000 + c
assert jf.pread(len(c), 2000) == c
del jf
fsck_verify(n)
cleanup(n)
def test_n23():
"jtrans_add_w + jtrans_add_r"
f, jf = bitmp()
n = f.name
c1 = gencontent(1000)
c2 = gencontent(1000)
c3 = gencontent(1000)
buf1 = bytearray(0 for i in range(30))
buf2 = bytearray(0 for i in range(100))
t = jf.new_trans()
( run in 1.075 second using v1.01-cache-2.11-cpan-f0fbb3f571b )