[prev in list] [next in list] [prev in thread] [next in thread] 

List:       sanlock-devel
Subject:    [PATCH v3 4/4] tests: add tests for invalid align and sector values
From:       Vojtech Juranek <vjuranek () redhat ! com>
Date:       2019-04-30 14:34:23
Message-ID: 20190430143423.18929-5-vjuranek () redhat ! com
[Download RAW message or body]

---
 tests/python_test.py | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tests/python_test.py b/tests/python_test.py
index 1bb714a..f822c3e 100644
--- a/tests/python_test.py
+++ b/tests/python_test.py
@@ -234,3 +234,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),
+])
+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
-- 
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

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic