test-marshallers: Check for "zero" attribute

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

Signed-off-by: Frediano Ziglio <fziglio@redhat.com>
Acked-by: Christophe Fergeau <cfergeau@redhat.com>
This commit is contained in:
Frediano Ziglio 2018-06-21 22:55:08 +01:00
parent 7050511d9e
commit 2b5cadcd8a
3 changed files with 23 additions and 0 deletions

View File

@ -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;

View File

@ -12,5 +12,9 @@ typedef struct {
int8_t *name;
} SpiceMsgMainArrayMessage;
typedef struct {
uint16_t n;
} SpiceMsgMainZeroes;
#endif /* _H_TEST_MARSHALLERS */

View File

@ -8,6 +8,12 @@ channel TestChannel {
message {
int8 name[];
} ArrayMessage;
message {
uint8 res1 @zero;
uint16 n;
uint32 res2 @zero;
} Zeroes;
};
protocol Spice {