~morphis/aethercast/enable-arm64-builds

« back to all changes in this revision

Viewing changes to tests/common/glibhelpers.cpp

  • Committer: Tarmac
  • Author(s): Simon Fels
  • Date: 2016-02-04 06:38:31 UTC
  • mfrom: (119.1.65 trunk)
  • Revision ID: tarmac-20160204063831-b6q9o8ktznevvd8x
Add a network manager implementation to use the DBus interface of wpa-supplicant.

Approved by PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2016 Canonical, Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License version 3, as published
 
6
 * by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
10
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
11
 * PURPOSE.  See the GNU General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 */
 
17
 
 
18
#include <mcs/keep_alive.h>
 
19
 
 
20
#include "glibhelpers.h"
 
21
 
 
22
namespace mcs {
 
23
namespace testing {
 
24
 
 
25
void RunMainLoop(const std::chrono::seconds &seconds) {
 
26
    std::shared_ptr<GMainLoop> loop(g_main_loop_new(g_main_context_default(), false), &g_main_loop_unref);
 
27
    g_timeout_add_seconds(seconds.count(), [](gpointer user_data) {
 
28
        auto loop = static_cast<mcs::SharedKeepAlive<GMainLoop>*>(user_data)->ShouldDie();
 
29
        g_main_loop_quit(loop.get());
 
30
        return FALSE;
 
31
    }, new mcs::SharedKeepAlive<GMainLoop>{loop});
 
32
    g_main_loop_run(loop.get());
 
33
}
 
34
 
 
35
void RunMainLoopIteration() {
 
36
    std::shared_ptr<GMainLoop> loop(g_main_loop_new(g_main_context_default(), false), &g_main_loop_unref);
 
37
    auto context = g_main_loop_get_context(loop.get());
 
38
    g_main_context_iteration(context, TRUE);
 
39
}
 
40
 
 
41
 
 
42
} // namespace testing
 
43
} // namespace mcs