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

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