on xenial help sign in
Fix the run.sh script - pretend to be running with qtmir and emit SIGSTOP at the right time
eec88deGerry Boland
src/main.cpp+7
@@ -25,6 +25,7 @@
25#include <QtQml/QQmlContext>
25#include <QtQml/QQmlContext>
26#include <QLibrary>
26#include <QLibrary>
27#include <QDebug>
27#include <QDebug>
28+#include <csignal>
28#include <libintl.h>
29#include <libintl.h>
29
30
30// local
31// local
@@ -140,6 +141,12 @@ Load the testability driver");
140 view->setSource(source);
141 view->setSource(source);
141 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
142 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
142
143
144+ if (!isMirServer && qEnvironmentVariableIsSet("UNITY_MIR_EMITS_SIGSTOP")) {
145+ // Emit SIGSTOP as expected by upstart, under Mir it's qtmir that will raise it.
146+ // see http://upstart.ubuntu.com/cookbook/#expect-stop
147+ raise(SIGSTOP);
148+ }
149+
143 if (isMirServer || parser.isSet(fullscreenOption)) {
150 if (isMirServer || parser.isSet(fullscreenOption)) {
144 view->showFullScreen();
151 view->showFullScreen();
145 } else {
152 } else {
tests/autopilot/unity8/shell/tests/test_upstart.py+18−3
@@ -25,7 +25,8 @@ import signal
25import subprocess
25import subprocess
26import time
26import time
27
27
28+import fixtures
28−from testtools.matchers._basic import Equals
29+from testtools.matchers import Equals, MismatchError
29from autopilot.matchers import Eventually
30from autopilot.matchers import Eventually
30from autopilot.introspection import get_proxy_object_for_existing_process
31from autopilot.introspection import get_proxy_object_for_existing_process
31
32
@@ -100,8 +101,21 @@ class UpstartIntegrationTests(UnityTestCase):
100 emulator_base=UnityEmulatorBase,))
101 emulator_base=UnityEmulatorBase,))
101
102
102 def test_no_sigstop(self):
103 def test_no_sigstop(self):
104+ self.useFixture(
105+ fixtures.EnvironmentVariable(
103− self.patch_environment("UNITY_MIR_EMITS_SIGSTOP", "")
106+ 'UNITY_MIR_EMITS_SIGSTOP', newvalue=None))
104 self._launch_unity()
107 self._launch_unity()
108+
109+ try:
110+ self.assertThat(
111+ lambda: os.WIFSTOPPED(self._get_status()),
112+ Eventually(Equals(True)))
113+ except MismatchError:
114+ pass
115+ else:
116+ self.process.send_signal(signal.SIGCONT)
117+ self.fail('Unity8 raised SIGSTOP')
118+
105 self._set_proxy()
119 self._set_proxy()
106
120
107 logger.debug("Unity started, waiting for it to be ready.")
121 logger.debug("Unity started, waiting for it to be ready.")
@@ -109,7 +123,8 @@ class UpstartIntegrationTests(UnityTestCase):
109 logger.debug("Unity loaded and ready.")
123 logger.debug("Unity loaded and ready.")
110
124
111 def test_expect_sigstop(self):
125 def test_expect_sigstop(self):
126+ self.useFixture(
112− self.patch_environment("UNITY_MIR_EMITS_SIGSTOP", "1")
127+ fixtures.EnvironmentVariable('UNITY_MIR_EMITS_SIGSTOP', '1'))
113 self._launch_unity()
128 self._launch_unity()
114 self.assertThat(
129 self.assertThat(
115 lambda: os.WIFSTOPPED(self._get_status()),
130 lambda: os.WIFSTOPPED(self._get_status()),