On Thu, Apr 25, 2019 at 2:57 PM Vojtech Juranek <vjuranek@redhat.com> wrote:
---
 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 == []
+
+
+@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),

I don't think the last value adds anything to the test.
Same for the other test.

+])
+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
+
+
+@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

It would be nice squash this test with the patch adding the validation,
and update the patch to use sanlock.ALIGN and sanlock.SECTOR tuples
in the patch adding the tuples.

This way we will have only 2 patches for 3.7.1-3.

 
--
2.20.1
_______________________________________________
sanlock-devel mailing list -- sanlock-devel@lists.fedorahosted.org
To unsubscribe send an email to sanlock-devel-leave@lists.fedorahosted.org
Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: https://lists.fedorahosted.org/archives/list/sanlock-devel@lists.fedorahosted.org