[PATCH spice-common v2 2/3] test-marshallers: Use unaligned structure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Allows to test for bad performance on some systems.
For instance on ARMv6/ARMv7 which does not support by default
64 bit unaligned read/write this can be checked on Linux
using /proc/cpu/alignment file.

Signed-off-by: Frediano Ziglio <fziglio@xxxxxxxxxx>
---
 tests/test-marshallers.c     | 10 ++++++----
 tests/test-marshallers.h     |  1 +
 tests/test-marshallers.proto |  1 +
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tests/test-marshallers.c b/tests/test-marshallers.c
index 734a2bb..a231b52 100644
--- a/tests/test-marshallers.c
+++ b/tests/test-marshallers.c
@@ -8,10 +8,11 @@
 #define g_assert_true g_assert
 #endif
 
-static uint8_t expected_data[] = { 0x02, 0x00, 0x00, 0x00, /* data_size */
-                                   0x08, 0x00, 0x00, 0x00, /* data offset */
-                                   0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, /* data */
+static uint8_t expected_data[] = { 123, /* dummy byte */
+                                   0x02, 0x00, 0x00, 0x00, /* data_size */
+                                   0x09, 0x00, 0x00, 0x00, /* data offset */
                                    0xef, 0xcd, 0xab, 0x90, 0x78, 0x56, 0x34, 0x12, /* data */
+                                   0x21, 0x43, 0x65, 0x87, 0x09, 0xba, 0xdc, 0xfe, /* data */
 };
 
 int main(int argc G_GNUC_UNUSED, char **argv G_GNUC_UNUSED)
@@ -23,9 +24,10 @@ int main(int argc G_GNUC_UNUSED, char **argv G_GNUC_UNUSED)
     uint8_t *data;
 
     msg = spice_malloc0(sizeof(SpiceMsgMainShortDataSubMarshall) + 2 * sizeof(uint64_t));
+    msg->dummy_byte = 123;
     msg->data_size = 2;
     msg->data[0] = 0x1234567890abcdef;
-    msg->data[1] = 0x1234567890abcdef;
+    msg->data[1] = 0xfedcba0987654321;
 
     marshaller = spice_marshaller_new();
     spice_marshall_msg_main_ShortDataSubMarshall(marshaller, msg);
diff --git a/tests/test-marshallers.h b/tests/test-marshallers.h
index 9cd34c7..371fcdc 100644
--- a/tests/test-marshallers.h
+++ b/tests/test-marshallers.h
@@ -4,6 +4,7 @@
 
 typedef struct {
     uint32_t data_size;
+    uint8_t dummy_byte;
     uint64_t data[];
 } SpiceMsgMainShortDataSubMarshall;
 
diff --git a/tests/test-marshallers.proto b/tests/test-marshallers.proto
index e360b09..68b5822 100644
--- a/tests/test-marshallers.proto
+++ b/tests/test-marshallers.proto
@@ -1,5 +1,6 @@
 channel TestChannel {
    message {
+      uint8 dummy_byte; // so structure is not aligned
       uint32 data_size;
       uint64 *data[data_size] @marshall;
    } ShortDataSubMarshall;
-- 
2.13.5

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]