chiark / gitweb /
gpt-auto-generator: skip nonexistent devices
[elogind.git] / src / libsystemd-bus / test-bus-kernel-bloom.c
index 02d9a98be9e8b38fcd1f3703da502e0f4e229d41..0ecad18f45f2e32b0892158d033f693b53c585b5 100644 (file)
@@ -26,6 +26,7 @@
 #include "bus-message.h"
 #include "bus-error.h"
 #include "bus-kernel.h"
+#include "bus-util.h"
 
 static void test_one(
                 const char *path,
@@ -36,12 +37,14 @@ static void test_one(
                 bool good) {
 
         _cleanup_close_ int bus_ref = -1;
-        _cleanup_free_ char *bus_name = NULL, *address = NULL;
+        _cleanup_free_ char *name = NULL, *bus_name = NULL, *address = NULL;
         _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
         sd_bus *a, *b;
         int r;
 
-        bus_ref = bus_kernel_create("deine-mutter", &bus_name);
+        assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
+
+        bus_ref = bus_kernel_create_bus(name, false, &bus_name);
         if (bus_ref == -ENOENT)
                 exit(EXIT_TEST_SKIP);
 
@@ -68,9 +71,11 @@ static void test_one(
         r = sd_bus_start(b);
         assert_se(r >= 0);
 
+        log_debug("match");
         r = sd_bus_add_match(b, match, NULL, NULL);
         assert_se(r >= 0);
 
+        log_debug("signal");
         r = sd_bus_emit_signal(a, path, interface, member, "s", arg0);
         assert_se(r >= 0);
 
@@ -95,5 +100,16 @@ int main(int argc, char *argv[]) {
         test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar'", true);
         test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar2'", false);
 
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo/quux'", false);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo/bar/waldo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo/bar'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/'", true);
+        test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/quux'", false);
+
         return 0;
 }