summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-08-27 17:34:39 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-08-27 19:49:09 +0200
commit11791cdeccd3e01f84dff614d344d4bda5d40a54 (patch)
treed98f037a17731fffd661c998480e174eb58b20ef
parent35e528018f315798d3bffcb592b32a0d8f5162bd (diff)
downloadsystemd-11791cdeccd3e01f84dff614d344d4bda5d40a54.tar.gz
test-bus-vtable: also print introspection for the fallback vtable
This doesn't really test anything, it's just a trivial test that we get the expected output for a fallback vtable.
-rw-r--r--src/libsystemd/sd-bus/test-bus-vtable.c26
-rw-r--r--src/libsystemd/sd-bus/test-vtable-data.h2
2 files changed, 25 insertions, 3 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-vtable.c b/src/libsystemd/sd-bus/test-bus-vtable.c
index d69ca6ac97..b6350027dd 100644
--- a/src/libsystemd/sd-bus/test-bus-vtable.c
+++ b/src/libsystemd/sd-bus/test-bus-vtable.c
@@ -19,9 +19,24 @@
#define DEFAULT_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
+static struct context c = {};
+static int happy_finder_object = 0;
+
+static int happy_finder(sd_bus *bus, const char *path, const char *interface, void *userdata, void **found, sd_bus_error *error) {
+ assert(userdata);
+ assert(userdata == &c);
+
+#ifndef __cplusplus
+ log_info("%s called", __func__);
+#endif
+
+ happy_finder_object++;
+ *found = &happy_finder_object;
+ return 1; /* found */
+}
+
static void test_vtable(void) {
sd_bus *bus = NULL;
- struct context c = {};
int r;
assert(sd_bus_new(&bus) >= 0);
@@ -32,16 +47,23 @@ static void test_vtable(void) {
assert(sd_bus_add_object_vtable(bus, NULL, "/foo", "org.freedesktop.systemd.testVtable221",
(const sd_bus_vtable *)vtable_format_221, &c) >= 0);
+ assert(sd_bus_add_fallback_vtable(bus, NULL, "/fallback", "org.freedesktop.systemd.testVtable2", test_vtable_2, happy_finder, &c) >= 0);
+
assert(sd_bus_set_address(bus, DEFAULT_BUS_PATH) >= 0);
r = sd_bus_start(bus);
assert(r == 0 || /* success */
r == -ENOENT /* dbus is inactive */ );
#ifndef __cplusplus
- _cleanup_free_ char *s = NULL;
+ _cleanup_free_ char *s, *s2;
assert_se(introspect_path(bus, "/foo", NULL, false, true, NULL, &s, NULL) == 1);
fputs(s, stdout);
+
+ assert_se(introspect_path(bus, "/fallback", NULL, false, true, NULL, &s2, NULL) == 1);
+ fputs(s2, stdout);
+
+ assert_se(happy_finder_object == 1);
#endif
sd_bus_unref(bus);
diff --git a/src/libsystemd/sd-bus/test-vtable-data.h b/src/libsystemd/sd-bus/test-vtable-data.h
index 333dbd5b12..bc89893814 100644
--- a/src/libsystemd/sd-bus/test-vtable-data.h
+++ b/src/libsystemd/sd-bus/test-vtable-data.h
@@ -42,7 +42,7 @@ static const sd_bus_vtable test_vtable_1[] = {
static const sd_bus_vtable test_vtable_2[] = {
SD_BUS_VTABLE_START(0),
- SD_BUS_METHOD("AlterSomething", "s", "s", handler, 0),
+ SD_BUS_METHOD("AlterSomething", "s", "s", handler, SD_BUS_VTABLE_UNPRIVILEGED),
SD_BUS_METHOD("Exit", "", "", handler, 0),
SD_BUS_METHOD_WITH_OFFSET("AlterSomething2", "s", "s", handler, 200, 0),
SD_BUS_METHOD_WITH_OFFSET("Exit2", "", "", handler, 200, 0),