summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/locks
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-17 14:02:12 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-17 14:02:12 -0700
commit1ffdb3667e18b50e52bbd5c2fa64f5e13a892eb5 (patch)
tree8f8de41fb8e3b367ac0267ac175ef7b371926743 /pym/portage/tests/locks
parent0ea4406a64f8af1143e1a819b61f95e8b1777f99 (diff)
downloadportage-1ffdb3667e18b50e52bbd5c2fa64f5e13a892eb5.tar.gz
portage-1ffdb3667e18b50e52bbd5c2fa64f5e13a892eb5.tar.bz2
portage-1ffdb3667e18b50e52bbd5c2fa64f5e13a892eb5.zip
test_asynchronous_lock: test wait and cancel
Diffstat (limited to 'pym/portage/tests/locks')
-rw-r--r--pym/portage/tests/locks/test_asynchronous_lock.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py
index e72adf684..dc4619dfd 100644
--- a/pym/portage/tests/locks/test_asynchronous_lock.py
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py
@@ -62,3 +62,25 @@ class AsynchronousLockTestCase(TestCase):
lock2.unlock()
finally:
shutil.rmtree(tempdir)
+
+ def testAsynchronousLockWaitCancel(self):
+ scheduler = PollScheduler().sched_iface
+ tempdir = tempfile.mkdtemp()
+ try:
+ path = os.path.join(tempdir, 'lock_me')
+ lock1 = AsynchronousLock(path=path, scheduler=scheduler)
+ lock1.start()
+ self.assertEqual(lock1.wait(), os.EX_OK)
+ lock2 = AsynchronousLock(path=path, scheduler=scheduler,
+ _force_async=True, _force_process=True)
+ lock2.start()
+ # lock2 should we waiting for lock1 to release
+ self.assertEqual(lock2.returncode, None)
+
+ # Cancel lock2 and then check wait() and returncode results.
+ lock2.cancel()
+ self.assertEqual(lock2.wait() == os.EX_OK, False)
+ self.assertEqual(lock2.returncode == os.EX_OK, False)
+ lock1.unlock()
+ finally:
+ shutil.rmtree(tempdir)