diff --git a/tests/functional/tests/security/conftest.py b/tests/functional/tests/security/conftest.py index 486f182..c586028 100644 --- a/tests/functional/tests/security/conftest.py +++ b/tests/functional/tests/security/conftest.py @@ -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 diff --git a/tests/functional/tests/security/test_negative_io.py b/tests/functional/tests/security/test_negative_io.py index 69a82ea..f915f71 100644 --- a/tests/functional/tests/security/test_negative_io.py +++ b/tests/functional/tests/security/test_negative_io.py @@ -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