Rather than showing the expected data in raw format (ascii codes, etc), which is hard to verify, show the characters themselves, and group them by structure. Also add a few more comments. --- server/tests/test-stream-device.c | 35 +++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/server/tests/test-stream-device.c b/server/tests/test-stream-device.c index cb3a1a4ff..dcdd91896 100644 --- a/server/tests/test-stream-device.c +++ b/server/tests/test-stream-device.c @@ -493,7 +493,8 @@ static void test_stream_device_data_message(TestFixture *fixture, gconstpointer static void test_display_info(TestFixture *fixture, gconstpointer user_data) { - // build a message for the streaming device + // craft a message from the mock stream device that provides display info to the server for the + // given stream static const char address[] = "pci/a/b.cde"; StreamMsgDeviceDisplayInfo info = { .stream_id = GUINT32_TO_LE(0x01020304), @@ -510,11 +511,13 @@ static void test_display_info(TestFixture *fixture, gconstpointer user_data) *message_sizes_end = p - message; ++message_sizes_end; - // parse the message we crafted + // parse the simulated display info message from the stream device so the server now has display + // info for the mock stream device test_kick(); // initialize a QXL interface test_add_display_interface(test); + /* qxl device supports 2 monitors */ spice_qxl_set_device_info(&test->qxl_instance, "pci/0/1.2", 0, 2); // build the buffer to send to the agent for display information @@ -524,14 +527,28 @@ static void test_display_info(TestFixture *fixture, gconstpointer user_data) size_t buf_len; uint8_t *buf = spice_marshaller_linearize(m, 0, &buf_len, &to_free); - // check output buffer + // check output buffer. The message that we send to the vdagent should combine display info for + // the stream device that we crafted above and the qxl device. static const uint8_t expected_buffer[] = { - 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 10, 0, 0, 0,112, 99,105, 47, 48, 47, 49, 46, 50, 0, 0, 0, - 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 10, 0, 0, 0,112, 99, - 105, 47, 48, 47, 49, 46, 50, 0, 0, 0, 0, 0, 4, 3, 2, 1, - 13, 12, 11, 10, 12, 0, 0, 0,112, 99,105, 47, 97, 47, 98, 46, - 99,100,101, 0 + /* device count */ 3, 0, 0, 0, + + /* channel_id */ 0, 0, 0, 0, + /* monitor_id */ 0, 0, 0, 0, + /* device_display_id */ 0, 0, 0, 0, + /* device_address_len */ 10, 0, 0, 0, + /* device_address */ 'p','c','i','/','0','/','1','.','2', 0, + + /* channel_id */ 0, 0, 0, 0, + /* monitor_id */ 1, 0, 0, 0, + /* device_display_id */ 1, 0, 0, 0, + /* device_address_len */ 10, 0, 0, 0, + /* device_address */ 'p','c', 'i','/','0','/','1','.','2', 0, + + /* channel_id */ 0, 0, 0, 0, + /* monitor_id */ 4, 3, 2, 1, + /* device_display_id */ 13, 12, 11, 10, + /* device_address_len */ 12, 0, 0, 0, + /* device_address */ 'p','c','i','/','a','/','b','.','c','d','e', 0 }; g_assert_cmpint(buf_len, ==, sizeof(expected_buffer)); g_assert_true(memcmp(buf, expected_buffer, buf_len) == 0); -- 2.17.2 _______________________________________________ Spice-devel mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/spice-devel