From e58829dd5e2272b9c3878cd0ec92680fae075b40 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 4 Oct 2012 21:08:01 -0700 Subject: [PATCH] test_ipc_daemon: implement internal SleepProcess Emulate the sleep command, in order to ensure a consistent return code when it is killed by SIGTERM (see bug #437180). --- pym/portage/tests/ebuild/test_ipc_daemon.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/pym/portage/tests/ebuild/test_ipc_daemon.py b/pym/portage/tests/ebuild/test_ipc_daemon.py index fc14671ba..77277fe8e 100644 --- a/pym/portage/tests/ebuild/test_ipc_daemon.py +++ b/pym/portage/tests/ebuild/test_ipc_daemon.py @@ -13,11 +13,21 @@ from portage.const import BASH_BINARY from portage.locks import hardlock_cleanup from portage.package.ebuild._ipc.ExitCommand import ExitCommand from portage.util import ensure_dirs +from portage.util._async.ForkProcess import ForkProcess from _emerge.SpawnProcess import SpawnProcess from _emerge.EbuildBuildDir import EbuildBuildDir from _emerge.EbuildIpcDaemon import EbuildIpcDaemon from _emerge.TaskScheduler import TaskScheduler +class SleepProcess(ForkProcess): + """ + Emulate the sleep command, in order to ensure a consistent + return code when it is killed by SIGTERM (see bug #437180). + """ + __slots__ = ('seconds',) + def _run(self): + time.sleep(self.seconds) + class IpcDaemonTestCase(TestCase): _SCHEDULE_TIMEOUT = 40000 # 40 seconds @@ -104,9 +114,8 @@ class IpcDaemonTestCase(TestCase): input_fifo=input_fifo, output_fifo=output_fifo, scheduler=task_scheduler.sched_iface) - proc = SpawnProcess( - args=[BASH_BINARY, "-c", 'exec sleep %d' % sleep_time_s], - env=env, scheduler=task_scheduler.sched_iface) + proc = SleepProcess(seconds=sleep_time_s, + scheduler=task_scheduler.sched_iface) self.received_command = False def exit_command_callback(): -- 2.26.2