diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-09-30 10:30:45 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-10-01 10:15:54 +0200 |
commit | f9c8c01fcc6f52ecf68607cccae06ba22746beb9 (patch) | |
tree | 07665b04b2c000a29b88e0fd8dfb67f5373cc0b6 /src/libsystemd/sd-bus/test-bus-track.c | |
parent | Merge pull request #10138 from yuwata/test-check-container (diff) | |
download | systemd-f9c8c01fcc6f52ecf68607cccae06ba22746beb9.tar.xz systemd-f9c8c01fcc6f52ecf68607cccae06ba22746beb9.zip |
test: try system bus if user bus cannot be opened
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-track.c')
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-track.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-track.c b/src/libsystemd/sd-bus/test-bus-track.c index a2782cd1d5..68a0010368 100644 --- a/src/libsystemd/sd-bus/test-bus-track.c +++ b/src/libsystemd/sd-bus/test-bus-track.c @@ -45,6 +45,7 @@ int main(int argc, char *argv[]) { _cleanup_(sd_event_unrefp) sd_event *event = NULL; _cleanup_(sd_bus_track_unrefp) sd_bus_track *x = NULL, *y = NULL; _cleanup_(sd_bus_unrefp) sd_bus *a = NULL, *b = NULL; + bool use_system_bus = false; const char *unique; int r; @@ -54,14 +55,21 @@ int main(int argc, char *argv[]) { assert_se(r >= 0); r = sd_bus_open_user(&a); - if (IN_SET(r, -ECONNREFUSED, -ENOENT)) - return log_tests_skipped("Failed to connect to bus"); + if (IN_SET(r, -ECONNREFUSED, -ENOENT)) { + r = sd_bus_open_system(&a); + if (IN_SET(r, -ECONNREFUSED, -ENOENT)) + return log_tests_skipped("Failed to connect to bus"); + use_system_bus = true; + } assert_se(r >= 0); r = sd_bus_attach_event(a, event, SD_EVENT_PRIORITY_NORMAL); assert_se(r >= 0); - r = sd_bus_open_user(&b); + if (use_system_bus) + r = sd_bus_open_system(&b); + else + r = sd_bus_open_user(&b); assert_se(r >= 0); r = sd_bus_attach_event(b, event, SD_EVENT_PRIORITY_NORMAL); |