20 """Tests for upstart integration."""
27 from testtools.matchers._basic
import Equals
28 from autopilot.matchers
import Eventually
29 from autopilot.introspection
import get_proxy_object_for_existing_process
31 from unity8
import get_binary_path
37 logger = logging.getLogger(__name__)
42 if sys.version_info < (3,):
45 class UpstartIntegrationTests(UnityTestCase):
47 scenarios = _get_device_emulation_scenarios()
49 def _get_status(self):
50 pid, status = os.waitpid(self.process.pid, os.WUNTRACED | os.WCONTINUED | os.WNOHANG)
51 logger.debug(
"Got status: {0}; stopped: {1}; continued: {2}"\
52 .format(status, os.WIFSTOPPED(status), os.WIFCONTINUED(status)))
55 def _launch_unity(self):
56 self.patch_environment(
"QT_LOAD_TESTABILITY",
"1")
57 self.process = subprocess.Popen([get_binary_path()] + self.unity_geometry_args)
59 self.process.terminate()
76 self.addCleanup(ensure_stopped)
79 super(UpstartIntegrationTests, self)._set_proxy(get_proxy_object_for_existing_process(
81 emulator_base=UnityEmulatorBase,
84 def test_no_sigstop(self):
85 self.patch_environment(
"UNITY_MIR_EMITS_SIGSTOP",
"")
89 logger.debug(
"Unity started, waiting for it to be ready.")
90 self.assertUnityReady()
91 logger.debug(
"Unity loaded and ready.")
93 def test_expect_sigstop(self):
94 self.patch_environment(
"UNITY_MIR_EMITS_SIGSTOP",
"1")
96 self.assertThat(
lambda: os.WIFSTOPPED(self._get_status()), Eventually(Equals(
True)),
"Unity8 should raise SIGSTOP when ready")
98 self.process.send_signal(signal.SIGCONT)
99 self.assertThat(
lambda: os.WIFCONTINUED(self._get_status()), Eventually(Equals(
True)),
"Unity8 should have resumed")
101 logger.debug(
"Unity started, waiting for it to be ready.")
103 self.assertUnityReady()
104 logger.debug(
"Unity loaded and ready.")