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