[Spice-devel] [PATCH spice-common] test-marshallers: Check for "zero" attribute

Frediano Ziglio fziglio at redhat.com
Thu Jun 28 06:40:20 UTC 2018


Check the previous fix for "zero" attribute works correctly
(commit bc9df5816210efbe15ca03e82510f34174784082, "marshal: Fix a bug
with zero attribute").

Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
---
 tests/test-marshallers.c     | 13 +++++++++++++
 tests/test-marshallers.h     |  4 ++++
 tests/test-marshallers.proto |  6 ++++++
 3 files changed, 23 insertions(+)

diff --git a/tests/test-marshallers.c b/tests/test-marshallers.c
index ae90770..3bd98e8 100644
--- a/tests/test-marshallers.c
+++ b/tests/test-marshallers.c
@@ -62,6 +62,19 @@ int main(int argc G_GNUC_UNUSED, char **argv G_GNUC_UNUSED)
     if (free_res) {
         free(data);
     }
+    spice_marshaller_reset(marshaller);
+
+    SpiceMsgMainZeroes msg_zeroes = { 0x0102 };
+
+    spice_marshall_msg_main_Zeroes(marshaller, &msg_zeroes);
+    spice_marshaller_flush(marshaller);
+    data = spice_marshaller_linearize(marshaller, 0, &len, &free_res);
+    g_assert_cmpint(len, ==, 7);
+    g_assert_true(memcmp(data, "\x00\x02\x01\x00\x00\x00\x00", 7) == 0);
+    if (free_res) {
+        free(data);
+    }
+
     spice_marshaller_destroy(marshaller);
 
     return 0;
diff --git a/tests/test-marshallers.h b/tests/test-marshallers.h
index 7b9f6c5..46263d7 100644
--- a/tests/test-marshallers.h
+++ b/tests/test-marshallers.h
@@ -12,5 +12,9 @@ typedef struct {
     int8_t *name;
 } SpiceMsgMainArrayMessage;
 
+typedef struct {
+    uint16_t n;
+} SpiceMsgMainZeroes;
+
 #endif /* _H_TEST_MARSHALLERS */
 
diff --git a/tests/test-marshallers.proto b/tests/test-marshallers.proto
index 95d086c..08d3e01 100644
--- a/tests/test-marshallers.proto
+++ b/tests/test-marshallers.proto
@@ -8,6 +8,12 @@ channel TestChannel {
    message {
       int8 name[];
    } ArrayMessage;
+
+    message {
+        uint8 res1 @zero;
+        uint16 n;
+        uint32 res2 @zero;
+    } Zeroes;
 };
 
 protocol Spice {
-- 
2.17.1



More information about the Spice-devel mailing list