[Spice-devel] [PATCH spice-gtk v4 26/29] test-cd-emu: Test attach/detach emulated device

Christophe de Dinechin christophe.de.dinechin at gmail.com
Tue Aug 27 10:46:37 UTC 2019


Frediano Ziglio writes:

>>
>> Frediano Ziglio writes:
>>
>> > Mock some usb-backend functions to be able to simulate device
>> > attachment and detachment.
>> > +
>> > +    // this it's the correct sequence to free session!
>> > +    // g_object_unref is not enough, causing wrong reference countings
>> > +    spice_session_disconnect(session);
>> > +    g_object_unref(session);
>> > +    while (g_main_context_iteration(NULL, FALSE)) {
>> > +        continue;
>> > +    }
>>
>> This looks so peculiar that it might be worth putting in its
>> own function, in order to facilitate reuse.
>>
>
> I was thinking about a DoEvents function in memory of the good old VB!
> (well, do_events in C).
> Getting these lines right was not really easy! Calling g_object_unref
> directly causes multiple crashes. The deallocations are queued in GLib.

Is the problem specific to this test? If so, might be worth explaining
why, otherwise someone might break it in the future.

>
>> > +
>> > +    g_assert_cmpint(gobjects_allocated, ==, 0);
>> > +}
>> > +
>> >  static void
>> >  write_test_iso(void)
>> >  {
>> > @@ -87,6 +234,8 @@ int main(int argc, char* argv[])
>> >
>> >      g_test_add_data_func("/cd-emu/simple", GUINT_TO_POINTER(1), multiple);
>> >      g_test_add_data_func("/cd-emu/multiple", GUINT_TO_POINTER(128),
>> >      multiple);
>> > +    g_test_add_data_func("/cd-emu/attach_no_auto", GUINT_TO_POINTER(0),
>> > attach);
>> > +    g_test_add_data_func("/cd-emu/attach_auto", GUINT_TO_POINTER(1),
>> > attach);
>> >
>> >      return g_test_run();
>> >  }
>>
>
> Frediano


--
Cheers,
Christophe de Dinechin (IRC c3d)


More information about the Spice-devel mailing list