Merge lp:~ted/ubuntu-app-launch/non-blocking-resume into lp:ubuntu-app-launch/touch-vivid

Proposed by Ted Gould
Status: Merged
Approved by: Michał Sawicz
Approved revision: 275
Merged at revision: 267
Proposed branch: lp:~ted/ubuntu-app-launch/non-blocking-resume
Merge into: lp:ubuntu-app-launch/touch-vivid
Diff against target: 470 lines (+158/-126)
6 files modified
libubuntu-app-launch/application-impl-base.cpp (+97/-75)
libubuntu-app-launch/application-impl-base.h (+15/-6)
libubuntu-app-launch/application-impl-libertine.cpp (+1/-2)
libubuntu-app-launch/registry-impl.cpp (+19/-26)
libubuntu-app-launch/snapd-info.cpp (+1/-1)
tests/libual-cpp-test.cc (+25/-16)
To merge this branch: bzr merge lp:~ted/ubuntu-app-launch/non-blocking-resume
Reviewer Review Type Date Requested Status
Michał Sawicz Approve
Review via email: mp+310492@code.launchpad.net

Commit message

Make resume/pause non-blocking

To post a comment you must log in.
274. By Ted Gould

Forgot to remove emit.h from the CMakeLists.txt

Revision history for this message
Michał Sawicz (saviq) wrote :
review: Needs Fixing
275. By Ted Gould

Make several functions static so that they don't depend on the object existing for their execution

Revision history for this message
Michał Sawicz (saviq) wrote :
review: Approve
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

