From 42c28b9424b6ef8a0021b124773e171dd5defadd Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Thu, 10 Apr 2014 09:11:12 +0200 Subject: SBUS: Generate introspection from the interface meta structure https://fedorahosted.org/sssd/ticket/2234 This patch generates the introspection data from the sbus interface meta structure. The generated XML conforms to http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format The XML description of the interface also always includes the org.freedesktop.DBus.Introspectable interface, which this patch also allows in the policy settings. --- src/tests/sbus_tests.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) (limited to 'src/tests/sbus_tests.c') diff --git a/src/tests/sbus_tests.c b/src/tests/sbus_tests.c index e4cab454d..194ba60ef 100644 --- a/src/tests/sbus_tests.c +++ b/src/tests/sbus_tests.c @@ -44,6 +44,23 @@ #define PILOT_BLINK "Blink" #define PILOT_EAT "Eat" +#define PILOT_IFACE_INTROSPECT \ + "\n" \ + "\n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + " \n" \ + "\n" + /* our vtable */ struct pilot_vtable { struct sbus_vtable vtable; @@ -276,6 +293,37 @@ START_TEST(test_request_parse_bad_args) } END_TEST +START_TEST(test_introspection) +{ + TALLOC_CTX *ctx; + DBusConnection *client; + DBusError error = DBUS_ERROR_INIT; + DBusMessage *reply; + char *xml; + + ctx = talloc_new(NULL); + client = test_dbus_setup_mock(ctx, NULL, pilot_test_server_init, NULL); + + reply = test_dbus_call_sync(client, + "/test/leela", + DBUS_INTROSPECT_INTERFACE, + DBUS_INTROSPECT_METHOD, + &error, + DBUS_TYPE_INVALID); /* bad agruments */ + + ck_assert(reply != NULL); + ck_assert(!dbus_error_is_set(&error)); + ck_assert(dbus_message_get_args(reply, NULL, + DBUS_TYPE_STRING, &xml, + DBUS_TYPE_INVALID)); + ck_assert_str_eq(PILOT_IFACE_INTROSPECT, xml); + + dbus_message_unref(reply); + + talloc_free(ctx); +} +END_TEST + TCase *create_sbus_tests(void) { TCase *tc = tcase_create("tests"); @@ -283,6 +331,7 @@ TCase *create_sbus_tests(void) tcase_add_test(tc, test_raw_handler); tcase_add_test(tc, test_request_parse_ok); tcase_add_test(tc, test_request_parse_bad_args); + tcase_add_test(tc, test_introspection); return tc; } -- cgit