]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/libsystemd/sd-bus/test-bus-proxy.c
Merge pull request #2495 from heftig/master
[thirdparty/systemd.git] / src / libsystemd / sd-bus / test-bus-proxy.c
index 369c2f331cd9edf5bf337291b5940a345a3b6bf1..45d0a5ffce6acdaba64889755b3da5983c9c5887 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
 #include <fcntl.h>
 #include <stdlib.h>
 
-#include "util.h"
-#include "log.h"
-
 #include "sd-bus.h"
+
+#include "alloc-util.h"
+#include "bus-dump.h"
 #include "bus-kernel.h"
 #include "bus-util.h"
-#include "bus-dump.h"
+#include "log.h"
+#include "util.h"
 
 typedef struct {
         const char *sender;
@@ -52,8 +51,10 @@ static int test_proxy_acquired(sd_bus_message *m, void *userdata, sd_bus_error *
 }
 
 static void test_proxy_matched(void) {
-        _cleanup_bus_flush_close_unref_ sd_bus *a = NULL;
+        _cleanup_(sd_bus_flush_close_unrefp) sd_bus *a = NULL;
+        _cleanup_free_ char *matchstr = NULL;
         TestProxyMatch match = {};
+        const char *me;
         int r;
 
         /* open bus 'a' */
@@ -70,10 +71,17 @@ static void test_proxy_matched(void) {
         r = sd_bus_start(a);
         assert_se(r >= 0);
 
-        r = sd_bus_add_match(a, NULL,
-                             "type='signal',"
-                             "member='NameAcquired'",
-                             test_proxy_acquired, &match);
+        r = sd_bus_get_unique_name(a, &me);
+        assert_se(r >= 0);
+
+        matchstr = strjoin("type='signal',"
+                           "member='NameAcquired',"
+                           "destination='",
+                           me,
+                           "'",
+                           NULL);
+        assert_se(matchstr);
+        r = sd_bus_add_match(a, NULL, matchstr, test_proxy_acquired, &match);
         assert_se(r >= 0);
 
         r = sd_bus_get_unique_name(a, &match.sender);