Tested silo 2181 on an MX4 running proposed and it fixed the symptoms from lp:1637996

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libubuntu-app-launch/application-impl-base.cpp'
--- libubuntu-app-launch/application-impl-base.cpp 2016-10-03 23:54:20 +0000
+++ libubuntu-app-launch/application-impl-base.cpp 2016-11-10 15:35:24 +0000
@@ -257,8 +257,15 @@
257/** Returns all the PIDs that are in the cgroup for this application */257/** Returns all the PIDs that are in the cgroup for this application */
258std::vector<pid_t> UpstartInstance::pids()258std::vector<pid_t> UpstartInstance::pids()
259{259{
260 auto pids = registry_->impl->pidsFromCgroup(upstartJobPath());260 return pids(registry_, appId_, upstartJobPath());
261 g_debug("Got %d PIDs for AppID '%s'", int(pids.size()), std::string(appId_).c_str());261}
262
263std::vector<pid_t> UpstartInstance::pids(const std::shared_ptr<Registry>& reg,
264 const AppID& appid,
265 const std::string& jobpath)
266{
267 auto pids = reg->impl->pidsFromCgroup(jobpath);
268 g_debug("Got %d PIDs for AppID '%s'", int(pids.size()), std::string(appid).c_str());
262 return pids;269 return pids;
263}270}
264271
@@ -267,16 +274,23 @@
267void UpstartInstance::pause()274void UpstartInstance::pause()
268{275{
269 g_debug("Pausing application: %s", std::string(appId_).c_str());276 g_debug("Pausing application: %s", std::string(appId_).c_str());
277
278 auto registry = registry_;
279 auto appid = appId_;
280 auto jobpath = upstartJobPath();
281
282 registry->impl->thread.executeOnThread([registry, appid, jobpath] {
283 auto pids = forAllPids(registry, appid, jobpath, [](pid_t pid) {
284 auto oomval = oom::paused();
285 g_debug("Pausing PID: %d (%d)", pid, int(oomval));
286 signalToPid(pid, SIGSTOP);
287 oomValueToPid(pid, oomval);
288 });
289
290 pidListToDbus(registry, appid, pids, "ApplicationPaused");
291 });
292
270 registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_LEAVE_EVENT);293 registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_LEAVE_EVENT);
271
272 auto pids = forAllPids([this](pid_t pid) {
273 auto oomval = oom::paused();
274 g_debug("Pausing PID: %d (%d)", pid, int(oomval));
275 signalToPid(pid, SIGSTOP);
276 oomValueToPid(pid, oomval);
277 });
278
279 pidListToDbus(pids, "ApplicationPaused");
280}294}
281295
282/** Resumes this application by sending SIGCONT to all the PIDs in the296/** Resumes this application by sending SIGCONT to all the PIDs in the
@@ -284,16 +298,23 @@
284void UpstartInstance::resume()298void UpstartInstance::resume()
285{299{
286 g_debug("Resuming application: %s", std::string(appId_).c_str());300 g_debug("Resuming application: %s", std::string(appId_).c_str());
301
302 auto registry = registry_;
303 auto appid = appId_;
304 auto jobpath = upstartJobPath();
305
306 registry->impl->thread.executeOnThread([registry, appid, jobpath] {
307 auto pids = forAllPids(registry, appid, jobpath, [](pid_t pid) {
308 auto oomval = oom::focused();
309 g_debug("Resuming PID: %d (%d)", pid, int(oomval));
310 signalToPid(pid, SIGCONT);
311 oomValueToPid(pid, oomval);
312 });
313
314 pidListToDbus(registry, appid, pids, "ApplicationResumed");
315 });
316
287 registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_ACCESS_EVENT);317 registry_->impl->zgSendEvent(appId_, ZEITGEIST_ZG_ACCESS_EVENT);
288
289 auto pids = forAllPids([this](pid_t pid) {
290 auto oomval = oom::focused();
291 g_debug("Resuming PID: %d (%d)", pid, int(oomval));
292 signalToPid(pid, SIGCONT);
293 oomValueToPid(pid, oomval);
294 });
295
296 pidListToDbus(pids, "ApplicationResumed");
297}318}
298319
299/** Stops this instance by asking Upstart to stop it. Upstart will then320/** Stops this instance by asking Upstart to stop it. Upstart will then
@@ -365,7 +386,7 @@
365*/386*/
366void UpstartInstance::setOomAdjustment(const oom::Score score)387void UpstartInstance::setOomAdjustment(const oom::Score score)
367{388{
368 forAllPids([this, &score](pid_t pid) { oomValueToPid(pid, score); });389 forAllPids(registry_, appId_, upstartJobPath(), [score](pid_t pid) { oomValueToPid(pid, score); });
369}390}
370391
371/** Figures out the path to the primary PID of the application and392/** Figures out the path to the primary PID of the application and
@@ -404,7 +425,10 @@
404425
405 \param eachPid Function to run on each PID426 \param eachPid Function to run on each PID
406*/427*/
407std::vector<pid_t> UpstartInstance::forAllPids(std::function<void(pid_t)> eachPid)428std::vector<pid_t> UpstartInstance::forAllPids(const std::shared_ptr<Registry>& reg,
429 const AppID& appid,
430 const std::string& jobpath,
431 std::function<void(pid_t)> eachPid)
408{432{
409 std::set<pid_t> seenPids;433 std::set<pid_t> seenPids;
410 bool added = true;434 bool added = true;
@@ -412,7 +436,7 @@
412 while (added)436 while (added)
413 {437 {
414 added = false;438 added = false;
415 auto pidlist = pids();439 auto pidlist = pids(reg, appid, jobpath);
416 for (auto pid : pidlist)440 for (auto pid : pidlist)
417 {441 {
418 if (seenPids.insert(pid).second)442 if (seenPids.insert(pid).second)
@@ -572,61 +596,59 @@
572 \param pids List of PIDs to turn into variants to send596 \param pids List of PIDs to turn into variants to send
573 \param signal Name of the DBus signal to send597 \param signal Name of the DBus signal to send
574*/598*/
575void UpstartInstance::pidListToDbus(const std::vector<pid_t>& pids, const std::string& signal)599void UpstartInstance::pidListToDbus(const std::shared_ptr<Registry>& reg,
600 const AppID& appid,
601 const std::vector<pid_t>& pids,
602 const std::string& signal)
576{603{
577 auto registry = registry_;604 auto vpids = std::shared_ptr<GVariant>(
578 auto lappid = appId_;605 [pids]() {
579606 GVariant* pidarray = nullptr;
580 registry_->impl->thread.executeOnThread([registry, lappid, pids, signal] {607
581 auto vpids = std::shared_ptr<GVariant>(608 if (pids.empty())
582 [pids]() {609 {
583 GVariant* pidarray = nullptr;610 pidarray = g_variant_new_array(G_VARIANT_TYPE_UINT64, nullptr, 0);
584
585 if (pids.empty())
586 {
587 pidarray = g_variant_new_array(G_VARIANT_TYPE_UINT64, nullptr, 0);
588 g_variant_ref_sink(pidarray);
589 return pidarray;
590 }
591
592 GVariantBuilder builder;
593 g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
594 for (auto pid : pids)
595 {
596 g_variant_builder_add_value(&builder, g_variant_new_uint64(pid));
597 }
598
599 pidarray = g_variant_builder_end(&builder);
600 g_variant_ref_sink(pidarray);611 g_variant_ref_sink(pidarray);
601 return pidarray;612 return pidarray;
602 }(),613 }
603 [](GVariant* var) { g_variant_unref(var); });614
604615 GVariantBuilder builder;
605 GVariantBuilder params;616 g_variant_builder_init(&builder, G_VARIANT_TYPE_ARRAY);
606 g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);617 for (auto pid : pids)
607 g_variant_builder_add_value(&params, g_variant_new_string(std::string(lappid).c_str()));618 {
608 g_variant_builder_add_value(&params, vpids.get());619 g_variant_builder_add_value(&builder, g_variant_new_uint64(pid));
609620 }
610 GError* error = nullptr;621
611 g_dbus_connection_emit_signal(registry->impl->_dbus.get(), /* bus */622 pidarray = g_variant_builder_end(&builder);
612 nullptr, /* destination */623 g_variant_ref_sink(pidarray);
613 "/", /* path */624 return pidarray;
614 "com.canonical.UbuntuAppLaunch", /* interface */625 }(),
615 signal.c_str(), /* signal */626 [](GVariant* var) { g_variant_unref(var); });
616 g_variant_builder_end(&params), /* params, the same */627
617 &error); /* error */628 GVariantBuilder params;
618629 g_variant_builder_init(&params, G_VARIANT_TYPE_TUPLE);
619 if (error != nullptr)630 g_variant_builder_add_value(&params, g_variant_new_string(std::string(appid).c_str()));
620 {631 g_variant_builder_add_value(&params, vpids.get());
621 g_warning("Unable to emit signal '%s' for appid '%s': %s", signal.c_str(), std::string(lappid).c_str(),632
622 error->message);633 GError* error = nullptr;
623 g_error_free(error);634 g_dbus_connection_emit_signal(reg->impl->_dbus.get(), /* bus */
624 }635 nullptr, /* destination */
625 else636 "/", /* path */
626 {637 "com.canonical.UbuntuAppLaunch", /* interface */
627 g_debug("Emmitted '%s' to DBus", signal.c_str());638 signal.c_str(), /* signal */
628 }639 g_variant_builder_end(&params), /* params, the same */
629 });640 &error); /* error */
641
642 if (error != nullptr)
643 {
644 g_warning("Unable to emit signal '%s' for appid '%s': %s", signal.c_str(), std::string(appid).c_str(),
645 error->message);
646 g_error_free(error);
647 }
648 else
649 {
650 g_debug("Emmitted '%s' to DBus", signal.c_str());
651 }
630}652}
631653
632/** Create a new Upstart Instance object that can track the job and654/** Create a new Upstart Instance object that can track the job and
633655
=== modified file 'libubuntu-app-launch/application-impl-base.h'
--- libubuntu-app-launch/application-impl-base.h 2016-09-23 22:30:51 +0000
+++ libubuntu-app-launch/application-impl-base.h 2016-11-10 15:35:24 +0000
@@ -108,14 +108,23 @@
108 /** A link to the registry we're using for connections */108 /** A link to the registry we're using for connections */
109 std::shared_ptr<Registry> registry_;109 std::shared_ptr<Registry> registry_;
110110
111 std::vector<pid_t> forAllPids(std::function<void(pid_t)> eachPid);
112 void signalToPid(pid_t pid, int signal);
113 std::string pidToOomPath(pid_t pid);
114 void oomValueToPid(pid_t pid, const oom::Score oomvalue);
115 void oomValueToPidHelper(pid_t pid, const oom::Score oomvalue);
116 void pidListToDbus(const std::vector<pid_t>& pids, const std::string& signal);
117 std::string upstartJobPath();111 std::string upstartJobPath();
118112
113 static std::vector<pid_t> forAllPids(const std::shared_ptr<Registry>& reg,
114 const AppID& appid,
115 const std::string& jobpath,
116 std::function<void(pid_t)> eachPid);
117 static std::vector<pid_t> pids(const std::shared_ptr<Registry>& reg,
118 const AppID& appid,
119 const std::string& jobpath);
120 static void pidListToDbus(const std::shared_ptr<Registry>& reg,
121 const AppID& appid,
122 const std::vector<pid_t>& pids,
123 const std::string& signal);
124 static void signalToPid(pid_t pid, int signal);
125 static void oomValueToPid(pid_t pid, const oom::Score oomvalue);
126 static void oomValueToPidHelper(pid_t pid, const oom::Score oomvalue);
127 static std::string pidToOomPath(pid_t pid);
119 static std::shared_ptr<gchar*> urlsToStrv(const std::vector<Application::URL>& urls);128 static std::shared_ptr<gchar*> urlsToStrv(const std::vector<Application::URL>& urls);
120 static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data);129 static void application_start_cb(GObject* obj, GAsyncResult* res, gpointer user_data);
121};130};
122131
=== modified file 'libubuntu-app-launch/application-impl-libertine.cpp'
--- libubuntu-app-launch/application-impl-libertine.cpp 2016-10-03 23:54:20 +0000
+++ libubuntu-app-launch/application-impl-libertine.cpp 2016-11-10 15:35:24 +0000
@@ -255,8 +255,7 @@
255 }255 }
256 catch (std::runtime_error& e)256 catch (std::runtime_error& e)
257 {257 {
258 g_debug("Unable to create application for libertine appname '%s': %s",258 g_debug("Unable to create application for libertine appname '%s': %s", apps.get()[j], e.what());
259 apps.get()[j], e.what());
260 }259 }
261 }260 }
262 }261 }
263262
=== modified file 'libubuntu-app-launch/registry-impl.cpp'
--- libubuntu-app-launch/registry-impl.cpp 2016-09-23 22:30:51 +0000
+++ libubuntu-app-launch/registry-impl.cpp 2016-11-10 15:35:24 +0000
@@ -222,17 +222,13 @@
222 if (cgManager_)222 if (cgManager_)
223 return;223 return;
224224
225 std::promise<std::shared_ptr<GDBusConnection>> promise;225 cgManager_ = thread.executeOnThread<std::shared_ptr<GDBusConnection>>([this]() {
226 auto future = promise.get_future();
227
228 thread.executeOnThread([this, &promise]() {
229 bool use_session_bus = g_getenv("UBUNTU_APP_LAUNCH_CG_MANAGER_SESSION_BUS") != nullptr;226 bool use_session_bus = g_getenv("UBUNTU_APP_LAUNCH_CG_MANAGER_SESSION_BUS") != nullptr;
230 if (use_session_bus)227 if (use_session_bus)
231 {228 {
232 /* For working dbusmock */229 /* For working dbusmock */
233 g_debug("Connecting to CG Manager on session bus");230 g_debug("Connecting to CG Manager on session bus");
234 promise.set_value(_dbus);231 return _dbus;
235 return;
236 }232 }
237233
238 auto cancel =234 auto cancel =
@@ -241,28 +237,25 @@
241 /* Ensure that we do not wait for more than a second */237 /* Ensure that we do not wait for more than a second */
242 thread.timeoutSeconds(std::chrono::seconds{1}, [cancel]() { g_cancellable_cancel(cancel.get()); });238 thread.timeoutSeconds(std::chrono::seconds{1}, [cancel]() { g_cancellable_cancel(cancel.get()); });
243239
244 g_dbus_connection_new_for_address(240 GError* error = nullptr;
245 CGMANAGER_DBUS_PATH, /* cgmanager path */241 auto retval = std::shared_ptr<GDBusConnection>(
246 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, /* flags */242 g_dbus_connection_new_for_address_sync(CGMANAGER_DBUS_PATH, /* cgmanager path */
247 nullptr, /* Auth Observer */243 G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT, /* flags */
248 cancel.get(), /* Cancellable */244 nullptr, /* Auth Observer */
249 [](GObject* obj, GAsyncResult* res, gpointer data) -> void {245 cancel.get(), /* Cancellable */
250 GError* error = nullptr;246 &error),
251 auto promise = reinterpret_cast<std::promise<std::shared_ptr<GDBusConnection>>*>(data);247 [](GDBusConnection* con) { g_clear_object(&con); });
252248
253 auto gcon = g_dbus_connection_new_for_address_finish(res, &error);249 if (error != nullptr)
254 if (error != nullptr)250 {
255 {251 g_warning("Unable to get CGManager connection: %s", error->message);
256 g_error_free(error);252 g_error_free(error);
257 }253 }
258254
259 auto con = std::shared_ptr<GDBusConnection>(gcon, [](GDBusConnection* con) { g_clear_object(&con); });255 return retval;
260 promise->set_value(con);
261 },
262 &promise);
263 });256 });
264257
265 cgManager_ = future.get();258 /* NOTE: This will execute on the thread */
266 thread.timeoutSeconds(std::chrono::seconds{10}, [this]() { cgManager_.reset(); });259 thread.timeoutSeconds(std::chrono::seconds{10}, [this]() { cgManager_.reset(); });
267}260}
268261
269262
=== modified file 'libubuntu-app-launch/snapd-info.cpp'
--- libubuntu-app-launch/snapd-info.cpp 2016-10-03 23:54:08 +0000
+++ libubuntu-app-launch/snapd-info.cpp 2016-11-10 15:35:24 +0000
@@ -217,7 +217,7 @@
217 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, snapd_writefunc);217 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, snapd_writefunc);
218218
219 /* Overridable timeout */219 /* Overridable timeout */
220 if (g_getenv("UBUNTU_APP_LAUNCH_DISABLE_SNAPD_TIMEOUT") != nullptr)220 if (g_getenv("UBUNTU_APP_LAUNCH_DISABLE_SNAPD_TIMEOUT") == nullptr)
221 {221 {
222 curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 100L);222 curl_easy_setopt(curl, CURLOPT_TIMEOUT_MS, 100L);
223 }223 }
224224
=== modified file 'tests/libual-cpp-test.cc'
--- tests/libual-cpp-test.cc 2016-09-23 20:36:31 +0000
+++ tests/libual-cpp-test.cc 2016-11-10 15:35:24 +0000
@@ -1523,13 +1523,7 @@
1523 }1523 }
1524};1524};
15251525
1526static void signal_increment(GDBusConnection* connection,1526static void signal_increment(const gchar* appid, GPid* pids, gpointer user_data)
1527 const gchar* sender,
1528 const gchar* path,
1529 const gchar* interface,
1530 const gchar* signal,
1531 GVariant* params,
1532 gpointer user_data)
1533{1527{
1534 guint* count = (guint*)user_data;1528 guint* count = (guint*)user_data;
1535 g_debug("Count incremented to: %d", *count + 1);1529 g_debug("Count incremented to: %d", *count + 1);
@@ -1577,12 +1571,9 @@
1577 /* Setup signal handling */1571 /* Setup signal handling */
1578 guint paused_count = 0;1572 guint paused_count = 0;
1579 guint resumed_count = 0;1573 guint resumed_count = 0;
1580 guint paused_signal =1574
1581 g_dbus_connection_signal_subscribe(bus, nullptr, "com.canonical.UbuntuAppLaunch", "ApplicationPaused", "/",1575 ASSERT_TRUE(ubuntu_app_launch_observer_add_app_paused(signal_increment, &paused_count));
1582 nullptr, G_DBUS_SIGNAL_FLAGS_NONE, signal_increment, &paused_count, nullptr);1576 ASSERT_TRUE(ubuntu_app_launch_observer_add_app_resumed(signal_increment, &resumed_count));
1583 guint resumed_signal = g_dbus_connection_signal_subscribe(
1584 bus, nullptr, "com.canonical.UbuntuAppLaunch", "ApplicationResumed", "/", nullptr, G_DBUS_SIGNAL_FLAGS_NONE,
1585 signal_increment, &resumed_count, nullptr);
15861577
1587 /* Get our app object */1578 /* Get our app object */
1588 auto appid = ubuntu::app_launch::AppID::find(registry, "com.test.good_application_1.2.3");1579 auto appid = ubuntu::app_launch::AppID::find(registry, "com.test.good_application_1.2.3");
@@ -1639,8 +1630,8 @@
16391630
1640 g_spawn_command_line_sync("rm -rf " CMAKE_BINARY_DIR "/libual-proc", NULL, NULL, NULL, NULL);1631 g_spawn_command_line_sync("rm -rf " CMAKE_BINARY_DIR "/libual-proc", NULL, NULL, NULL, NULL);
16411632
1642 g_dbus_connection_signal_unsubscribe(bus, paused_signal);1633 ASSERT_TRUE(ubuntu_app_launch_observer_delete_app_paused(signal_increment, &paused_count));
1643 g_dbus_connection_signal_unsubscribe(bus, resumed_signal);1634 ASSERT_TRUE(ubuntu_app_launch_observer_delete_app_resumed(signal_increment, &resumed_count));
1644}1635}
16451636
1646TEST_F(LibUAL, MultiPause)1637TEST_F(LibUAL, MultiPause)
@@ -1686,10 +1677,17 @@
1686 do1677 do
1687 {1678 {
1688 g_debug("Giving mocks a chance to start");1679 g_debug("Giving mocks a chance to start");
1689 pause(200);1680 pause(20);
1690 } while (dbus_test_task_get_state(DBUS_TEST_TASK(cgmock2)) != DBUS_TEST_TASK_STATE_RUNNING &&1681 } while (dbus_test_task_get_state(DBUS_TEST_TASK(cgmock2)) != DBUS_TEST_TASK_STATE_RUNNING &&
1691 dbus_test_task_get_state(DBUS_TEST_TASK(zgmock)) != DBUS_TEST_TASK_STATE_RUNNING);1682 dbus_test_task_get_state(DBUS_TEST_TASK(zgmock)) != DBUS_TEST_TASK_STATE_RUNNING);
16921683
1684 /* Setup signal handling */
1685 guint paused_count = 0;
1686 guint resumed_count = 0;
1687
1688 ASSERT_TRUE(ubuntu_app_launch_observer_add_app_paused(signal_increment, &paused_count));
1689 ASSERT_TRUE(ubuntu_app_launch_observer_add_app_resumed(signal_increment, &resumed_count));
1690
1693 /* Get our app object */1691 /* Get our app object */
1694 auto appid = ubuntu::app_launch::AppID::find(registry, "com.test.good_application_1.2.3");1692 auto appid = ubuntu::app_launch::AppID::find(registry, "com.test.good_application_1.2.3");
1695 auto app = ubuntu::app_launch::Application::create(appid, registry);1693 auto app = ubuntu::app_launch::Application::create(appid, registry);
@@ -1705,6 +1703,8 @@
1705 /* Pause the app */1703 /* Pause the app */
1706 instance->pause();1704 instance->pause();
17071705
1706 EXPECT_EVENTUALLY_EQ(1, paused_count);
1707
1708 std::for_each(spews.begin(), spews.end(), [](SpewMaster& spew) { spew.reset(); });1708 std::for_each(spews.begin(), spews.end(), [](SpewMaster& spew) { spew.reset(); });
1709 pause(50);1709 pause(50);
17101710
@@ -1715,6 +1715,8 @@
1715 /* Now Resume the App */1715 /* Now Resume the App */
1716 instance->resume();1716 instance->resume();
17171717
1718 EXPECT_EVENTUALLY_EQ(1, resumed_count);
1719
1718 pause(50);1720 pause(50);
17191721
1720 EXPECT_NE(0, std::accumulate(spews.begin(), spews.end(), int{0},1722 EXPECT_NE(0, std::accumulate(spews.begin(), spews.end(), int{0},
@@ -1723,6 +1725,8 @@
1723 /* Pause the app */1725 /* Pause the app */
1724 instance->pause();1726 instance->pause();
17251727
1728 EXPECT_EVENTUALLY_EQ(2, paused_count);
1729
1726 std::for_each(spews.begin(), spews.end(), [](SpewMaster& spew) { spew.reset(); });1730 std::for_each(spews.begin(), spews.end(), [](SpewMaster& spew) { spew.reset(); });
1727 pause(50);1731 pause(50);
17281732
@@ -1733,12 +1737,17 @@
1733 /* Now Resume the App */1737 /* Now Resume the App */
1734 instance->resume();1738 instance->resume();
17351739
1740 EXPECT_EVENTUALLY_EQ(2, resumed_count);
1741
1736 pause(50);1742 pause(50);
17371743
1738 EXPECT_NE(0, std::accumulate(spews.begin(), spews.end(), int{0},1744 EXPECT_NE(0, std::accumulate(spews.begin(), spews.end(), int{0},
1739 [](const int& acc, SpewMaster& spew) { return acc + spew.dataCnt(); }));1745 [](const int& acc, SpewMaster& spew) { return acc + spew.dataCnt(); }));
17401746
1741 g_spawn_command_line_sync("rm -rf " CMAKE_BINARY_DIR "/libual-proc", NULL, NULL, NULL, NULL);1747 g_spawn_command_line_sync("rm -rf " CMAKE_BINARY_DIR "/libual-proc", NULL, NULL, NULL, NULL);
1748
1749 ASSERT_TRUE(ubuntu_app_launch_observer_delete_app_paused(signal_increment, &paused_count));
1750 ASSERT_TRUE(ubuntu_app_launch_observer_delete_app_resumed(signal_increment, &resumed_count));
1742}1751}
17431752
1744TEST_F(LibUAL, OOMSet)1753TEST_F(LibUAL, OOMSet)

Subscribers

People subscribed via source and target branches