1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Lennart Poettering
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
26 #include "bus-message.h"
27 #include "bus-error.h"
28 #include "bus-kernel.h"
33 const char *interface,
39 _cleanup_close_ int bus_ref = -1;
40 _cleanup_free_ char *bus_name = NULL, *address = NULL;
41 _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
45 bus_ref = bus_kernel_create("deine-mutter", &bus_name);
46 if (bus_ref == -ENOENT)
49 assert_se(bus_ref >= 0);
51 address = strappend("kernel:path=", bus_name);
60 r = sd_bus_set_address(a, address);
63 r = sd_bus_set_address(b, address);
73 r = sd_bus_add_match(b, match, NULL, NULL);
77 r = sd_bus_emit_signal(a, path, interface, member, "s", arg0);
80 r = sd_bus_process(b, &m);
81 assert_se(r >= 0 && (good == !!m));
87 int main(int argc, char *argv[]) {
88 log_set_max_level(LOG_DEBUG);
90 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "", true);
91 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo'", true);
92 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo/tuut'", false);
93 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "interface='waldo.com'", true);
94 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "member='Piep'", true);
95 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "member='Pi_ep'", false);
96 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "arg0='foobar'", true);
97 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "arg0='foo_bar'", false);
98 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar'", true);
99 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo',interface='waldo.com',member='Piep',arg0='foobar2'", false);
101 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo'", true);
102 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar'", false);
103 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo'", false);
104 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/'", false);
105 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path='/foo/bar/waldo/quux'", false);
106 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo/bar/waldo'", true);
107 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo/bar'", true);
108 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/foo'", true);
109 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/'", true);
110 test_one("/foo/bar/waldo", "waldo.com", "Piep", "foobar", "path_namespace='/quux'", false);