diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-09-13 19:25:58 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-09-13 19:25:58 -0700 |
commit | d2e97d34a60ca84c84b42f9c0f732c22be7a0b46 (patch) | |
tree | 82aa77105acdaaa545243ab106e7d6220f1614b6 /pym/portage/tests/locks | |
parent | 063f8a597647da0ba9b3a421fd2b74dffd39a6cc (diff) | |
download | portage-d2e97d34a60ca84c84b42f9c0f732c22be7a0b46.tar.gz portage-d2e97d34a60ca84c84b42f9c0f732c22be7a0b46.tar.bz2 portage-d2e97d34a60ca84c84b42f9c0f732c22be7a0b46.zip |
Add a new AsynchronousLock class that uses the portage.locks module to
acquire a lock asynchronously, using a background thread.
Diffstat (limited to 'pym/portage/tests/locks')
-rw-r--r-- | pym/portage/tests/locks/__init__.py | 2 | ||||
-rw-r--r-- | pym/portage/tests/locks/__test__ | 0 | ||||
-rw-r--r-- | pym/portage/tests/locks/test_asynchronous_lock.py | 29 |
3 files changed, 31 insertions, 0 deletions
diff --git a/pym/portage/tests/locks/__init__.py b/pym/portage/tests/locks/__init__.py new file mode 100644 index 000000000..21a391aee --- /dev/null +++ b/pym/portage/tests/locks/__init__.py @@ -0,0 +1,2 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 diff --git a/pym/portage/tests/locks/__test__ b/pym/portage/tests/locks/__test__ new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/pym/portage/tests/locks/__test__ diff --git a/pym/portage/tests/locks/test_asynchronous_lock.py b/pym/portage/tests/locks/test_asynchronous_lock.py new file mode 100644 index 000000000..ac38462ed --- /dev/null +++ b/pym/portage/tests/locks/test_asynchronous_lock.py @@ -0,0 +1,29 @@ +# Copyright 2010 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import shutil +import tempfile + +from portage import os +from portage.tests import TestCase +from _emerge.AsynchronousLock import AsynchronousLock +from _emerge.PollScheduler import PollScheduler + +class AsynchronousLockTestCase(TestCase): + + def testAsynchronousLock(self): + scheduler = PollScheduler().sched_iface + tempdir = tempfile.mkdtemp() + try: + path = os.path.join(tempdir, 'lock_me') + for force_thread in (True, False): + for force_dummy in (True, False): + async_lock = AsynchronousLock(path=path, + scheduler=scheduler, _force_dummy=force_dummy, + _force_thread=force_thread) + async_lock.start() + async_lock.wait() + async_lock.unlock() + self.assertEqual(async_lock.returncode, os.EX_OK) + finally: + shutil.rmtree(tempdir) |