Adam Litke has uploaded a new change for review.
Change subject: tests: Add basic tests for RWLock ......................................................................
tests: Add basic tests for RWLock
Change-Id: I77b9ea1cd6d378738fbf14de119c88bf0ebc94e2 Signed-off-by: Adam Litke alitke@redhat.com --- M tests/miscTests.py 1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/72/42772/1
diff --git a/tests/miscTests.py b/tests/miscTests.py index 976b503..c6d9690 100644 --- a/tests/miscTests.py +++ b/tests/miscTests.py @@ -1268,3 +1268,21 @@
def _run(self): self.result = self._func() + + +class RWLockTests(TestCaseBase): + + def test_multiple_acquire(self): + lock = misc.RWLock() + self.assertTrue(lock.acquire(exclusive=True)) + self.assertTrue(lock.acquire(exclusive=True)) + + def test_demote(self): + lock = misc.RWLock() + self.assertTrue(lock.acquire(exclusive=True)) + self.assertTrue(lock.acquire(exclusive=False)) + + def test_promote(self): + lock = misc.RWLock() + self.assertTrue(lock.acquire(False)) + self.assertRaises(RuntimeError, lock.acquire, True)