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,):
46 class UpstartIntegrationTests(UnityTestCase):
48 scenarios = _get_device_emulation_scenarios()
50 def _get_status(self):
51 pid, status = os.waitpid(
52 self.process.pid, os.WUNTRACED | os.WCONTINUED | os.WNOHANG)
54 "Got status: {0}; stopped: {1}; continued: {2}".format(
55 status, os.WIFSTOPPED(status), os.WIFCONTINUED(status)))
58 def _launch_unity(self):
59 self.patch_environment(
"QT_LOAD_TESTABILITY",
"1")
60 self.process = subprocess.Popen(
61 [get_binary_path()] + self.unity_geometry_args)
64 self.process.terminate()
81 self.addCleanup(ensure_stopped)
84 super(UpstartIntegrationTests, self)._set_proxy(
85 get_proxy_object_for_existing_process(
87 emulator_base=UnityEmulatorBase,))
89 def test_no_sigstop(self):
90 self.patch_environment(
"UNITY_MIR_EMITS_SIGSTOP",
"")
94 logger.debug(
"Unity started, waiting for it to be ready.")
95 self.assertUnityReady()
96 logger.debug(
"Unity loaded and ready.")
98 def test_expect_sigstop(self):
99 self.patch_environment(
"UNITY_MIR_EMITS_SIGSTOP",
"1")
102 lambda: os.WIFSTOPPED(self._get_status()),
103 Eventually(Equals(
True)),
"Unity8 should raise SIGSTOP when ready")
105 self.process.send_signal(signal.SIGCONT)
107 lambda: os.WIFCONTINUED(self._get_status()),
108 Eventually(Equals(
True)),
"Unity8 should have resumed")
110 logger.debug(
"Unity started, waiting for it to be ready.")
112 self.assertUnityReady()
113 logger.debug(
"Unity loaded and ready.")