2
* Copyright © 2015 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authored by: Alexandros Frantzis <alexandros.frantzis@canonical.com>
31
std::string run_command(std::string const& cmd)
33
auto fp = ::popen(cmd.c_str(), "r");
35
throw std::runtime_error("Failed to execute command: " + cmd);
42
auto nread = fread(buffer, 1, 64, fp);
43
reply.append(buffer, nread);
53
usc::test::DBusBus::DBusBus()
56
auto launch = run_command("dbus-daemon --session --print-address=1 --print-pid=1 --fork");
57
std::stringstream ss{launch};
59
std::getline(ss, address_);
63
throw std::runtime_error("Failed to get dbus bus address");
66
throw std::runtime_error("Failed to get dbus bus pid");
69
usc::test::DBusBus::~DBusBus()
74
std::string usc::test::DBusBus::address()