From 5550dbaf09e758ea9270d82bc6357b5319ceb0cd Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Fri, 11 Mar 2022 12:40:53 +0100 Subject: [PATCH] tests: fix capabilities test Adjust manner of calculating some of the traits to the newer kernel version. New way of calculating them have been introduced in kernel with commit 97f433c3601a24d3513d06f575a389a2ca4e11e4. Signed-off-by: Michal Mielewczyk --- .../tests/misc/test_device_capabilities.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/functional/tests/misc/test_device_capabilities.py b/test/functional/tests/misc/test_device_capabilities.py index 1326126..95e591d 100644 --- a/test/functional/tests/misc/test_device_capabilities.py +++ b/test/functional/tests/misc/test_device_capabilities.py @@ -183,11 +183,23 @@ def compare_capabilities(cache_device, core_device, cache, core, msg): cache_val = cache_dev_capabilities[capability] core_val = core_dev_capabilities[capability] - comparison_val = method(core_val, cache_val) if method is not None else core_val + expected_val = method(core_val, cache_val) if method is not None else core_val - if comparison_val != cas_val: + if capability in ["max_sectors_kb", "max_hw_sectors_kb"] and expected_val != cas_val: + # On the newer kernels this trait is rounded. Instead of checking for + # the current kernel version, assume that both values are acceptable. + SECTOR_SHIFT = 9 + lbs = measure_capabilities(core)["logical_block_size"] + # The original uint is kb, but number of sectors is needed + new_expected_val = expected_val * 2 + round_val = lbs >> SECTOR_SHIFT + new_expected_val -= new_expected_val % round_val + # Restore the original unit + expected_val = new_expected_val // 2 + + if expected_val != cas_val: TestRun.LOGGER.error(f"Cas device {capability} is not set properly. Is: {cas_val}, " - f"should be {comparison_val} (cache: {cache_val}, " + f"should be {expected_val} (cache: {cache_val}, " f"core: {core_val})") continue TestRun.LOGGER.info(f"Cas device {capability} has proper value: {cas_val} "