Status: | Merged | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Approved by: | Gerry Boland | ||||||||||||
Approved revision: | 274 | ||||||||||||
Merged at revision: | 276 | ||||||||||||
Proposed branch: | lp:~ted/qtmir/ual-pause | ||||||||||||
Merge into: | lp:qtmir | ||||||||||||
Diff against target: |
1079 lines (+75/-689) 16 files modified
src/modules/Unity/Application/Application.pro (+0/-2) src/modules/Unity/Application/application.cpp (+2/-2) src/modules/Unity/Application/applicationcontroller.h (+3/-0) src/modules/Unity/Application/processcontroller.cpp (+0/-231) src/modules/Unity/Application/processcontroller.h (+0/-62) src/modules/Unity/Application/taskcontroller.cpp (+12/-69) src/modules/Unity/Application/taskcontroller.h (+3/-7) src/modules/Unity/Application/upstart/applicationcontroller.cpp (+19/-0) src/modules/Unity/Application/upstart/applicationcontroller.h (+3/-0) tests/modules/ApplicationManager/application_manager_test.cpp (+0/-18) tests/modules/TaskController/taskcontroller_test.cpp (+4/-198) tests/modules/common/common.pri (+1/-3) tests/modules/common/mock_application_controller.h (+26/-2) tests/modules/common/mock_oom_controller.h (+0/-34) tests/modules/common/mock_process_controller.h (+0/-45) tests/modules/common/qtmir_test.h (+2/-16) |
||||||||||||
To merge this branch: | bzr merge lp:~ted/qtmir/ual-pause | ||||||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+236033@code.launchpad.net |
Commit message
Use UAL pause/resume functions for stopping/continuing all tasks in the cgroup
Description of the change
Switching from internal functions for doing all the signaling and OOM adjusting to using the ones in UAL.
* Are there any related MPs required for this MP to build/function as expected? Please list.
https:/
* Did you perform an exploratory manual test run of your code change and any related functionality?
Yup.
* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Naw, just removing a one-line dep. I think I'm good for that change.
PS Jenkins bot (ps-jenkins) wrote : | # |
Ted Gould (ted) wrote : | # |
Okay, to get all the Oxide renderers you'll need this too:
https:/
Gerry Boland (gerboland) wrote : | # |
Hey Ted, thanks for this! Lots of red, yay! Couple of things I noticed before doing a full review:
Please add checklist: https:/
with the list of required MRs
As you're removing ProcessController, I suspect you can remove qtmir's dependence on process-cpp package.
+++ src/modules/
-/*
- * Copyright (C) 2013-2014 Canonical, Ltd.
+/* Copyright (C) 2013-2014 Canonical, Ltd.
Unnecessary change
+++ src/modules/
+bool ApplicationCont
+ qDebug() << "ApplicationCon
failed to _pause_ appId
+ qDebug() << "ApplicationCon
failed to _resume_
+++ tests/modules/
+ (void) appId;
Us Qt people tend to use a macro for this: Q_UNUSED(appId);
And couple of higher-level questions about UAL's behaviour (mostly confirmations for me):
1. UAL changes the OOM-killer score when we pause/resume apps, yes?
2. UAL gives app a unlikely-
Something that worries me about this change is that apps not managed by upstart will no longer have correct OOM-killer weights. Are trust helpers managed by upstart these days? Does the OSK get a good OOM-killer value? I need to test this carefully.
Ted Gould (ted) wrote : | # |
On Mon, 2014-10-06 at 12:17 +0000, Gerry Boland wrote:
> As you're removing ProcessController, I suspect you can remove qtmir's
> dependence on process-cpp package.
Not my goal, but it seems so. There were a few pieces left to kill. r262
> +++ src/modules/
> -/*
> - * Copyright (C) 2013-2014 Canonical, Ltd.
> +/* Copyright (C) 2013-2014 Canonical, Ltd.
> Unnecessary change
Fixed r263.
> +++ src/modules/
> +bool ApplicationCont
> + qDebug() << "ApplicationCon
> failed to _pause_ appId
>
> + qDebug() << "ApplicationCon
> failed to _resume_
Fixed r264.
> +++ tests/modules/
> + (void) appId;
> Us Qt people tend to use a macro for this: Q_UNUSED(appId);
Fixed r265.
> And couple of higher-level questions about UAL's behaviour (mostly
> confirmations for me):
> 1. UAL changes the OOM-killer score when we pause/resume apps, yes?
Correct.
> 2. UAL gives app a unlikely-
> app?
Correct.
> Something that worries me about this change is that apps not managed
> by upstart will no longer have correct OOM-killer weights. Are trust
> helpers managed by upstart these days? Does the OSK get a good
> OOM-killer value? I need to test this carefully.
All processes are managed by Upstart, so they can all have an OOM score
set in their Upstart job. For instance that's how UAL sets the initial
value, it makes Upstart do it on job creation. I don't know that the OSK
job has that configured properly though.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:265
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:266
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:267
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:268
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:269
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:270
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
CI still not happy. Appears we still use process-cpp in a test. You'd better restore it, and we'll change that later.
Gerry Boland (gerboland) wrote : | # |
One important piece of info for you:
https:/
this will land first, and we need the ability to give Dash a custom OOM weight. You need to adjust this to suit unfortunately.
Gerry Boland (gerboland) wrote : | # |
- pid_t pid = m_appController
- if (pid == 0) {
- pid = app->pid();
- }
-m_processContr
This code is needed, as unity-dash is not managed by UAL, but is spawned by upstart, and we need to suspend/resume it
Ted Gould (ted) wrote : | # |
As discussed on IRC here's the change to the dash Upstart job to put the OOM score at 200.
https:/
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:273
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:274
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
Working well. Only issue is that dash is not being suspended/resumed. This bit of code you removed was doing it:
- pid_t pid = m_appController
- if (pid == 0) {
- pid = app->pid();
- }
i.e. if UAL didn't know the PID for the process, then we'd use the PID that AppMan saves. Then you could call signal(SIGSTOP) manually. That'll do to fix it.
Thanks
-G
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:275
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
Hey Ted,
my apologies but I've been told that your initial design to not suspend/resume the dash is now correct. Can you please revert revision 275. Then am happy to approve
-Gerry
Ted Gould (ted) wrote : | # |
Pushed without r275
Gerry Boland (gerboland) wrote : | # |
Works great, thanks Ted
* Did you perform an exploratory manual test run of the code change and any related functionality?
Yep
* Did CI run pass? If not, please explain why.
Y
Preview Diff
1 | === modified file 'src/modules/Unity/Application/Application.pro' |
2 | --- src/modules/Unity/Application/Application.pro 2014-09-17 17:29:42 +0000 |
3 | +++ src/modules/Unity/Application/Application.pro 2014-10-24 15:59:35 +0000 |
4 | @@ -36,7 +36,6 @@ |
5 | ubuntukeyboardinfo.cpp \ |
6 | mirsurfaceitem.cpp \ |
7 | mirbuffersgtexture.cpp \ |
8 | - processcontroller.cpp \ |
9 | proc_info.cpp \ |
10 | session.cpp \ |
11 | sessionmanager.cpp \ |
12 | @@ -60,7 +59,6 @@ |
13 | mirsurfaceitemmodel.h \ |
14 | mirbuffersgtexture.h \ |
15 | objectlistmodel.h \ |
16 | - processcontroller.h \ |
17 | proc_info.h \ |
18 | session.h \ |
19 | session_interface.h \ |
20 | |
21 | === modified file 'src/modules/Unity/Application/application.cpp' |
22 | --- src/modules/Unity/Application/application.cpp 2014-10-13 10:07:10 +0000 |
23 | +++ src/modules/Unity/Application/application.cpp 2014-10-24 15:59:35 +0000 |
24 | @@ -325,13 +325,13 @@ |
25 | void Application::onSessionSuspended() |
26 | { |
27 | qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId(); |
28 | - m_taskController->suspend(this); |
29 | + m_taskController->suspend(longAppId()); |
30 | } |
31 | |
32 | void Application::onSessionResumed() |
33 | { |
34 | qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId(); |
35 | - m_taskController->resume(this); |
36 | + m_taskController->resume(longAppId()); |
37 | } |
38 | |
39 | void Application::respawn() |
40 | |
41 | === modified file 'src/modules/Unity/Application/applicationcontroller.h' |
42 | --- src/modules/Unity/Application/applicationcontroller.h 2014-07-02 22:56:08 +0000 |
43 | +++ src/modules/Unity/Application/applicationcontroller.h 2014-10-24 15:59:35 +0000 |
44 | @@ -48,6 +48,9 @@ |
45 | virtual bool stopApplicationWithAppId(const QString &appId) = 0; |
46 | virtual bool startApplicationWithAppIdAndArgs(const QString &appId, const QStringList &arguments) = 0; |
47 | |
48 | + virtual bool pauseApplicationWithAppId(const QString &appId) = 0; |
49 | + virtual bool resumeApplicationWithAppId(const QString &appId) = 0; |
50 | + |
51 | virtual QFileInfo findDesktopFileForAppId(const QString &appId) const = 0; |
52 | |
53 | Q_SIGNALS: |
54 | |
55 | === removed file 'src/modules/Unity/Application/processcontroller.cpp' |
56 | --- src/modules/Unity/Application/processcontroller.cpp 2014-10-10 08:38:30 +0000 |
57 | +++ src/modules/Unity/Application/processcontroller.cpp 1970-01-01 00:00:00 +0000 |
58 | @@ -1,231 +0,0 @@ |
59 | -/* |
60 | - * Copyright (C) 2014 Canonical, Ltd. |
61 | - * |
62 | - * This program is free software: you can redistribute it and/or modify it under |
63 | - * the terms of the GNU Lesser General Public License version 3, as published by |
64 | - * the Free Software Foundation. |
65 | - * |
66 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
67 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
68 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
69 | - * Lesser General Public License for more details. |
70 | - * |
71 | - * You should have received a copy of the GNU Lesser General Public License |
72 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
73 | - * |
74 | - */ |
75 | - |
76 | -#include "processcontroller.h" |
77 | - |
78 | -#include "logging.h" |
79 | - |
80 | -// Process C++ |
81 | -#include <core/posix/process.h> |
82 | -#include <core/posix/this_process.h> |
83 | -#include <core/posix/linux/proc/process/oom_adj.h> |
84 | -#include <core/posix/linux/proc/process/oom_score_adj.h> |
85 | - |
86 | -// std |
87 | -#include <signal.h> |
88 | -#include <unistd.h> |
89 | - |
90 | -/* |
91 | - * ProcessController |
92 | - * This class manages individual processes during their lifetime. It allows one to pause |
93 | - * and resume processes. |
94 | - * |
95 | - * It also has methods to set a score on processes which is used by the Out of Memory (OOM) |
96 | - * process killer to decide what process gets killed in a low memory situation. |
97 | - */ |
98 | - |
99 | -namespace plpp = core::posix::linux::proc::process; |
100 | - |
101 | -namespace qtmir |
102 | -{ |
103 | - |
104 | -ProcessController::OomController::OomController() |
105 | -{ |
106 | -} |
107 | - |
108 | -/*! |
109 | - * \brief ProcessController::OomController::ensureProcessLikelyToBeKilled |
110 | - * \param pid |
111 | - * Set the process OOM-killer score so that the process is _more_ likely to be killed |
112 | - * in a low memory situation |
113 | - */ |
114 | - |
115 | -/* |
116 | - * Useful information about these OOM-weighting methods |
117 | - * |
118 | - * the "Process C++" library wraps some APIs exported by the kernel in the the /proc filesystem. |
119 | - * The OOM score is one of these, but the APIs for it changed from Linux 2.6.36 onward. |
120 | - * |
121 | - * === Up to Linux 2.6.36 === |
122 | - * /proc/[pid]/oom_adj (wrapped by plpp::OomAdj) was used up to 2.6.36 (is deprecated now) |
123 | - * Valid values are in the range -16 to +15, plus the special value -17, which disables |
124 | - * OOM-killing altogether for this process. A positive score increases the likelihood |
125 | - * of this process being killed by the OOM-killer; a negative score decreases the likelihood. |
126 | - * |
127 | - * The default value for this file is 0; a new process inherits its parent's oom_adj setting. |
128 | - * |
129 | - * === Linux 2.6.36 and later === |
130 | - * /proc/[pid]/oom_score_adj (wrapped by plpp::OomScoreAdj) is the recommended API. Valid |
131 | - * values are in the range -1000 (never kill) to 1000 (always kill). |
132 | - * |
133 | - * For backward compatibility with previous kernels, /proc/[pid]/oom_adj can still be used to |
134 | - * tune the badness score. Its value is scaled linearly with oom_score_adj. So writing to |
135 | - * /proc/[pid]/oom_score_adj or /proc/[pid]/oom_adj will change the other with its scaled value. |
136 | - * |
137 | - * === How OOM score changing is implemented === |
138 | - * To support all available kernels, we thus perform the following for any OOM score change: |
139 | - * 1. Attempt to use the newer kernel API (plpp::OomScoreAdj). Fetch the min & max possible |
140 | - * values and calculate a desired score for the process. |
141 | - * 2. If that fails, fall back to the older kernel API (plpp::OomSAdj), again fetching min |
142 | - * & max possible values and calculating a desired score for the process. |
143 | - */ |
144 | -void ProcessController::OomController::ensureProcessLikelyToBeKilled(pid_t pid) |
145 | -{ |
146 | - // We avoid boundary values for oom_score_adj. For that, we |
147 | - // set it to 80% of the total available range. |
148 | - static const float defaultPercentage = 0.8; |
149 | - |
150 | - core::posix::Process process(pid); |
151 | - |
152 | - try { |
153 | - plpp::OomScoreAdj shellScore; |
154 | - core::posix::this_process::instance() >> shellScore; |
155 | - |
156 | - plpp::OomScoreAdj processScore |
157 | - { |
158 | - static_cast<int>((plpp::OomScoreAdj::max_value() - shellScore.value) * defaultPercentage) + shellScore.value |
159 | - }; |
160 | - |
161 | - process << processScore; |
162 | - } catch(...) { |
163 | - // Accessing OomScoreAdj resulted in an exception being thrown. |
164 | - // Trying with the deprecated OomAdj now as a last resort. |
165 | - try |
166 | - { |
167 | - process << plpp::OomAdj{plpp::OomAdj::max_value()}; |
168 | - } catch(...) |
169 | - { |
170 | - qDebug() << "ensureProcessIsLikelyToBeKilled failed for pid=" << pid; |
171 | - } |
172 | - } |
173 | -} |
174 | - |
175 | -/*! |
176 | - * \brief ProcessController::OomController::ensureProcessLessLikelyToBeKilled |
177 | - * \param pid |
178 | - * Set the process OOM-killer score so that, in a low memory situation, the process |
179 | - * is _more_ likely to be killed than the foreground application, but less likely |
180 | - * than the background applications |
181 | - */ |
182 | -void ProcessController::OomController::ensureProcessLessLikelyToBeKilled(pid_t pid) |
183 | -{ |
184 | - // Set it to 50% of the total available range. |
185 | - static const float defaultPercentage = 0.5; |
186 | - |
187 | - core::posix::Process process(pid); |
188 | - |
189 | - try { |
190 | - plpp::OomScoreAdj shellScore; |
191 | - core::posix::this_process::instance() >> shellScore; |
192 | - |
193 | - plpp::OomScoreAdj processScore |
194 | - { |
195 | - static_cast<int>((plpp::OomScoreAdj::max_value() - shellScore.value) * defaultPercentage) + shellScore.value |
196 | - }; |
197 | - |
198 | - process << processScore; |
199 | - } catch(...) { |
200 | - // Accessing OomScoreAdj resulted in an exception being thrown. |
201 | - // Trying with the deprecated OomAdj now as a last resort. |
202 | - try |
203 | - { |
204 | - process << plpp::OomAdj{plpp::OomAdj::max_value()}; |
205 | - } catch(...) |
206 | - { |
207 | - qDebug() << "ensureProcessIsLessLikelyToBeKilled failed for pid=" << pid; |
208 | - } |
209 | - } |
210 | -} |
211 | - |
212 | -/*! |
213 | - * \brief ProcessController::OomController::ensureProcessUnlikelyToBeKilled |
214 | - * \param pid |
215 | - * Set the process OOM-killer weighting so that the process is _less_ likely to be killed |
216 | - * in a low memory situation |
217 | - */ |
218 | -void ProcessController::OomController::ensureProcessUnlikelyToBeKilled(pid_t pid) |
219 | -{ |
220 | - // By system default, we set the oom_score_adj of Unity8 to -10 (via lightdm). |
221 | - // As we want to avoid that any app's oom_score_adj is <= Unity8's oom_score_adj, |
222 | - // (i.e. Unity8 would be killed before that app is) we choose a default increase of +1. |
223 | - static const int default_increase = 1; |
224 | - |
225 | - core::posix::Process process(pid); |
226 | - |
227 | - try { |
228 | - plpp::OomScoreAdj shellScore; |
229 | - core::posix::this_process::instance() >> shellScore; |
230 | - |
231 | - plpp::OomScoreAdj processScore |
232 | - { |
233 | - shellScore.value + default_increase |
234 | - }; |
235 | - |
236 | - process << processScore; |
237 | - } catch(...) { |
238 | - // Accessing OomScoreAdj resulted in an exception being thrown. |
239 | - // Trying with the deprecated OomAdj now as a last resort. |
240 | - // By system default, we set the oom_score_adj of Unity8 to -10 (via lightdm). |
241 | - // As we want to avoid that any app's oom_score_adj or oom_adj is <= Unity8's oom_score_adj, |
242 | - // we choose a default value of -9 for oom_score_adj and 0 for oom_adj. |
243 | - static const int defaultValue = 0; |
244 | - |
245 | - try |
246 | - { |
247 | - process << plpp::OomAdj{defaultValue}; |
248 | - } catch(...) |
249 | - { |
250 | - qDebug() << "ensureProcessIsUnlikelyToBeKilled failed for pid" << pid; |
251 | - } |
252 | - } |
253 | -} |
254 | - |
255 | -ProcessController::ProcessController() |
256 | - : m_oomController(new ProcessController::OomController()) |
257 | -{ |
258 | -} |
259 | - |
260 | -ProcessController::~ProcessController() |
261 | -{ |
262 | -} |
263 | - |
264 | -const QSharedPointer<ProcessController::OomController>& ProcessController::oomController() const |
265 | -{ |
266 | - return m_oomController; |
267 | -} |
268 | - |
269 | -/*! |
270 | - * \brief ProcessController::sigStopProcessGroupForPid |
271 | - * \param pid |
272 | - * \return True if process was stopped successfully, false otherwise |
273 | - */ |
274 | -bool ProcessController::sigStopProcessGroupForPid(pid_t pid) const |
275 | -{ |
276 | - return -1 != kill(-pid, SIGSTOP); |
277 | -} |
278 | - |
279 | -/*! |
280 | - * \brief ProcessController::sigContinueProcessGroupForPid |
281 | - * \param pid |
282 | - * \return True of process was resumed successfully, false otherwise |
283 | - */ |
284 | -bool ProcessController::sigContinueProcessGroupForPid(pid_t pid) const |
285 | -{ |
286 | - return -1 != kill(-pid, SIGCONT); |
287 | -} |
288 | - |
289 | -} // namespace qtmir |
290 | |
291 | === removed file 'src/modules/Unity/Application/processcontroller.h' |
292 | --- src/modules/Unity/Application/processcontroller.h 2014-10-10 08:38:30 +0000 |
293 | +++ src/modules/Unity/Application/processcontroller.h 1970-01-01 00:00:00 +0000 |
294 | @@ -1,62 +0,0 @@ |
295 | -/* |
296 | - * Copyright (C) 2014 Canonical, Ltd. |
297 | - * |
298 | - * This program is free software: you can redistribute it and/or modify it under |
299 | - * the terms of the GNU Lesser General Public License version 3, as published by |
300 | - * the Free Software Foundation. |
301 | - * |
302 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
303 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
304 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
305 | - * Lesser General Public License for more details. |
306 | - * |
307 | - * You should have received a copy of the GNU Lesser General Public License |
308 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
309 | - * |
310 | - */ |
311 | - |
312 | -#ifndef PROCESS_CONTROLLER_H |
313 | -#define PROCESS_CONTROLLER_H |
314 | - |
315 | -#include <QSharedPointer> |
316 | - |
317 | -#include <sys/types.h> |
318 | - |
319 | -namespace qtmir |
320 | -{ |
321 | - |
322 | -class ProcessController |
323 | -{ |
324 | -public: |
325 | - class OomController |
326 | - { |
327 | - public: |
328 | - OomController(); |
329 | - OomController(const OomController&) = delete; |
330 | - virtual ~OomController() = default; |
331 | - |
332 | - OomController& operator=(const OomController&) = delete; |
333 | - |
334 | - virtual void ensureProcessLikelyToBeKilled(pid_t); |
335 | - virtual void ensureProcessLessLikelyToBeKilled(pid_t); |
336 | - virtual void ensureProcessUnlikelyToBeKilled(pid_t); |
337 | - }; |
338 | - |
339 | - ProcessController(); |
340 | - ProcessController(const ProcessController&) = delete; |
341 | - virtual ~ProcessController(); |
342 | - |
343 | - ProcessController& operator=(const ProcessController&) = delete; |
344 | - |
345 | - virtual const QSharedPointer<OomController>& oomController() const; |
346 | - |
347 | - virtual bool sigStopProcessGroupForPid(pid_t pid) const; |
348 | - virtual bool sigContinueProcessGroupForPid(pid_t pid) const; |
349 | - |
350 | -protected: |
351 | - QSharedPointer<OomController> m_oomController; |
352 | -}; |
353 | - |
354 | -} // namespace qtmir |
355 | - |
356 | -#endif // PROCESS_CONTROLLER_H |
357 | |
358 | === modified file 'src/modules/Unity/Application/taskcontroller.cpp' |
359 | --- src/modules/Unity/Application/taskcontroller.cpp 2014-10-10 08:38:30 +0000 |
360 | +++ src/modules/Unity/Application/taskcontroller.cpp 2014-10-24 15:59:35 +0000 |
361 | @@ -23,12 +23,6 @@ |
362 | // Qt |
363 | #include <QStringList> |
364 | |
365 | -// Process C++ |
366 | -#include <core/posix/process.h> |
367 | -#include <core/posix/this_process.h> |
368 | -#include <core/posix/linux/proc/process/oom_adj.h> |
369 | -#include <core/posix/linux/proc/process/oom_score_adj.h> |
370 | - |
371 | // STL |
372 | #include <mutex> |
373 | |
374 | @@ -41,11 +35,9 @@ |
375 | |
376 | TaskController::TaskController( |
377 | QObject *parent, |
378 | - const QSharedPointer<ApplicationController> &appController, |
379 | - const QSharedPointer<ProcessController> &processController) : |
380 | + const QSharedPointer<ApplicationController> &appController) : |
381 | QObject(parent), |
382 | - m_appController(appController), |
383 | - m_processController(processController) |
384 | + m_appController(appController) |
385 | { |
386 | connect(m_appController.data(), |
387 | &ApplicationController::applicationAboutToBeStarted, |
388 | @@ -53,11 +45,6 @@ |
389 | &TaskController::processStarting); |
390 | |
391 | connect(m_appController.data(), |
392 | - &ApplicationController::applicationStarted, |
393 | - this, |
394 | - &TaskController::onApplicationStarted); |
395 | - |
396 | - connect(m_appController.data(), |
397 | &ApplicationController::applicationStopped, |
398 | this, |
399 | &TaskController::processStopped); |
400 | @@ -109,64 +96,20 @@ |
401 | return m_appController->findDesktopFileForAppId(appId); |
402 | } |
403 | |
404 | -bool TaskController::suspend(const Application* app) |
405 | -{ |
406 | - qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << app->appId(); |
407 | - pid_t pid = m_appController->primaryPidForAppId(app->appId()); |
408 | - if (pid == 0) { |
409 | - pid = app->pid(); |
410 | - } |
411 | - |
412 | - // FIXME This harcodes the unity8-dash name, we should consider a different approach, |
413 | - // some privileged way to define which apps should be less likely to be killed. |
414 | - if (app->appId() == "unity8-dash") { |
415 | - m_processController->oomController()->ensureProcessLessLikelyToBeKilled(pid); |
416 | - } else { |
417 | - m_processController->oomController()->ensureProcessLikelyToBeKilled(pid); |
418 | - } |
419 | - |
420 | - if (pid) { |
421 | - // We do assume that the app was launched by ubuntu-app-launch and with that, |
422 | - // in its own process group. For that, we interpret the pid as pgid and |
423 | - // sigstop the complete process group on suspend. |
424 | - return m_processController->sigStopProcessGroupForPid(pid); |
425 | - } else { |
426 | - return false; |
427 | - } |
428 | -} |
429 | - |
430 | -bool TaskController::resume(const Application* app) |
431 | -{ |
432 | - qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << app->appId(); |
433 | - pid_t pid = m_appController->primaryPidForAppId(app->appId()); |
434 | - if (pid == 0) { |
435 | - pid = app->pid(); |
436 | - } |
437 | - |
438 | - m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid); |
439 | - |
440 | - if (pid) { |
441 | - // We do assume that the app was launched by ubuntu-app-launch and with that, |
442 | - // in its own process group. For that, we interpret the pid as pgid and |
443 | - // sigcont the complete process group on resume. |
444 | - return m_processController->sigContinueProcessGroupForPid(pid); |
445 | - return true; |
446 | - } else { |
447 | - qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - couldn't find PID to resume for appId=" << app->appId(); |
448 | - return false; |
449 | - } |
450 | -} |
451 | - |
452 | -void TaskController::onApplicationStarted(const QString& id) |
453 | -{ |
454 | - pid_t pid = m_appController->primaryPidForAppId(id); |
455 | - m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid); |
456 | +bool TaskController::suspend(const QString &appId) |
457 | +{ |
458 | + qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << appId; |
459 | + return m_appController->pauseApplicationWithAppId(appId); |
460 | +} |
461 | + |
462 | +bool TaskController::resume(const QString &appId) |
463 | +{ |
464 | + qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << appId; |
465 | + return m_appController->resumeApplicationWithAppId(appId); |
466 | } |
467 | |
468 | void TaskController::onApplicationFocusRequest(const QString& id) |
469 | { |
470 | - pid_t pid = m_appController->primaryPidForAppId(id); |
471 | - m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid); |
472 | Q_EMIT requestFocus(id); |
473 | } |
474 | |
475 | |
476 | === modified file 'src/modules/Unity/Application/taskcontroller.h' |
477 | --- src/modules/Unity/Application/taskcontroller.h 2014-09-18 09:39:48 +0000 |
478 | +++ src/modules/Unity/Application/taskcontroller.h 2014-10-24 15:59:35 +0000 |
479 | @@ -23,7 +23,6 @@ |
480 | |
481 | #include "application.h" |
482 | #include "applicationcontroller.h" |
483 | -#include "processcontroller.h" |
484 | |
485 | namespace qtmir |
486 | { |
487 | @@ -34,15 +33,14 @@ |
488 | public: |
489 | TaskController( |
490 | QObject *parent, |
491 | - const QSharedPointer<ApplicationController> &appController, |
492 | - const QSharedPointer<ProcessController> &processController = QSharedPointer<ProcessController>(new ProcessController())); |
493 | + const QSharedPointer<ApplicationController> &appController); |
494 | ~TaskController(); |
495 | |
496 | bool start(const QString &appId, const QStringList &args); |
497 | bool stop(const QString &appId); |
498 | |
499 | - bool suspend(const Application* app); |
500 | - bool resume(const Application* app); |
501 | + bool suspend(const QString &appId); |
502 | + bool resume(const QString &appId); |
503 | |
504 | bool appIdHasProcessId(const QString &appId, const quint64 pid) const; |
505 | QFileInfo findDesktopFileForAppId(const QString &appId) const; |
506 | @@ -55,7 +53,6 @@ |
507 | void requestResume(const QString &appId); |
508 | |
509 | private Q_SLOTS: |
510 | - void onApplicationStarted(const QString &id); |
511 | void onApplicationFocusRequest(const QString &id); |
512 | void onApplicationResumeRequest(const QString &id); |
513 | |
514 | @@ -63,7 +60,6 @@ |
515 | |
516 | private: |
517 | const QSharedPointer<ApplicationController> m_appController; |
518 | - const QSharedPointer<ProcessController> m_processController; |
519 | }; |
520 | |
521 | } // namespace qtmir |
522 | |
523 | === modified file 'src/modules/Unity/Application/upstart/applicationcontroller.cpp' |
524 | --- src/modules/Unity/Application/upstart/applicationcontroller.cpp 2014-07-01 13:38:06 +0000 |
525 | +++ src/modules/Unity/Application/upstart/applicationcontroller.cpp 2014-10-24 15:59:35 +0000 |
526 | @@ -203,6 +203,25 @@ |
527 | return result; |
528 | } |
529 | |
530 | +bool ApplicationController::pauseApplicationWithAppId(const QString& appId) |
531 | +{ |
532 | + auto result = ubuntu_app_launch_pause_application(toLongAppIdIfPossible(appId).toLatin1().constData()); |
533 | + if (!result) |
534 | + qDebug() << "ApplicationController::pauseApplication FAILED to pause appId=" << appId; |
535 | + |
536 | + return result; |
537 | +} |
538 | + |
539 | +bool ApplicationController::resumeApplicationWithAppId(const QString& appId) |
540 | +{ |
541 | + auto result = ubuntu_app_launch_resume_application(toLongAppIdIfPossible(appId).toLatin1().constData()); |
542 | + if (!result) |
543 | + qDebug() << "ApplicationController::resumeApplication FAILED to resume appId=" << appId; |
544 | + |
545 | + return result; |
546 | +} |
547 | + |
548 | + |
549 | QFileInfo ApplicationController::findDesktopFileForAppId(const QString &appId) const |
550 | { |
551 | qCDebug(QTMIR_APPLICATIONS) << "ApplicationController::desktopFilePathForAppId - appId=" << appId; |
552 | |
553 | === modified file 'src/modules/Unity/Application/upstart/applicationcontroller.h' |
554 | --- src/modules/Unity/Application/upstart/applicationcontroller.h 2014-07-01 13:38:06 +0000 |
555 | +++ src/modules/Unity/Application/upstart/applicationcontroller.h 2014-10-24 15:59:35 +0000 |
556 | @@ -37,6 +37,9 @@ |
557 | bool stopApplicationWithAppId(const QString& appId) override; |
558 | bool startApplicationWithAppIdAndArgs(const QString& appId, const QStringList& arguments) override; |
559 | |
560 | + bool pauseApplicationWithAppId(const QString& appId) override; |
561 | + bool resumeApplicationWithAppId(const QString& appId) override; |
562 | + |
563 | QFileInfo findDesktopFileForAppId(const QString &appId) const override; |
564 | |
565 | private: |
566 | |
567 | === modified file 'tests/modules/ApplicationManager/application_manager_test.cpp' |
568 | --- tests/modules/ApplicationManager/application_manager_test.cpp 2014-10-10 08:38:30 +0000 |
569 | +++ tests/modules/ApplicationManager/application_manager_test.cpp 2014-10-24 15:59:35 +0000 |
570 | @@ -56,12 +56,6 @@ |
571 | |
572 | EXPECT_CALL(desktopFileReaderFactory, createInstance(_, _)).Times(1); |
573 | |
574 | - EXPECT_CALL(processController, sigStopProcessGroupForPid(_)).Times(1); |
575 | - EXPECT_CALL(processController, sigContinueProcessGroupForPid(_)).Times(1); |
576 | - EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(_)).Times(1); |
577 | - EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(_)).Times(1); |
578 | - EXPECT_CALL(oomController, ensureProcessLessLikelyToBeKilled(_)).Times(0); |
579 | - |
580 | auto application = applicationManager.startApplication( |
581 | appId, |
582 | ApplicationManager::NoFlag, |
583 | @@ -87,12 +81,6 @@ |
584 | |
585 | ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false)); |
586 | |
587 | - EXPECT_CALL(processController, sigStopProcessGroupForPid(_)).Times(1); |
588 | - EXPECT_CALL(processController, sigContinueProcessGroupForPid(_)).Times(1); |
589 | - EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(_)).Times(1); |
590 | - EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(_)).Times(0); |
591 | - EXPECT_CALL(oomController, ensureProcessLessLikelyToBeKilled(_)).Times(1); |
592 | - |
593 | bool authed = true; |
594 | |
595 | std::shared_ptr<mir::scene::Session> session = std::make_shared<MockSession>("Oo", procId); |
596 | @@ -131,12 +119,6 @@ |
597 | onSessionStarting( mirSession ); |
598 | |
599 | EXPECT_NE(nullptr, application); |
600 | - |
601 | - appIds.insert(appId); |
602 | - auto it = appController.children.find(appId); |
603 | - if (it != appController.children.end()) |
604 | - EXPECT_CALL(oomController, |
605 | - ensureProcessUnlikelyToBeKilled(it->pid())).Times(1); |
606 | } |
607 | |
608 | for (auto appId : appIds) |
609 | |
610 | === modified file 'tests/modules/TaskController/taskcontroller_test.cpp' |
611 | --- tests/modules/TaskController/taskcontroller_test.cpp 2014-09-10 11:01:14 +0000 |
612 | +++ tests/modules/TaskController/taskcontroller_test.cpp 2014-10-24 15:59:35 +0000 |
613 | @@ -19,13 +19,8 @@ |
614 | #include <Unity/Application/desktopfilereader.h> |
615 | #include <Unity/Application/application.h> |
616 | |
617 | -#include "mock_oom_controller.h" |
618 | -#include "mock_process_controller.h" |
619 | #include "mock_desktop_file_reader.h" |
620 | |
621 | -#include <core/posix/fork.h> |
622 | -#include <core/posix/linux/proc/process/oom_score_adj.h> |
623 | - |
624 | #include <gmock/gmock.h> |
625 | #include <gtest/gtest.h> |
626 | |
627 | @@ -56,6 +51,8 @@ |
628 | |
629 | MOCK_METHOD1(stopApplicationWithAppId, bool(const QString&)); |
630 | MOCK_METHOD2(startApplicationWithAppIdAndArgs, bool(const QString&, const QStringList&)); |
631 | + MOCK_METHOD1(pauseApplicationWithAppId, bool(const QString&)); |
632 | + MOCK_METHOD1(resumeApplicationWithAppId, bool(const QString&)); |
633 | }; |
634 | } |
635 | |
636 | @@ -72,19 +69,8 @@ |
637 | |
638 | EXPECT_CALL(appController, startApplicationWithAppIdAndArgs(appId, QStringList())).Times(1).WillRepeatedly(Return(true)); |
639 | |
640 | - testing::NiceMock<MockOomController> oomController; |
641 | - QSharedPointer<ProcessController::OomController> oomControllerPtr( |
642 | - &oomController, |
643 | - [](ProcessController::OomController*){}); |
644 | - |
645 | - NiceMock<testing::MockProcessController> processController(oomControllerPtr); |
646 | - QSharedPointer<ProcessController> processControllerPtr( |
647 | - &processController, |
648 | - [](ProcessController*){}); |
649 | - |
650 | TaskController taskController(nullptr, |
651 | - appControllerPtr, |
652 | - processControllerPtr); |
653 | + appControllerPtr); |
654 | |
655 | taskController.start(appId, QStringList()); |
656 | } |
657 | @@ -102,189 +88,9 @@ |
658 | |
659 | EXPECT_CALL(appController, stopApplicationWithAppId(appId)).Times(1).WillRepeatedly(Return(true)); |
660 | |
661 | - testing::NiceMock<MockOomController> oomController; |
662 | - QSharedPointer<ProcessController::OomController> oomControllerPtr( |
663 | - &oomController, |
664 | - [](ProcessController::OomController*){}); |
665 | - |
666 | - NiceMock<testing::MockProcessController> processController(oomControllerPtr); |
667 | - QSharedPointer<ProcessController> processControllerPtr( |
668 | - &processController, |
669 | - [](ProcessController*){}); |
670 | - |
671 | TaskController taskController(nullptr, |
672 | - appControllerPtr, |
673 | - processControllerPtr); |
674 | + appControllerPtr); |
675 | |
676 | taskController.stop(appId); |
677 | } |
678 | |
679 | -TEST(TaskController, suspendingAnApplicationAdjustsOomScoreForCorrectPid) |
680 | -{ |
681 | - using namespace ::testing; |
682 | - |
683 | - const QString appId{"com.canonical.does.not.exist"}; |
684 | - |
685 | - testing::NiceMock<TriggerableApplicationController> appController; |
686 | - QSharedPointer<TriggerableApplicationController> appControllerPtr( |
687 | - &appController, |
688 | - [](ApplicationController*){}); |
689 | - |
690 | - EXPECT_CALL(appController, primaryPidForAppId(appId)).Times(1).WillRepeatedly(Return(-1)); |
691 | - |
692 | - testing::NiceMock<MockOomController> oomController; |
693 | - QSharedPointer<ProcessController::OomController> oomControllerPtr( |
694 | - &oomController, |
695 | - [](ProcessController::OomController*){}); |
696 | - |
697 | - NiceMock<testing::MockProcessController> processController(oomControllerPtr); |
698 | - QSharedPointer<ProcessController> processControllerPtr( |
699 | - &processController, |
700 | - [](ProcessController*){}); |
701 | - |
702 | - EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(-1)).Times(1); |
703 | - |
704 | - auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr, |
705 | - appControllerPtr, |
706 | - processControllerPtr)); |
707 | - |
708 | - |
709 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
710 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
711 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
712 | - Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr); |
713 | - taskController->suspend(app); |
714 | - delete app; |
715 | -} |
716 | - |
717 | -TEST(TaskController, resumingAnApplicationAdjustsOomScoreForCorrectPid) |
718 | -{ |
719 | - using namespace ::testing; |
720 | - |
721 | - const QString appId{"com.canonical.does.not.exist"}; |
722 | - |
723 | - testing::NiceMock<TriggerableApplicationController> appController; |
724 | - QSharedPointer<TriggerableApplicationController> appControllerPtr( |
725 | - &appController, |
726 | - [](ApplicationController*){}); |
727 | - |
728 | - EXPECT_CALL(appController, primaryPidForAppId(appId)).Times(1).WillRepeatedly(Return(-1)); |
729 | - |
730 | - testing::NiceMock<MockOomController> oomController; |
731 | - QSharedPointer<ProcessController::OomController> oomControllerPtr( |
732 | - &oomController, |
733 | - [](ProcessController::OomController*){}); |
734 | - |
735 | - NiceMock<testing::MockProcessController> processController(oomControllerPtr); |
736 | - QSharedPointer<ProcessController> processControllerPtr( |
737 | - &processController, |
738 | - [](ProcessController*){}); |
739 | - |
740 | - EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(-1)).Times(1); |
741 | - |
742 | - auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr, |
743 | - appControllerPtr, |
744 | - processControllerPtr)); |
745 | - |
746 | - |
747 | - auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); |
748 | - ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); |
749 | - ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); |
750 | - Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr); |
751 | - taskController->resume(app); |
752 | - delete app; |
753 | -} |
754 | - |
755 | -TEST(TaskController, aStartedApplicationIsOomScoreAdjusted) |
756 | -{ |
757 | - using namespace ::testing; |
758 | - |
759 | - const QString appId{"com.canonical.does.not.exist"}; |
760 | - |
761 | - testing::NiceMock<TriggerableApplicationController> appController; |
762 | - QSharedPointer<TriggerableApplicationController> appControllerPtr( |
763 | - &appController, |
764 | - [](ApplicationController*){}); |
765 | - EXPECT_CALL(appController, primaryPidForAppId(appId)).Times(1).WillRepeatedly(Return(42)); |
766 | - |
767 | - testing::NiceMock<MockOomController> oomController; |
768 | - QSharedPointer<ProcessController::OomController> oomControllerPtr( |
769 | - &oomController, |
770 | - [](ProcessController::OomController*){}); |
771 | - |
772 | - NiceMock<testing::MockProcessController> processController(oomControllerPtr); |
773 | - QSharedPointer<ProcessController> processControllerPtr( |
774 | - &processController, |
775 | - [](ProcessController*){}); |
776 | - |
777 | - EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(42)).Times(1); |
778 | - |
779 | - TaskController taskController(nullptr, |
780 | - appControllerPtr, |
781 | - processControllerPtr); |
782 | - |
783 | - appControllerPtr->triggerApplicationStarted(appId); |
784 | -} |
785 | - |
786 | -TEST(TaskController, aFocusedApplicationIsOomScoreAdjusted) |
787 | -{ |
788 | - using namespace ::testing; |
789 | - |
790 | - const QString appId{"com.canonical.does.not.exist"}; |
791 | - |
792 | - testing::NiceMock<TriggerableApplicationController> appController; |
793 | - QSharedPointer<TriggerableApplicationController> appControllerPtr( |
794 | - &appController, |
795 | - [](ApplicationController*){}); |
796 | - EXPECT_CALL(appController, primaryPidForAppId(appId)).Times(1).WillRepeatedly(Return(42)); |
797 | - |
798 | - testing::NiceMock<MockOomController> oomController; |
799 | - QSharedPointer<ProcessController::OomController> oomControllerPtr( |
800 | - &oomController, |
801 | - [](ProcessController::OomController*){}); |
802 | - |
803 | - NiceMock<testing::MockProcessController> processController(oomControllerPtr); |
804 | - QSharedPointer<ProcessController> processControllerPtr( |
805 | - &processController, |
806 | - [](ProcessController*){}); |
807 | - |
808 | - EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(42)).Times(1); |
809 | - |
810 | - TaskController taskController(nullptr, |
811 | - appControllerPtr, |
812 | - processControllerPtr); |
813 | - |
814 | - appControllerPtr->triggerApplicationFocusRequest(appId); |
815 | -} |
816 | - |
817 | -TEST(TaskController, oomControllerUpdatesOomScoreAdjCorrectly) |
818 | -{ |
819 | - ProcessController::OomController oomController; |
820 | - |
821 | - auto child = core::posix::fork([]() |
822 | - { |
823 | - while (true); |
824 | - |
825 | - return core::posix::exit::Status::success; |
826 | - }, core::posix::StandardStream::empty); |
827 | - |
828 | - EXPECT_GT(child.pid(), 0); |
829 | - |
830 | - core::posix::linux::proc::process::OomScoreAdj oomScoreAdj; |
831 | - child >> oomScoreAdj; |
832 | - |
833 | - core::posix::linux::proc::process::OomScoreAdj likelyOomScoreAdj, unlikelyOomScoreAdj; |
834 | - { |
835 | - oomController.ensureProcessLikelyToBeKilled(child.pid()); |
836 | - child >> likelyOomScoreAdj; |
837 | - |
838 | - EXPECT_GE(likelyOomScoreAdj.value, oomScoreAdj.value); |
839 | - } |
840 | - |
841 | - { |
842 | - oomController.ensureProcessUnlikelyToBeKilled(child.pid()); |
843 | - child >> unlikelyOomScoreAdj; |
844 | - |
845 | - EXPECT_LE(unlikelyOomScoreAdj.value, likelyOomScoreAdj.value); |
846 | - } |
847 | -} |
848 | |
849 | === modified file 'tests/modules/common/common.pri' |
850 | --- tests/modules/common/common.pri 2014-09-11 16:18:40 +0000 |
851 | +++ tests/modules/common/common.pri 2014-10-24 15:59:35 +0000 |
852 | @@ -1,5 +1,5 @@ |
853 | CONFIG += no_keywords # keywords clash with ProcessC++ |
854 | -PKGCONFIG += process-cpp ubuntu-app-launch-2 |
855 | +PKGCONFIG += ubuntu-app-launch-2 process-cpp |
856 | |
857 | QT += quick |
858 | |
859 | @@ -7,8 +7,6 @@ |
860 | ../common/mock_desktop_file_reader.h \ |
861 | ../common/mock_focus_controller.h \ |
862 | ../common/mock_mir_session.h \ |
863 | - ../common/mock_oom_controller.h \ |
864 | - ../common/mock_process_controller.h \ |
865 | ../common/mock_proc_info.h \ |
866 | ../common/mock_prompt_session.h \ |
867 | ../common/mock_prompt_session_manager.h \ |
868 | |
869 | === modified file 'tests/modules/common/mock_application_controller.h' |
870 | --- tests/modules/common/mock_application_controller.h 2014-07-01 13:38:06 +0000 |
871 | +++ tests/modules/common/mock_application_controller.h 2014-10-24 15:59:35 +0000 |
872 | @@ -34,6 +34,8 @@ |
873 | |
874 | MOCK_METHOD1(stopApplicationWithAppId, bool(const QString&)); |
875 | MOCK_METHOD2(startApplicationWithAppIdAndArgs, bool(const QString&, const QStringList&)); |
876 | + MOCK_METHOD1(pauseApplicationWithAppId, bool(const QString&)); |
877 | + MOCK_METHOD1(resumeApplicationWithAppId, bool(const QString&)); |
878 | |
879 | MockApplicationController() |
880 | { |
881 | @@ -57,6 +59,14 @@ |
882 | ON_CALL(*this, startApplicationWithAppIdAndArgs(_, _)) |
883 | .WillByDefault( |
884 | Invoke(this, &MockApplicationController::doStartApplicationWithAppIdAndArgs)); |
885 | + |
886 | + ON_CALL(*this, pauseApplicationWithAppId(_)) |
887 | + .WillByDefault( |
888 | + Invoke(this, &MockApplicationController::doPauseApplicationWithAppId)); |
889 | + |
890 | + ON_CALL(*this, resumeApplicationWithAppId(_)) |
891 | + .WillByDefault( |
892 | + Invoke(this, &MockApplicationController::doResumeApplicationWithAppId)); |
893 | } |
894 | |
895 | pid_t doPrimaryPidForAppId(const QString& appId) |
896 | @@ -85,14 +95,14 @@ |
897 | |
898 | bool doStopApplicationWithAppId(const QString& appId) |
899 | { |
900 | - (void) appId; |
901 | + Q_UNUSED(appId); |
902 | |
903 | return false; |
904 | } |
905 | |
906 | bool doStartApplicationWithAppIdAndArgs(const QString& appId, const QStringList& args) |
907 | { |
908 | - (void) args; |
909 | + Q_UNUSED(args); |
910 | |
911 | auto child = core::posix::fork([]() |
912 | { |
913 | @@ -110,6 +120,20 @@ |
914 | return false; |
915 | } |
916 | |
917 | + bool doPauseApplicationWithAppId(const QString& appId) |
918 | + { |
919 | + Q_UNUSED(appId); |
920 | + |
921 | + return false; |
922 | + } |
923 | + |
924 | + bool doResumeApplicationWithAppId(const QString& appId) |
925 | + { |
926 | + Q_UNUSED(appId); |
927 | + |
928 | + return false; |
929 | + } |
930 | + |
931 | QMap<QString, core::posix::ChildProcess> children; |
932 | }; |
933 | } // namespace testing |
934 | |
935 | === removed file 'tests/modules/common/mock_oom_controller.h' |
936 | --- tests/modules/common/mock_oom_controller.h 2014-10-10 08:38:30 +0000 |
937 | +++ tests/modules/common/mock_oom_controller.h 1970-01-01 00:00:00 +0000 |
938 | @@ -1,34 +0,0 @@ |
939 | -/* |
940 | - * Copyright (C) 2013 Canonical, Ltd. |
941 | - * |
942 | - * This program is free software: you can redistribute it and/or modify it under |
943 | - * the terms of the GNU Lesser General Public License version 3, as published by |
944 | - * the Free Software Foundation. |
945 | - * |
946 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
947 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
948 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
949 | - * Lesser General Public License for more details. |
950 | - * |
951 | - * You should have received a copy of the GNU Lesser General Public License |
952 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
953 | - * |
954 | - */ |
955 | -#ifndef MOCK_OOM_CONTROLLER_H |
956 | -#define MOCK_OOM_CONTROLLER_H |
957 | - |
958 | -#include <Unity/Application/processcontroller.h> |
959 | - |
960 | -#include <gmock/gmock.h> |
961 | - |
962 | -namespace testing |
963 | -{ |
964 | -struct MockOomController : public qtmir::ProcessController::OomController |
965 | -{ |
966 | - MOCK_METHOD1(ensureProcessLikelyToBeKilled, void(pid_t)); |
967 | - MOCK_METHOD1(ensureProcessLessLikelyToBeKilled, void(pid_t)); |
968 | - MOCK_METHOD1(ensureProcessUnlikelyToBeKilled, void(pid_t)); |
969 | -}; |
970 | -} |
971 | - |
972 | -#endif // MOCK_OOM_CONTROLLER_H |
973 | |
974 | === removed file 'tests/modules/common/mock_process_controller.h' |
975 | --- tests/modules/common/mock_process_controller.h 2014-07-01 13:38:06 +0000 |
976 | +++ tests/modules/common/mock_process_controller.h 1970-01-01 00:00:00 +0000 |
977 | @@ -1,45 +0,0 @@ |
978 | -/* |
979 | - * Copyright (C) 2013 Canonical, Ltd. |
980 | - * |
981 | - * This program is free software: you can redistribute it and/or modify it under |
982 | - * the terms of the GNU Lesser General Public License version 3, as published by |
983 | - * the Free Software Foundation. |
984 | - * |
985 | - * This program is distributed in the hope that it will be useful, but WITHOUT |
986 | - * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
987 | - * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
988 | - * Lesser General Public License for more details. |
989 | - * |
990 | - * You should have received a copy of the GNU Lesser General Public License |
991 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
992 | - * |
993 | - */ |
994 | -#ifndef MOCK_PROCESS_CONTROLLER_H |
995 | -#define MOCK_PROCESS_CONTROLLER_H |
996 | - |
997 | -#include <Unity/Application/processcontroller.h> |
998 | - |
999 | -#include <gmock/gmock.h> |
1000 | - |
1001 | -namespace testing |
1002 | -{ |
1003 | -struct MockProcessController : public qtmir::ProcessController |
1004 | -{ |
1005 | - MockProcessController(const QSharedPointer<qtmir::ProcessController::OomController>& oomController) |
1006 | - : m_oomController(oomController) |
1007 | - { |
1008 | - } |
1009 | - |
1010 | - const QSharedPointer<qtmir::ProcessController::OomController>& oomController() const |
1011 | - { |
1012 | - return m_oomController; |
1013 | - } |
1014 | - |
1015 | - MOCK_CONST_METHOD1(sigStopProcessGroupForPid, bool(pid_t)); |
1016 | - MOCK_CONST_METHOD1(sigContinueProcessGroupForPid, bool(pid_t)); |
1017 | - |
1018 | - QSharedPointer<qtmir::ProcessController::OomController> m_oomController; |
1019 | -}; |
1020 | -} |
1021 | - |
1022 | -#endif // MOCK_PROCESS_CONTROLLER_H |
1023 | |
1024 | === modified file 'tests/modules/common/qtmir_test.h' |
1025 | --- tests/modules/common/qtmir_test.h 2014-09-11 16:18:40 +0000 |
1026 | +++ tests/modules/common/qtmir_test.h 2014-10-24 15:59:35 +0000 |
1027 | @@ -20,8 +20,6 @@ |
1028 | |
1029 | #include <gtest/gtest.h> |
1030 | |
1031 | -#include <core/posix/linux/proc/process/oom_score_adj.h> |
1032 | - |
1033 | #include <Unity/Application/application_manager.h> |
1034 | #include <Unity/Application/applicationcontroller.h> |
1035 | #include <Unity/Application/mirsurfacemanager.h> |
1036 | @@ -32,8 +30,6 @@ |
1037 | |
1038 | #include "mock_application_controller.h" |
1039 | #include "mock_desktop_file_reader.h" |
1040 | -#include "mock_oom_controller.h" |
1041 | -#include "mock_process_controller.h" |
1042 | #include "mock_proc_info.h" |
1043 | #include "mock_mir_session.h" |
1044 | #include "mock_focus_controller.h" |
1045 | @@ -80,12 +76,7 @@ |
1046 | { |
1047 | public: |
1048 | QtMirTest() |
1049 | - : processController{ |
1050 | - QSharedPointer<ProcessController::OomController> ( |
1051 | - &oomController, |
1052 | - [](ProcessController::OomController*){}) |
1053 | - } |
1054 | - , mirConfig{ |
1055 | + : mirConfig{ |
1056 | QSharedPointer<FakeMirServerConfiguration> (new FakeMirServerConfiguration) |
1057 | } |
1058 | , taskController{ |
1059 | @@ -94,10 +85,7 @@ |
1060 | nullptr, |
1061 | QSharedPointer<ApplicationController>( |
1062 | &appController, |
1063 | - [](ApplicationController*){}), |
1064 | - QSharedPointer<ProcessController>( |
1065 | - &processController, |
1066 | - [](ProcessController*){}) |
1067 | + [](ApplicationController*){}) |
1068 | ) |
1069 | ) |
1070 | } |
1071 | @@ -150,8 +138,6 @@ |
1072 | return nullptr; |
1073 | } |
1074 | |
1075 | - testing::NiceMock<testing::MockOomController> oomController; |
1076 | - testing::NiceMock<testing::MockProcessController> processController; |
1077 | testing::NiceMock<testing::MockApplicationController> appController; |
1078 | testing::NiceMock<testing::MockProcInfo> procInfo; |
1079 | testing::NiceMock<testing::MockDesktopFileReaderFactory> desktopFileReaderFactory; |
PASSED: Continuous integration, rev:261 jenkins. qa.ubuntu. com/job/ qtmir-ci/ 97/ jenkins. qa.ubuntu. com/job/ qtmir-utopic- amd64-ci/ 97 jenkins. qa.ubuntu. com/job/ qtmir-utopic- armhf-ci/ 97 jenkins. qa.ubuntu. com/job/ qtmir-utopic- armhf-ci/ 97/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtmir- ci/97/rebuild
http://