on xenial help sign in
Fix the run.sh script - pretend to be running with qtmir and emit SIGSTOP at the right time

Approved by: Michał Sawicz, Albert Astals Cid

commiteec88de699604903626b6704e8d15c395702af27 authorGerry Boland <gerry.boland@canonical.com> dateThu 31 Jul 2014, 16:50 (12 years ago) parent6dbd96565c0272
2 files changed+25−3
src/main.cpp+7 tests/autopilot/unity8/shell/tests/test_upstart.py+18−3
src/main.cpp+7
@@ -25,6 +25,7 @@
2525#include <QtQml/QQmlContext>
2626#include <QLibrary>
2727#include <QDebug>
28+#include <csignal>
2829#include <libintl.h>
2930
3031// local
@@ -140,6 +141,12 @@ Load the testability driver");
140141 view->setSource(source);
141142 QObject::connect(view->engine(), SIGNAL(quit()), application, SLOT(quit()));
142143
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+
143150 if (isMirServer || parser.isSet(fullscreenOption)) {
144151 view->showFullScreen();
145152 } else {
tests/autopilot/unity8/shell/tests/test_upstart.py+18−3
@@ -25,7 +25,8 @@ import signal
2525import subprocess
2626import time
2727
28−from testtools.matchers._basic import Equals
28+import fixtures
29+from testtools.matchers import Equals, MismatchError
2930from autopilot.matchers import Eventually
3031from autopilot.introspection import get_proxy_object_for_existing_process
3132
@@ -100,8 +101,21 @@ class UpstartIntegrationTests(UnityTestCase):
100101 emulator_base=UnityEmulatorBase,))
101102
102103 def test_no_sigstop(self):
103− self.patch_environment("UNITY_MIR_EMITS_SIGSTOP", "")
104+ self.useFixture(
105+ fixtures.EnvironmentVariable(
106+ 'UNITY_MIR_EMITS_SIGSTOP', newvalue=None))
104107 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+
105119 self._set_proxy()
106120
107121 logger.debug("Unity started, waiting for it to be ready.")
@@ -109,7 +123,8 @@ class UpstartIntegrationTests(UnityTestCase):
109123 logger.debug("Unity loaded and ready.")
110124
111125 def test_expect_sigstop(self):
112− self.patch_environment("UNITY_MIR_EMITS_SIGSTOP", "1")
126+ self.useFixture(
127+ fixtures.EnvironmentVariable('UNITY_MIR_EMITS_SIGSTOP', '1'))
113128 self._launch_unity()
114129 self.assertThat(
115130 lambda: os.WIFSTOPPED(self._get_status()),