Skip to content

Commit

Permalink
test-server: test complex signatures as well
Browse files Browse the repository at this point in the history
  • Loading branch information
mrc0mmand committed May 2, 2022
1 parent 6463da0 commit fbbeed2
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/dfuzzer-test-server.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ static const gchar introspection_xml[] =
" <method name='df_variant_crash'>"
" <arg type='v' name='variant' direction='in'/>"
" </method>"
" <method name='df_complex_sig_1'>"
" <arg type='i' name='in1' direction='in'/>"
" <arg type='u' name='in2' direction='in'/>"
" <arg type='s' name='in3' direction='in'/>"
" <arg type='a{ss}' name='what' direction='in'/>"
" <arg type='a(uiyo)' name='also_what' direction='in'/>"
" <arg type='s' name='response' direction='out'/>"
" </method>"
" </interface>"
"</node>";

Expand All @@ -71,10 +79,11 @@ static void handle_method_call(
const gchar *method_name, GVariant *parameters,
GDBusMethodInvocation *invocation, gpointer user_data)
{
_cleanup_(g_freep) gchar *response = NULL;

g_printf("->[handle_method_call]\n");

if (g_strcmp0(method_name, "df_hello") == 0) {
_cleanup_(g_freep) gchar *response = NULL;
gchar *msg;
int n;

Expand All @@ -99,6 +108,22 @@ static void handle_method_call(
pause();
else if (g_strcmp0(method_name, "df_noreply") == 0)
return;
else if (g_strcmp0(method_name, "df_complex_sig_1") == 0) {
gchar *str = NULL;
unsigned u;
int i;

g_variant_get(parameters, "(iu&s@a{ss}@a(uiyo))", &i, &u, &str, NULL, NULL);
if (strlen(str) <= 0) {
g_printf("Got unexpected data for method %s\n", method_name);
abort();
}

g_printf("%s: string size: %zu\n", method_name, strlen(str));

response = g_strdup_printf("%s", str);
g_dbus_method_invocation_return_value(invocation, g_variant_new("(s)", response));
}
}

// Virtual table for handling properties and method calls for a D-Bus interface.
Expand Down

0 comments on commit fbbeed2

Please sign in to comment.