summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-bus/test-bus-vtable.c
diff options
context:
space:
mode:
authorGiacinto Cifelli <gciofono@gmail.com>2019-01-08 12:14:37 +0100
committerGiacinto Cifelli <gciofono@gmail.com>2019-02-26 12:55:02 +0100
commit856ad2a86bd9b3e264a090fcf4b0d05bfaa91030 (patch)
tree478ab7fafbe63489b5238452bc0a9e48c55d5f89 /src/libsystemd/sd-bus/test-bus-vtable.c
parentMerge pull request #11352 from yuwata/rfe-11348 (diff)
downloadsystemd-856ad2a86bd9b3e264a090fcf4b0d05bfaa91030.tar.xz
systemd-856ad2a86bd9b3e264a090fcf4b0d05bfaa91030.zip
sd-bus: add methods and signals parameter names. Fixes: #1564
Diffstat (limited to 'src/libsystemd/sd-bus/test-bus-vtable.c')
-rw-r--r--src/libsystemd/sd-bus/test-bus-vtable.c65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/libsystemd/sd-bus/test-bus-vtable.c b/src/libsystemd/sd-bus/test-bus-vtable.c
index fd9ad81217..b278094fad 100644
--- a/src/libsystemd/sd-bus/test-bus-vtable.c
+++ b/src/libsystemd/sd-bus/test-bus-vtable.c
@@ -39,6 +39,10 @@ static const sd_bus_vtable vtable[] = {
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),
+ SD_BUS_METHOD_WITH_NAMES_OFFSET("AlterSomething3", "so", SD_BUS_PARAM(string) SD_BUS_PARAM(path),
+ "s", SD_BUS_PARAM(returnstring), handler, 200, 0),
+ SD_BUS_METHOD_WITH_NAMES("Exit3", "bx", SD_BUS_PARAM(with_confirmation) SD_BUS_PARAM(after_msec),
+ "bb", SD_BUS_PARAM(accepted) SD_BUS_PARAM(scheduled), handler, 0),
SD_BUS_PROPERTY("Value", "s", value_handler, 10, SD_BUS_VTABLE_PROPERTY_EMITS_CHANGE),
SD_BUS_PROPERTY("Value2", "s", value_handler, 10, SD_BUS_VTABLE_PROPERTY_EMITS_INVALIDATION),
SD_BUS_PROPERTY("Value3", "s", value_handler, 10, SD_BUS_VTABLE_PROPERTY_CONST),
@@ -53,9 +57,68 @@ static const sd_bus_vtable vtable[] = {
SD_BUS_METHOD("NoOperation", NULL, NULL, NULL, 0),
SD_BUS_SIGNAL("DummySignal", "b", 0),
SD_BUS_SIGNAL("DummySignal2", "so", 0),
+ SD_BUS_SIGNAL_WITH_NAMES("DummySignal3", "so", SD_BUS_PARAM(string) SD_BUS_PARAM(path), 0),
SD_BUS_VTABLE_END
};
+struct sd_bus_vtable_original {
+ uint8_t type:8;
+ uint64_t flags:56;
+ union {
+ struct {
+ size_t element_size;
+ } start;
+ struct {
+ const char *member;
+ const char *signature;
+ const char *result;
+ sd_bus_message_handler_t handler;
+ size_t offset;
+ } method;
+ struct {
+ const char *member;
+ const char *signature;
+ } signal;
+ struct {
+ const char *member;
+ const char *signature;
+ sd_bus_property_get_t get;
+ sd_bus_property_set_t set;
+ size_t offset;
+ } property;
+ } x;
+};
+
+static const struct sd_bus_vtable_original vtable_format_original[] = {
+ {
+ .type = _SD_BUS_VTABLE_START,
+ .flags = 0,
+ .x = {
+ .start = {
+ .element_size = sizeof(struct sd_bus_vtable_original)
+ },
+ },
+ },
+ {
+ .type = _SD_BUS_VTABLE_METHOD,
+ .flags = 0,
+ .x = {
+ .method = {
+ .member = "Exit",
+ .signature = "",
+ .result = "",
+ .handler = handler,
+ .offset = 0,
+ },
+ },
+ },
+ {
+ .type = _SD_BUS_VTABLE_END,
+ .flags = 0,
+ .x = { { 0 } },
+ }
+};
+
static void test_vtable(void) {
sd_bus *bus = NULL;
struct context c = {};
@@ -65,6 +128,8 @@ static void test_vtable(void) {
assert(sd_bus_add_object_vtable(bus, NULL, "/foo", "org.freedesktop.systemd.testVtable", vtable, &c) >= 0);
assert(sd_bus_add_object_vtable(bus, NULL, "/foo", "org.freedesktop.systemd.testVtable2", vtable, &c) >= 0);
+ /* the cast on the line below is needed to test with the old version of the table */
+ assert(sd_bus_add_object_vtable(bus, NULL, "/foo", "org.freedesktop.systemd.testVtableOriginal", (const sd_bus_vtable *)vtable_format_original, &c) >= 0);
assert(sd_bus_set_address(bus, DEFAULT_BUS_PATH) >= 0);
r = sd_bus_start(bus);