Merge pull request #310 from robertbaldyga/test-sector-alignment

Test with io aligned to sector size
This commit is contained in:
Katarzyna Łapińska 2019-10-02 19:53:34 +02:00 committed by GitHub
commit 2c56f6eb37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View File

@ -38,6 +38,11 @@ def c_int_randomize(request):
return request.param
@pytest.fixture(params=RandomGenerator(DefaultRanges.INT))
def c_int_sector_randomize(request):
return request.param // 512 * 512
@pytest.fixture(params=RandomStringGenerator())
def string_randomize(request):
return request.param

View File

@ -85,7 +85,7 @@ def test_neg_read_too_far(pyocf_ctx, c_uint16_randomize):
@pytest.mark.security
def test_neg_write_offset_outside_of_device(pyocf_ctx, c_int_randomize):
def test_neg_write_offset_outside_of_device(pyocf_ctx, c_int_sector_randomize):
"""
Check that write operations are blocked when
IO offset is located outside of device range
@ -93,16 +93,16 @@ def test_neg_write_offset_outside_of_device(pyocf_ctx, c_int_randomize):
core = prepare_cache_and_core(Size.from_MiB(2))
data = Data(int(Size.from_KiB(1)))
completion = io_operation(core, data, IoDir.WRITE, offset=c_int_randomize)
completion = io_operation(core, data, IoDir.WRITE, offset=c_int_sector_randomize)
if 0 <= c_int_randomize <= int(Size.from_MiB(2)) - int(Size.from_KiB(1)):
if 0 <= c_int_sector_randomize <= int(Size.from_MiB(2)) - int(Size.from_KiB(1)):
assert completion.results["err"] == 0
else:
assert completion.results["err"] != 0
@pytest.mark.security
def test_neg_read_offset_outside_of_device(pyocf_ctx, c_int_randomize):
def test_neg_read_offset_outside_of_device(pyocf_ctx, c_int_sector_randomize):
"""
Check that read operations are blocked when
IO offset is located outside of device range
@ -110,9 +110,9 @@ def test_neg_read_offset_outside_of_device(pyocf_ctx, c_int_randomize):
core = prepare_cache_and_core(Size.from_MiB(2))
data = Data(int(Size.from_KiB(1)))
completion = io_operation(core, data, IoDir.READ, offset=c_int_randomize)
completion = io_operation(core, data, IoDir.READ, offset=c_int_sector_randomize)
if 0 <= c_int_randomize <= int(Size.from_MiB(2)) - int(Size.from_KiB(1)):
if 0 <= c_int_sector_randomize <= int(Size.from_MiB(2)) - int(Size.from_KiB(1)):
assert completion.results["err"] == 0
else:
assert completion.results["err"] != 0