mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 11:26:16 +01:00
gdbus-codegen: test --interface-info-{header,body}
This test is rudimentary but better than nothing.
This commit is contained in:
parent
d946bff480
commit
335a01ebe4
@ -487,16 +487,16 @@ gdbus_proxy_threads_SOURCES = $(gdbus_sessionbus_sources) gdbus-pro
|
||||
gdbus_proxy_unique_name_SOURCES = $(gdbus_sessionbus_sources) gdbus-proxy-unique-name.c
|
||||
gdbus_proxy_well_known_name_SOURCES = $(gdbus_sessionbus_sources) gdbus-proxy-well-known-name.c
|
||||
gdbus_test_codegen_SOURCES = $(gdbus_sessionbus_sources) gdbus-test-codegen.c
|
||||
nodist_gdbus_test_codegen_SOURCES = gdbus-test-codegen-generated.c gdbus-test-codegen-generated.h
|
||||
nodist_gdbus_test_codegen_SOURCES = gdbus-test-codegen-generated.c gdbus-test-codegen-generated.h gdbus-test-codegen-generated-interface-info.c gdbus-test-codegen-generated-interface-info.h
|
||||
gdbus_test_codegen_old_SOURCES = $(gdbus_sessionbus_sources) gdbus-test-codegen.c
|
||||
nodist_gdbus_test_codegen_old_SOURCES = gdbus-test-codegen-generated.c gdbus-test-codegen-generated.h
|
||||
nodist_gdbus_test_codegen_old_SOURCES = gdbus-test-codegen-generated.c gdbus-test-codegen-generated.h gdbus-test-codegen-generated-interface-info.c gdbus-test-codegen-generated-interface-info.h
|
||||
gdbus_test_codegen_old_CPPFLAGS = $(AM_CPPFLAGS) -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36
|
||||
gdbus_threading_SOURCES = $(gdbus_sessionbus_sources) gdbus-threading.c
|
||||
gmenumodel_SOURCES = $(gdbus_sessionbus_sources) gmenumodel.c
|
||||
gnotification_SOURCES = $(gdbus_sessionbus_sources) gnotification.c gnotification-server.h gnotification-server.c
|
||||
|
||||
BUILT_SOURCES += gdbus-test-codegen-generated.c gdbus-test-codegen-generated.h
|
||||
gdbus-test-codegen.o: gdbus-test-codegen-generated.h
|
||||
BUILT_SOURCES += gdbus-test-codegen-generated.c gdbus-test-codegen-generated.h gdbus-test-codegen-generated-interface-info.c gdbus-test-codegen-generated-interface-info.h
|
||||
gdbus-test-codegen.o: gdbus-test-codegen-generated.h gdbus-test-codegen-generated-interface-info.h
|
||||
gdbus-test-codegen-generated.h: test-codegen.xml Makefile $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen
|
||||
$(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
|
||||
UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
|
||||
@ -519,9 +519,41 @@ gdbus-test-codegen-generated.h: test-codegen.xml Makefile $(top_builddir)/gio/gd
|
||||
$(NULL)
|
||||
gdbus-test-codegen-generated.c: gdbus-test-codegen-generated.h
|
||||
@: # Generated as side-effect of .h
|
||||
gdbus-test-codegen-generated-interface-info.h: test-codegen.xml Makefile $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen
|
||||
$(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
|
||||
UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
|
||||
$(PYTHON) $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen \
|
||||
--interface-info-header \
|
||||
--annotate "org.project.Bar" Key1 Value1 \
|
||||
--annotate "org.project.Bar" org.gtk.GDBus.Internal Value2 \
|
||||
--annotate "org.project.Bar.HelloWorld()" Key3 Value3 \
|
||||
--annotate "org.project.Bar::TestSignal" Key4 Value4 \
|
||||
--annotate "org.project.Bar:ay" Key5 Value5 \
|
||||
--annotate "org.project.Bar.TestPrimitiveTypes()[val_int32]" Key6 Value6 \
|
||||
--annotate "org.project.Bar.TestPrimitiveTypes()[ret_uint32]" Key7 Value7 \
|
||||
--annotate "org.project.Bar::TestSignal[array_of_strings]" Key8 Value8 \
|
||||
--output $@ \
|
||||
$(srcdir)/test-codegen.xml \
|
||||
$(NULL)
|
||||
gdbus-test-codegen-generated-interface-info.c: test-codegen.xml Makefile $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen
|
||||
$(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
|
||||
UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
|
||||
$(PYTHON) $(top_builddir)/gio/gdbus-2.0/codegen/gdbus-codegen \
|
||||
--interface-info-body \
|
||||
--annotate "org.project.Bar" Key1 Value1 \
|
||||
--annotate "org.project.Bar" org.gtk.GDBus.Internal Value2 \
|
||||
--annotate "org.project.Bar.HelloWorld()" Key3 Value3 \
|
||||
--annotate "org.project.Bar::TestSignal" Key4 Value4 \
|
||||
--annotate "org.project.Bar:ay" Key5 Value5 \
|
||||
--annotate "org.project.Bar.TestPrimitiveTypes()[val_int32]" Key6 Value6 \
|
||||
--annotate "org.project.Bar.TestPrimitiveTypes()[ret_uint32]" Key7 Value7 \
|
||||
--annotate "org.project.Bar::TestSignal[array_of_strings]" Key8 Value8 \
|
||||
--output $@ \
|
||||
$(srcdir)/test-codegen.xml \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_DIST += test-codegen.xml
|
||||
CLEANFILES += gdbus-test-codegen-generated.[ch] gdbus-test-codegen-generated-doc-*.xml
|
||||
CLEANFILES += gdbus-test-codegen-generated.[ch] gdbus-test-codegen-generated-doc-*.xml gdbus-test-codegen-generated-interface-info.[ch]
|
||||
endif # OS_UNIX
|
||||
endif # HAVE_DBUS_DAEMON
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "gdbus-tests.h"
|
||||
|
||||
#include "gdbus-test-codegen-generated.h"
|
||||
#include "gdbus-test-codegen-generated-interface-info.h"
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
@ -2463,6 +2464,110 @@ test_deprecations (void)
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
static void
|
||||
assert_arg_infos_equal (GDBusArgInfo **a,
|
||||
GDBusArgInfo **b)
|
||||
{
|
||||
if (a == NULL)
|
||||
{
|
||||
g_assert_null (b);
|
||||
return;
|
||||
}
|
||||
|
||||
g_assert_nonnull (b);
|
||||
|
||||
for (; *a != NULL && *b != NULL; a++, b++)
|
||||
{
|
||||
g_assert_cmpstr ((*a)->name, ==, (*b)->name);
|
||||
g_assert_cmpstr ((*a)->signature, ==, (*b)->signature);
|
||||
}
|
||||
|
||||
g_assert_null (*a);
|
||||
g_assert_null (*b);
|
||||
}
|
||||
|
||||
static void
|
||||
assert_annotations_equal (GDBusAnnotationInfo **a,
|
||||
GDBusAnnotationInfo **b)
|
||||
{
|
||||
guint a_len = count_annotations (a);
|
||||
guint b_len = count_annotations (b);
|
||||
|
||||
g_assert_cmpuint (a_len, ==, b_len);
|
||||
|
||||
if (a == NULL || b == NULL)
|
||||
return;
|
||||
|
||||
for (; *a != NULL && *b != NULL; a++, b++)
|
||||
{
|
||||
g_assert_cmpstr ((*a)->key, ==, (*b)->key);
|
||||
g_assert_cmpstr ((*a)->value, ==, (*b)->value);
|
||||
assert_annotations_equal ((*a)->annotations, (*b)->annotations);
|
||||
}
|
||||
|
||||
g_assert_null (*a);
|
||||
g_assert_null (*b);
|
||||
}
|
||||
|
||||
/* Test that the GDBusInterfaceInfo structure generated by gdbus-codegen
|
||||
* --interface-info-body matches that generated by the other mode.
|
||||
*/
|
||||
static void
|
||||
test_standalone_interface_info (void)
|
||||
{
|
||||
GDBusInterfaceSkeleton *skel = G_DBUS_INTERFACE_SKELETON (foo_igen_bar_skeleton_new ());
|
||||
GDBusInterfaceInfo *skel_info = g_dbus_interface_skeleton_get_info (skel);
|
||||
const GDBusInterfaceInfo *slim_info = &org_project_bar_interface;
|
||||
gsize i;
|
||||
|
||||
g_assert_cmpstr (skel_info->name, ==, slim_info->name);
|
||||
|
||||
for (i = 0; skel_info->methods[i] != NULL; i++)
|
||||
{
|
||||
GDBusMethodInfo *skel_method = skel_info->methods[i];
|
||||
GDBusMethodInfo *slim_method = slim_info->methods[i];
|
||||
|
||||
g_assert_nonnull (slim_method);
|
||||
g_assert_cmpstr (skel_method->name, ==, slim_method->name);
|
||||
assert_arg_infos_equal (skel_method->in_args, slim_method->in_args);
|
||||
assert_arg_infos_equal (skel_method->out_args, slim_method->out_args);
|
||||
assert_annotations_equal (skel_method->annotations, slim_method->annotations);
|
||||
}
|
||||
g_assert_null (slim_info->methods[i]);
|
||||
|
||||
for (i = 0; skel_info->signals[i] != NULL; i++)
|
||||
{
|
||||
GDBusSignalInfo *skel_signal = skel_info->signals[i];
|
||||
GDBusSignalInfo *slim_signal = slim_info->signals[i];
|
||||
|
||||
g_assert_nonnull (slim_signal);
|
||||
g_assert_cmpstr (skel_signal->name, ==, slim_signal->name);
|
||||
assert_arg_infos_equal (skel_signal->args, slim_signal->args);
|
||||
assert_annotations_equal (skel_signal->annotations, slim_signal->annotations);
|
||||
}
|
||||
g_assert_null (slim_info->signals[i]);
|
||||
|
||||
for (i = 0; skel_info->properties[i] != NULL; i++)
|
||||
{
|
||||
GDBusPropertyInfo *skel_prop = skel_info->properties[i];
|
||||
GDBusPropertyInfo *slim_prop = slim_info->properties[i];
|
||||
|
||||
g_assert_nonnull (slim_prop);
|
||||
|
||||
g_assert_cmpstr (skel_prop->name, ==, slim_prop->name);
|
||||
g_assert_cmpstr (skel_prop->signature, ==, slim_prop->signature);
|
||||
g_assert_cmpuint (skel_prop->flags, ==, slim_prop->flags);
|
||||
assert_annotations_equal (skel_prop->annotations, slim_prop->annotations);
|
||||
}
|
||||
g_assert_null (slim_info->properties[i]);
|
||||
|
||||
assert_annotations_equal (skel_info->annotations, slim_info->annotations);
|
||||
|
||||
g_clear_object (&skel);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------------------------------------- */
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char *argv[])
|
||||
@ -2475,6 +2580,7 @@ main (int argc,
|
||||
g_test_add_func ("/gdbus/codegen/property-naming", test_property_naming);
|
||||
g_test_add_func ("/gdbus/codegen/autocleanups", test_autocleanups);
|
||||
g_test_add_func ("/gdbus/codegen/deprecations", test_deprecations);
|
||||
g_test_add_func ("/gdbus/codegen/standalone-interface-info", test_standalone_interface_info);
|
||||
|
||||
return session_bus_run ();
|
||||
}
|
||||
|
@ -171,6 +171,16 @@ if host_machine.system() != 'windows'
|
||||
# Test programs that need to bring up a session bus (requires dbus-daemon)
|
||||
have_dbus_daemon = find_program('dbus-daemon', required : false).found()
|
||||
if have_dbus_daemon
|
||||
annotate_args = [
|
||||
'--annotate', 'org.project.Bar', 'Key1', 'Value1',
|
||||
'--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
|
||||
'--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
|
||||
'--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
|
||||
'--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
|
||||
'--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
|
||||
'--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
|
||||
'--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
|
||||
]
|
||||
# Generate gdbus-test-codegen-generated.{c,h}
|
||||
gdbus_test_codegen_generated = custom_target('gdbus-test-codegen-generated',
|
||||
input : ['test-codegen.xml'],
|
||||
@ -185,16 +195,30 @@ if host_machine.system() != 'windows'
|
||||
'--c-generate-autocleanup', 'all',
|
||||
'--c-namespace', 'Foo_iGen',
|
||||
'--generate-docbook', 'gdbus-test-codegen-generated-doc',
|
||||
'--annotate', 'org.project.Bar', 'Key1', 'Value1',
|
||||
'--annotate', 'org.project.Bar', 'org.gtk.GDBus.Internal', 'Value2',
|
||||
'--annotate', 'org.project.Bar.HelloWorld()', 'Key3', 'Value3',
|
||||
'--annotate', 'org.project.Bar::TestSignal', 'Key4', 'Value4',
|
||||
'--annotate', 'org.project.Bar:ay', 'Key5', 'Value5',
|
||||
'--annotate', 'org.project.Bar.TestPrimitiveTypes()[val_int32]', 'Key6', 'Value6',
|
||||
'--annotate', 'org.project.Bar.TestPrimitiveTypes()[ret_uint32]', 'Key7', 'Value7',
|
||||
'--annotate', 'org.project.Bar::TestSignal[array_of_strings]', 'Key8', 'Value8',
|
||||
annotate_args,
|
||||
'@INPUT@'])
|
||||
|
||||
gdbus_test_codegen_generated_interface_info = [
|
||||
custom_target('gdbus-test-codegen-generated-interface-info-h',
|
||||
input : ['test-codegen.xml'],
|
||||
output : ['gdbus-test-codegen-generated-interface-info.h'],
|
||||
depend_files : gdbus_codegen_built_files,
|
||||
command : [python, gdbus_codegen,
|
||||
'--interface-info-header',
|
||||
annotate_args,
|
||||
'--output', '@OUTPUT@',
|
||||
'@INPUT@']),
|
||||
custom_target('gdbus-test-codegen-generated-interface-info-c',
|
||||
input : ['test-codegen.xml'],
|
||||
output : ['gdbus-test-codegen-generated-interface-info.c'],
|
||||
depend_files : gdbus_codegen_built_files,
|
||||
command : [python, gdbus_codegen,
|
||||
'--interface-info-body',
|
||||
annotate_args,
|
||||
'--output', '@OUTPUT@',
|
||||
'@INPUT@']),
|
||||
]
|
||||
|
||||
extra_sources = ['gdbus-sessionbus.c', 'gdbus-tests.c']
|
||||
|
||||
gio_tests += {
|
||||
@ -224,7 +248,7 @@ if host_machine.system() != 'windows'
|
||||
'gdbus-proxy-unique-name' : {'extra_sources' : extra_sources},
|
||||
'gdbus-proxy-well-known-name' : {'extra_sources' : extra_sources},
|
||||
'gdbus-test-codegen' : {
|
||||
'extra_sources' : [extra_sources, gdbus_test_codegen_generated],
|
||||
'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
|
||||
},
|
||||
'gdbus-threading' : {
|
||||
'extra_sources' : extra_sources,
|
||||
@ -239,7 +263,7 @@ if host_machine.system() != 'windows'
|
||||
},
|
||||
'gdbus-test-codegen-old' : {
|
||||
'source' : 'gdbus-test-codegen.c',
|
||||
'extra_sources' : [extra_sources, gdbus_test_codegen_generated],
|
||||
'extra_sources' : [extra_sources, gdbus_test_codegen_generated, gdbus_test_codegen_generated_interface_info],
|
||||
'c_args' : ['-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_36',
|
||||
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_36'],
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user