[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:11:30 UTC 2019


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.

> +
> +    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();
>  }


--
Cheers,
Christophe de Dinechin (IRC c3d)


More information about the Spice-devel mailing list