---
tests/python_test.py | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/tests/python_test.py b/tests/python_test.py
index 2535af1..76e8c96 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -227,3 +227,41 @@ def test_acquire_release_resource(tmpdir, sanlock_daemon, size,
offset):
owners = sanlock.read_resource_owners("ls_name", "res_name",
disks)
assert owners == []
+
+
+(a)pytest.mark.parametrize("align, sector", [
+ # Invalid alignment
+ (1024, sanlock.SECTOR[0]),
+ # Invalid sector size
+ (sanlock.ALIGN[0], 8192),
+ # Invalid both alignment and sector size
+ (3145728, 8192),
+])
+def test_write_lockspace_invalid_align_sector(
+ tmpdir, sanlock_daemon, align, sector):
+ path = str(tmpdir.join("lockspace"))
+ util.create_file(path, LOCKSPACE_SIZE)
+
+ with pytest.raises(sanlock.SanlockException) as e:
+ sanlock.write_lockspace("name", path, align=align, sector=sector)
+ assert e.value.errno == errno.EINVAL
+
+
+(a)pytest.mark.parametrize("align, sector", [
+ # Invalid alignment
+ (1024, sanlock.SECTOR[0]),
+ # Invalid sector size
+ (sanlock.ALIGN[0], 8192),
+ # Invalid both alignment and sector size
+ (3145728, 8192),
+])
+def test_write_resource_invalid_align_sector(
+ tmpdir, sanlock_daemon, align, sector):
+ path = str(tmpdir.join("resources"))
+ util.create_file(path, MIN_RES_SIZE)
+ disks = [(path, 0)]
+
+ with pytest.raises(sanlock.SanlockException) as e:
+ sanlock.write_resource(
+ "ls_name", "res_name", disks, align=align,
sector=sector)
+ assert e.value.errno == errno.EINVAL
--
2.20.1