Blame SOURCES/0001-test-marshal-Ensure-we-use-suitably-aligned-buffers.patch

f8e34b
From 1a09d46b3cad370e4bd2c59ec6215fbf65351834 Mon Sep 17 00:00:00 2001
f8e34b
From: Colin Walters <walters@verbum.org>
f8e34b
Date: Wed, 24 Jul 2013 21:48:58 +0100
f8e34b
Subject: [PATCH] test/marshal: Ensure we use suitably aligned buffers
f8e34b
f8e34b
This test was failing on s390; though it could fail
f8e34b
on other platforms too.  Basically we need to be sure
f8e34b
we're passing at least word-aligned buffers to the
f8e34b
demarshalling code.  malloc() will do that for us.
f8e34b
---
f8e34b
 test/marshal.c | 27 ++++++++++++++++++++++-----
f8e34b
 1 file changed, 22 insertions(+), 5 deletions(-)
f8e34b
f8e34b
diff --git a/test/marshal.c b/test/marshal.c
f8e34b
index e9ac7e3..e65ee7c 100644
f8e34b
--- a/test/marshal.c
f8e34b
+++ b/test/marshal.c
f8e34b
@@ -27,6 +27,7 @@
f8e34b
 #include <config.h>
f8e34b
 
f8e34b
 #include <glib.h>
f8e34b
+#include <string.h>
f8e34b
 
f8e34b
 #include <dbus/dbus.h>
f8e34b
 #include <dbus/dbus-glib-lowlevel.h>
f8e34b
@@ -244,14 +245,30 @@ int
f8e34b
 main (int argc,
f8e34b
     char **argv)
f8e34b
 {
f8e34b
+  int ret;
f8e34b
+  char *aligned_le_blob;
f8e34b
+  char *aligned_be_blob;
f8e34b
+
f8e34b
   g_test_init (&argc, &argv, NULL);
f8e34b
 
f8e34b
-  g_test_add ("/demarshal/le", Fixture, le_blob, setup, test_endian, teardown);
f8e34b
-  g_test_add ("/demarshal/be", Fixture, be_blob, setup, test_endian, teardown);
f8e34b
-  g_test_add ("/demarshal/needed/le", Fixture, le_blob, setup, test_needed,
f8e34b
+  /* We have to pass in a buffer that's at least "default aligned",
f8e34b
+   * i.e.  on GNU systems to 8 or 16.  The linker may have only given
f8e34b
+   * us byte-alignment for the char[] static variables.
f8e34b
+   */
f8e34b
+  aligned_le_blob = g_malloc (sizeof (le_blob));
f8e34b
+  memcpy (aligned_le_blob, le_blob, sizeof (le_blob));
f8e34b
+  aligned_be_blob = g_malloc (sizeof (be_blob));
f8e34b
+  memcpy (aligned_be_blob, be_blob, sizeof (be_blob));  
f8e34b
+
f8e34b
+  g_test_add ("/demarshal/le", Fixture, aligned_le_blob, setup, test_endian, teardown);
f8e34b
+  g_test_add ("/demarshal/be", Fixture, aligned_be_blob, setup, test_endian, teardown);
f8e34b
+  g_test_add ("/demarshal/needed/le", Fixture, aligned_le_blob, setup, test_needed,
f8e34b
       teardown);
f8e34b
-  g_test_add ("/demarshal/needed/be", Fixture, be_blob, setup, test_needed,
f8e34b
+  g_test_add ("/demarshal/needed/be", Fixture, aligned_be_blob, setup, test_needed,
f8e34b
       teardown);
f8e34b
 
f8e34b
-  return g_test_run ();
f8e34b
+  ret = g_test_run ();
f8e34b
+  g_free (aligned_le_blob);
f8e34b
+  g_free (aligned_be_blob);
f8e34b
+  return ret;
f8e34b
 }
f8e34b
-- 
f8e34b
1.8.1.4
f8e34b