Debian Codegraph @

src/libsystemd/sd-bus/test-bus-introspect.c

raw
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include "bus-introspect.h"
4 #include "log.h"
5 #include "test-vtable-data.h"
6 #include "tests.h"
7
8 static void test_manual_introspection_one(const sd_bus_vtable vtable[]) {
9 BusIntrospect intro = {};
10 _cleanup_free_ char *s = NULL;
11
12 log_info("/* %s */", __func__);
13
14 assert_se(introspect_begin(&intro, false) >= 0);
15
16 assert_se(introspect_write_interface(&intro, "org.foo", vtable) >= 0);
17 /* write again to check if output looks OK for a different interface */
18 assert_se(introspect_write_interface(&intro, "org.foo.bar", vtable) >= 0);
19 assert_se(introspect_finish(&intro, &s) == 0);
20
21 fputs(s, stdout);
22 fputs("\n", stdout);
23 }
24
25 TEST(manual_introspection) {
26 test_manual_introspection_one(test_vtable_1);
27 test_manual_introspection_one(test_vtable_2);
28 test_manual_introspection_one(test_vtable_deprecated);
29 test_manual_introspection_one((const sd_bus_vtable *) vtable_format_221);
30 }
31
32 DEFINE_TEST_MAIN(LOG_DEBUG);