sanlock_read_resource_owners() fallback mechanism hides invalid align
size specified by the caller. Add a test reproducing this issue, and
specifying the wanted behaviour.
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
tests/python_test.py | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/tests/python_test.py b/tests/python_test.py
index 6f8f0bc..d5b81ae 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -21,11 +21,12 @@ from . import util
LARGE_FILE_SIZE = 1024**4
LOCKSPACE_SIZE = 1024**2
MIN_RES_SIZE = 1024**2
-ALIGNMENT_1M = 1024**2
+ALIGNMENT_1M = 1 * 1024**2
+ALIGNMENT_2M = 2 * 1024**2
SECTOR_SIZE_512 = 512
SECTOR_SIZE_4K = 4096
@pytest.mark.parametrize("size,offset", [
@@ -234,10 +235,33 @@ def test_read_resource_owners_4k_invalid_sector_size(
sanlock.read_resource_owners(
"ls_name", "res_name", disks, sector=SECTOR_SIZE_512)
assert e.value.errno == errno.EINVAL
+(a)pytest.mark.xfail(reason="fallback hides invalid user value")
+def test_read_resource_owners_invalid_align_size(tmpdir, sanlock_daemon):
+ path = str(tmpdir.join("path"))
+ util.create_file(path, 1024**3)
+ disks = [(path, 0)]
+
+ sanlock.write_resource(
+ "ls_name",
+ "res_name",
+ disks,
+ align=ALIGNMENT_1M,
+ sector=SECTOR_SIZE_512)
+
+ with pytest.raises(sanlock.SanlockException) as e:
+ sanlock.read_resource_owners(
+ "ls_name",
+ "res_name",
+ disks,
+ align=ALIGNMENT_2M,
+ sector=SECTOR_SIZE_512)
+ assert e.value.errno == errno.EINVAL
+
+
@pytest.mark.parametrize("size,offset", [
# Smallest offset.
(MIN_RES_SIZE, 0),
# Large offset.
(LARGE_FILE_SIZE, LARGE_FILE_SIZE - MIN_RES_SIZE),
--
2.17.2