[Spice-commits] tests/test-marshallers.c tests/test-marshallers.h tests/test-marshallers.proto

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jul 3 11:25:49 UTC 2018


 tests/test-marshallers.c     |   13 +++++++++++++
 tests/test-marshallers.h     |    4 ++++
 tests/test-marshallers.proto |    6 ++++++
 3 files changed, 23 insertions(+)

New commits:
commit 2b5cadcd8a4d6aeb910b1949a8b393548503c9fc
Author: Frediano Ziglio <fziglio at redhat.com>
Date:   Thu Jun 21 22:55:08 2018 +0100

    test-marshallers: Check for "zero" attribute
    
    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>
    Acked-by: Christophe Fergeau <cfergeau at redhat.com>

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 {


More information about the Spice-commits mailing list