summaryrefslogtreecommitdiffstats
path: root/pym
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-17 14:02:12 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-25 20:05:30 -0700
commit6c6d648ff08be7c7874d1a39ee1f4412081f9f16 (patch)
treee18add57b43f40c696d0c2f355c60a5a38f76d55 /pym
parentc09572b6c0ab707105d1acd4ae873d98b6b93c7a (diff)
downloadportage-6c6d648ff08be7c7874d1a39ee1f4412081f9f16.tar.gz
portage-6c6d648ff08be7c7874d1a39ee1f4412081f9f16.tar.bz2
portage-6c6d648ff08be7c7874d1a39ee1f4412081f9f16.zip
test_asynchronous_lock: test wait and cancel
Diffstat (limited to 'pym')
-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)