aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2010-09-03 14:23:58 -0700
committerZac Medico <zmedico@gentoo.org>2010-09-03 14:23:58 -0700
commit35f639f21f285897903d9805569af26c3333300a (patch)
treec4a33f6b3e6d0718d884099e18031a6ca50d3843 /pym/portage/tests/ebuild/test_ipc_daemon.py
parentBug #335777 - Add a 40 second timeout in ebuild-ipc.py, so that if an (diff)
downloadportage-35f639f21f285897903d9805569af26c3333300a.tar.gz
portage-35f639f21f285897903d9805569af26c3333300a.tar.bz2
portage-35f639f21f285897903d9805569af26c3333300a.zip
Add support for a timeout argument to QueueScheduler.run() and
use it in IpcDaemonTestCase to implement a 40 second timeout in test cases.
Diffstat (limited to 'pym/portage/tests/ebuild/test_ipc_daemon.py')
-rw-r--r--pym/portage/tests/ebuild/test_ipc_daemon.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/pym/portage/tests/ebuild/test_ipc_daemon.py b/pym/portage/tests/ebuild/test_ipc_daemon.py
index 0a9a9a929..dee61a2d2 100644
--- a/pym/portage/tests/ebuild/test_ipc_daemon.py
+++ b/pym/portage/tests/ebuild/test_ipc_daemon.py
@@ -3,6 +3,8 @@
import shutil
import tempfile
+import time
+import portage
from portage import os
from portage import _python_interpreter
from portage.tests import TestCase
@@ -16,6 +18,8 @@ from _emerge.TaskScheduler import TaskScheduler
class IpcDaemonTestCase(TestCase):
+ _SCHEDULE_TIMEOUT = 40000 # 40 seconds
+
def testIpcDaemon(self):
tmpdir = tempfile.mkdtemp()
try:
@@ -49,13 +53,23 @@ class IpcDaemonTestCase(TestCase):
args=[BASH_BINARY, "-c",
'"$PORTAGE_BIN_PATH"/ebuild-ipc exit %d' % exitcode],
env=env, scheduler=task_scheduler.sched_iface)
+
+ self.received_command = False
def exit_command_callback():
+ self.received_command = True
proc.cancel()
daemon.cancel()
+
exit_command.reply_hook = exit_command_callback
task_scheduler.add(daemon)
task_scheduler.add(proc)
- task_scheduler.run()
+ start_time = time.time()
+ task_scheduler.run(timeout=self._SCHEDULE_TIMEOUT)
+ task_scheduler.clear()
+
+ self.assertEqual(self.received_command, True,
+ "command not received after %d seconds" % \
+ (time.time() - start_time,))
self.assertEqual(exit_command.exitcode, exitcode)
finally:
shutil.rmtree(tmpdir)