[Spice-devel] [PATCH spice-server] test-leaks: Test that creating and destroying spicevmc does not leak
Christophe Fergeau
cfergeau at redhat.com
Wed Mar 8 12:06:01 UTC 2017
On Tue, Mar 07, 2017 at 04:41:53PM +0000, Frediano Ziglio wrote:
> Add and remove some vmc device to check for leaking.
> These combination assure that currently implemented type
> of devices (webdav, usb and generic) are checked.
In general, I think having a test case in test-leaks should be our last
option. In my opinion, it makes more sense to have this kind of tests
grouped together with other spicevmc related tests which we can then
run under valgrind.
In this specific case, maybe it would make sense to combine this somehow
with test-vdagent, potentially renaming it to test-spicevmc?
Acked-by: Christophe Fergeau <cfergeau at redhat.com>
Christophe
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/tests/test-leaks.c | 67 +++++++++++++++++++++++++++++++++++++++++++++--
> 1 file changed, 65 insertions(+), 2 deletions(-)
>
> diff --git a/server/tests/test-leaks.c b/server/tests/test-leaks.c
> index e07e3c6..c9bc996 100644
> --- a/server/tests/test-leaks.c
> +++ b/server/tests/test-leaks.c
> @@ -20,8 +20,9 @@
>
> #include "test-glib-compat.h"
> #include "basic-event-loop.h"
> +#include "test-display-base.h"
>
> -static void leaks(void)
> +static void server_leaks(void)
> {
> int result;
> SpiceCoreInterface *core;
> @@ -45,11 +46,73 @@ static void leaks(void)
> basic_event_loop_destroy();
> }
>
> +static int vmc_write(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
> + SPICE_GNUC_UNUSED const uint8_t *buf,
> + int len)
> +{
> + return len;
> +}
> +
> +static int vmc_read(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
> + SPICE_GNUC_UNUSED uint8_t *buf,
> + SPICE_GNUC_UNUSED int len)
> +{
> + return 0;
> +}
> +
> +static void vmc_state(SPICE_GNUC_UNUSED SpiceCharDeviceInstance *sin,
> + SPICE_GNUC_UNUSED int connected)
> +{
> +}
> +
> +static SpiceCharDeviceInterface vmc_interface = {
> + .base.type = SPICE_INTERFACE_CHAR_DEVICE,
> + .base.description = "test spice virtual channel char device",
> + .base.major_version = SPICE_INTERFACE_CHAR_DEVICE_MAJOR,
> + .base.minor_version = SPICE_INTERFACE_CHAR_DEVICE_MINOR,
> + .state = vmc_state,
> + .write = vmc_write,
> + .read = vmc_read,
> +};
> +
> +static SpiceCharDeviceInstance vmc_instance;
> +
> +static void vmc_leaks(void)
> +{
> + SpiceCoreInterface *core = basic_event_loop_init();
> + Test *test = test_new(core);
> + int status;
> +
> + vmc_instance.subtype = "usbredir";
> + vmc_instance.base.sif = &vmc_interface.base;
> + spice_server_add_interface(test->server, &vmc_instance.base);
> + status = spice_server_remove_interface(&vmc_instance.base);
> + g_assert_cmpint(status, ==, 0);
> +
> + vmc_instance.subtype = "port";
> + vmc_instance.portname = "org.spice-space.webdav.0";
> + vmc_instance.base.sif = &vmc_interface.base;
> + spice_server_add_interface(test->server, &vmc_instance.base);
> + status = spice_server_remove_interface(&vmc_instance.base);
> + g_assert_cmpint(status, ==, 0);
> +
> + vmc_instance.subtype = "port";
> + vmc_instance.portname = "default_port";
> + vmc_instance.base.sif = &vmc_interface.base;
> + spice_server_add_interface(test->server, &vmc_instance.base);
> + status = spice_server_remove_interface(&vmc_instance.base);
> + g_assert_cmpint(status, ==, 0);
> +
> + test_destroy(test);
> + basic_event_loop_destroy();
> +}
> +
> int main(int argc, char *argv[])
> {
> g_test_init(&argc, &argv, NULL);
>
> - g_test_add_func("/server/server leaks", leaks);
> + g_test_add_func("/server/server leaks", server_leaks);
> + g_test_add_func("/server/vmc leaks", vmc_leaks);
>
> return g_test_run();
> }
> --
> 2.9.3
>
> _______________________________________________
> Spice-devel mailing list
> Spice-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170308/9d024ca7/attachment.sig>
More information about the Spice-devel
mailing list