@@ -37,44 +37,44 @@ logger = logging.getLogger(__name__)
39class UpstartIntegrationTests(UnityTestCase):
39class UpstartIntegrationTests(UnityTestCase):
41 scenarios = _get_device_emulation_scenarios()
41 scenarios = _get_device_emulation_scenarios()
43 def _get_status(self):
43 def _get_status(self):
44 pid, status = os.waitpid(self.process.pid, os.WUNTRACED | os.WCONTINUED | os.WNOHANG)
44 pid, status = os.waitpid(self.process.pid, os.WUNTRACED | os.WCONTINUED | os.WNOHANG)
45 logger.debug("Got status: {0}; stopped: {1}; continued: {2}"\
45 logger.debug("Got status: {0}; stopped: {1}; continued: {2}"\
46 .format(status, os.WIFSTOPPED(status), os.WIFCONTINUED(status)))
46 .format(status, os.WIFSTOPPED(status), os.WIFCONTINUED(status)))
47 return status
47 return status
49 def _launch_unity(self):
49 def _launch_unity(self):
50 self.patch_environment("QT_LOAD_TESTABILITY", "1")
50 self.patch_environment("QT_LOAD_TESTABILITY", "1")
51 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
51 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
52 self.addCleanup(lambda: self.process.kill())
52 self.addCleanup(lambda: self.process.kill())
54 def _set_proxy(self):
54 def _set_proxy(self):
55 super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process(
55 super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process(
56 pid=self.process.pid,
56 pid=self.process.pid,
57 emulator_base=UnityEmulatorBase,
57 emulator_base=UnityEmulatorBase,
60 def test_no_sigstop(self):
60 def test_no_sigstop(self):
61 self.patch_environment("UPSTART_JOB", "foo")
61 self.patch_environment("UPSTART_JOB", "foo")
62 self._launch_unity()
62 self._launch_unity()
63 self._set_proxy()
63 self._set_proxy()
65 logger.debug("Unity started, waiting for it to be ready.")
65 logger.debug("Unity started, waiting for it to be ready.")
66 self.assertUnityReady()
66 self.assertUnityReady()
67 logger.debug("Unity loaded and ready.")
67 logger.debug("Unity loaded and ready.")
69 def test_expect_sigstop(self):
69 def test_expect_sigstop(self):
70 self.patch_environment("UPSTART_JOB", "unity8")
70 self.patch_environment("UPSTART_JOB", "unity8")
71 self._launch_unity()
71 self._launch_unity()
72 self.assertThat(lambda: os.WIFSTOPPED(self._get_status()), Eventually(Equals(True)), "Unity8 should raise SIGSTOP when ready")
72 self.assertThat(lambda: os.WIFSTOPPED(self._get_status()), Eventually(Equals(True)), "Unity8 should raise SIGSTOP when ready")
74 self.process.send_signal(signal.SIGCONT)
74 self.process.send_signal(signal.SIGCONT)
75 self.assertThat(lambda: os.WIFCONTINUED(self._get_status()), Eventually(Equals(True)), "Unity8 should have resumed")
75 self.assertThat(lambda: os.WIFCONTINUED(self._get_status()), Eventually(Equals(True)), "Unity8 should have resumed")
77 logger.debug("Unity started, waiting for it to be ready.")
77 logger.debug("Unity started, waiting for it to be ready.")
78 self._set_proxy()
78 self._set_proxy()
79 self.assertUnityReady()
79 self.assertUnityReady()
80− logger.debug("Unity loaded and ready.")
80+ logger.debug("Unity loaded and ready.")