summaryrefslogtreecommitdiffstats
path: root/pym/portage/tests/locks
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2011-05-17 13:56:15 -0700
committerZac Medico <zmedico@gentoo.org>2011-05-17 13:56:15 -0700
commit0ea4406a64f8af1143e1a819b61f95e8b1777f99 (patch)
tree0d7b4950759f5670c0d33896f23ccb8f4e67cbda /pym/portage/tests/locks
parent82da4172fbd61106e3c960cb67aae7b02e27c13a (diff)
downloadportage-0ea4406a64f8af1143e1a819b61f95e8b1777f99.tar.gz
portage-0ea4406a64f8af1143e1a819b61f95e8b1777f99.tar.bz2
portage-0ea4406a64f8af1143e1a819b61f95e8b1777f99.zip
test_asynchronous_lock: test waiting
Diffstat (limited to 'pym/portage/tests/locks')
-rw-r--r--pym/portage/tests/locks/test_asynchronous_lock.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py
index 7e9fdfec9..e72adf684 100644
--- a/pym/portage/tests/locks/test_asynchronous_lock.py
+++ b/pym/portage/tests/locks/test_asynchronous_lock.py
@@ -37,3 +37,28 @@ class AsynchronousLockTestCase(TestCase):
finally:
shutil.rmtree(tempdir)
+
+ def testAsynchronousLockWait(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 requires _force_async=True since the portage.locks
+ # module is not designed to work as intended here if the
+ # same process tries to lock the same file more than
+ # one time concurrently.
+ 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)
+
+ lock1.unlock()
+ self.assertEqual(lock2.wait(), os.EX_OK)
+ lock2.unlock()
+ finally:
+ shutil.rmtree(tempdir)