Merge pull request #311 from katlapinka/unaligned-tests
Add new negative io tests and raising error when failed to create io
This commit is contained in:
commit
a61664ddd8
@ -100,6 +100,10 @@ class Core:
|
|||||||
|
|
||||||
io = OcfLib.getInstance().ocf_core_new_io_wrapper(
|
io = OcfLib.getInstance().ocf_core_new_io_wrapper(
|
||||||
self.handle, queue.handle, addr, length, direction, io_class, flags)
|
self.handle, queue.handle, addr, length, direction, io_class, flags)
|
||||||
|
|
||||||
|
if io is None:
|
||||||
|
raise Exception("Failed to create io!")
|
||||||
|
|
||||||
return Io.from_pointer(io)
|
return Io.from_pointer(io)
|
||||||
|
|
||||||
def new_core_io(
|
def new_core_io(
|
||||||
|
@ -118,6 +118,36 @@ def test_neg_read_offset_outside_of_device(pyocf_ctx, c_int_sector_randomize):
|
|||||||
assert completion.results["err"] != 0
|
assert completion.results["err"] != 0
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.security
|
||||||
|
def test_neg_offset_unaligned(pyocf_ctx, c_int_randomize):
|
||||||
|
"""
|
||||||
|
Check that write operations are blocked when
|
||||||
|
IO offset is not aligned
|
||||||
|
"""
|
||||||
|
|
||||||
|
core = prepare_cache_and_core(Size.from_MiB(2))
|
||||||
|
data = Data(int(Size.from_KiB(1)))
|
||||||
|
if c_int_randomize % 512 != 0:
|
||||||
|
with pytest.raises(Exception, match="Failed to create io!"):
|
||||||
|
core.new_io(core.cache.get_default_queue(), c_int_randomize, data.size,
|
||||||
|
IoDir.WRITE, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.security
|
||||||
|
def test_neg_size_unaligned(pyocf_ctx, c_uint16_randomize):
|
||||||
|
"""
|
||||||
|
Check that write operations are blocked when
|
||||||
|
IO size is not aligned
|
||||||
|
"""
|
||||||
|
|
||||||
|
core = prepare_cache_and_core(Size.from_MiB(2))
|
||||||
|
data = Data(int(Size.from_B(c_uint16_randomize)))
|
||||||
|
if c_uint16_randomize % 512 != 0:
|
||||||
|
with pytest.raises(Exception, match="Failed to create io!"):
|
||||||
|
core.new_io(core.cache.get_default_queue(), 0, data.size,
|
||||||
|
IoDir.WRITE, 0, 0)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.security
|
@pytest.mark.security
|
||||||
def test_neg_io_class(pyocf_ctx, c_int_randomize):
|
def test_neg_io_class(pyocf_ctx, c_int_randomize):
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user