orion / rpms / dbus

Forked from rpms/dbus a year ago
Clone

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

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