Re: [Spice-devel] [PATCH spice-server 2/8] test-stream-device: Test batched multiple messages

2018-02-23 Thread Christophe Fergeau
Ok, some of the same comments from previous patch apply.

Acked-by: Christophe Fergeau 

On Sun, Feb 18, 2018 at 06:58:08PM +, Frediano Ziglio wrote:
> Test all batched (send together) messages are handled correctly
> and device is not stuck.
> 
> Signed-off-by: Frediano Ziglio 
> ---
>  server/tests/test-stream-device.c | 36 
>  1 file changed, 36 insertions(+)
> 
> diff --git a/server/tests/test-stream-device.c 
> b/server/tests/test-stream-device.c
> index edd618e2..72b3f382 100644
> --- a/server/tests/test-stream-device.c
> +++ b/server/tests/test-stream-device.c
> @@ -215,12 +215,48 @@ static void test_stream_device_unfinished(void)
>  basic_event_loop_destroy();
>  }
>  
> +// check if sending multiple messages cause stall
> +static void test_stream_device_multiple(void)
> +{
> +uint8_t *p = message;
> +SpiceCoreInterface *core = basic_event_loop_init();
> +Test *test = test_new(core);
> +
> +pos = 0;
> +message_sizes_curr = message_sizes;
> +message_sizes_end = message_sizes;
> +
> +// add some messages into device buffer
> +p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG);
> +p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG);
> +p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG);
> +*message_sizes_end = p - message;
> +++message_sizes_end;
> +
> +vmc_instance.base.sif = _interface.base;
> +spice_server_add_interface(test->server, _instance.base);
> +
> +// we need to open the device and kick the start
> +// the alarm is to avoid program to stuck
> +alarm(5);
> +spice_server_port_event(_instance, SPICE_PORT_EVENT_OPENED);
> +spice_server_char_device_wakeup(_instance);
> +alarm(0);
> +
> +// we should read all data
> +g_assert(message_sizes_curr - message_sizes == 1);
> +
> +test_destroy(test);
> +basic_event_loop_destroy();
> +}
> +
>  int main(int argc, char *argv[])
>  {
>  g_test_init(, , NULL);
>  
>  g_test_add_func("/server/stream-device", test_stream_device);
>  g_test_add_func("/server/stream-device-unfinished", 
> test_stream_device_unfinished);
> +g_test_add_func("/server/stream-device-multiple", 
> test_stream_device_multiple);
>  
>  return g_test_run();
>  }
> -- 
> 2.14.3
> 
> ___
> Spice-devel mailing list
> Spice-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/spice-devel


signature.asc
Description: PGP signature
___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel


[Spice-devel] [PATCH spice-server 2/8] test-stream-device: Test batched multiple messages

2018-02-18 Thread Frediano Ziglio
Test all batched (send together) messages are handled correctly
and device is not stuck.

Signed-off-by: Frediano Ziglio 
---
 server/tests/test-stream-device.c | 36 
 1 file changed, 36 insertions(+)

diff --git a/server/tests/test-stream-device.c 
b/server/tests/test-stream-device.c
index edd618e2..72b3f382 100644
--- a/server/tests/test-stream-device.c
+++ b/server/tests/test-stream-device.c
@@ -215,12 +215,48 @@ static void test_stream_device_unfinished(void)
 basic_event_loop_destroy();
 }
 
+// check if sending multiple messages cause stall
+static void test_stream_device_multiple(void)
+{
+uint8_t *p = message;
+SpiceCoreInterface *core = basic_event_loop_init();
+Test *test = test_new(core);
+
+pos = 0;
+message_sizes_curr = message_sizes;
+message_sizes_end = message_sizes;
+
+// add some messages into device buffer
+p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG);
+p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG);
+p = add_format(p, 640, 480, SPICE_VIDEO_CODEC_TYPE_MJPEG);
+*message_sizes_end = p - message;
+++message_sizes_end;
+
+vmc_instance.base.sif = _interface.base;
+spice_server_add_interface(test->server, _instance.base);
+
+// we need to open the device and kick the start
+// the alarm is to avoid program to stuck
+alarm(5);
+spice_server_port_event(_instance, SPICE_PORT_EVENT_OPENED);
+spice_server_char_device_wakeup(_instance);
+alarm(0);
+
+// we should read all data
+g_assert(message_sizes_curr - message_sizes == 1);
+
+test_destroy(test);
+basic_event_loop_destroy();
+}
+
 int main(int argc, char *argv[])
 {
 g_test_init(, , NULL);
 
 g_test_add_func("/server/stream-device", test_stream_device);
 g_test_add_func("/server/stream-device-unfinished", 
test_stream_device_unfinished);
+g_test_add_func("/server/stream-device-multiple", 
test_stream_device_multiple);
 
 return g_test_run();
 }
-- 
2.14.3

___
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel