2d3b65
From 85c4031696add9797e2334ced20678edcd96c869 Mon Sep 17 00:00:00 2001
2d3b65
From: Mart Raudsepp <leio@gentoo.org>
2d3b65
Date: Wed, 19 Dec 2018 16:22:21 +0200
2d3b65
Subject: [PATCH 1/2] tests: Allocate gvariant data from the heap to guarantee
2d3b65
 alignment
2d3b65
2d3b65
On glib-2-58 branch we don't have !455, thus we need aligned data
2d3b65
for the gvariant tests to not fail on i686.
2d3b65
2d3b65
Fixes #1626
2d3b65
---
2d3b65
 glib/tests/gvariant.c | 15 ++++++++++++---
2d3b65
 1 file changed, 12 insertions(+), 3 deletions(-)
2d3b65
2d3b65
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
2d3b65
index 6e417f6c1..a7b19826d 100644
2d3b65
--- a/glib/tests/gvariant.c
2d3b65
+++ b/glib/tests/gvariant.c
2d3b65
@@ -4664,6 +4664,7 @@ test_stack_dict_init (void)
2d3b65
 static void
2d3b65
 test_normal_checking_tuples (void)
2d3b65
 {
2d3b65
+  gpointer aligned_data;
2d3b65
   const guint8 data[] = {
2d3b65
     0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
2d3b65
     'a', '(', 'a', 'o', 'a', 'o', 'a', 'a', 'o', 'a', 'a', 'o', ')'
2d3b65
@@ -4672,13 +4673,15 @@ test_normal_checking_tuples (void)
2d3b65
   GVariant *variant = NULL;
2d3b65
   GVariant *normal_variant = NULL;
2d3b65
 
2d3b65
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
2d3b65
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
2d3b65
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
2d3b65
                                      FALSE, NULL, NULL);
2d3b65
   g_assert_nonnull (variant);
2d3b65
 
2d3b65
   normal_variant = g_variant_get_normal_form (variant);
2d3b65
   g_assert_nonnull (normal_variant);
2d3b65
 
2d3b65
+  g_free (aligned_data);
2d3b65
   g_variant_unref (normal_variant);
2d3b65
   g_variant_unref (variant);
2d3b65
 }
2d3b65
@@ -4790,6 +4793,7 @@ test_recursion_limits_array_in_variant (void)
2d3b65
 static void
2d3b65
 test_normal_checking_array_offsets (void)
2d3b65
 {
2d3b65
+  gpointer aligned_data;
2d3b65
   const guint8 data[] = {
2d3b65
     0x07, 0xe5, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00,
2d3b65
     'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'g',
2d3b65
@@ -4798,13 +4802,15 @@ test_normal_checking_array_offsets (void)
2d3b65
   GVariant *variant = NULL;
2d3b65
   GVariant *normal_variant = NULL;
2d3b65
 
2d3b65
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
2d3b65
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
2d3b65
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
2d3b65
                                      FALSE, NULL, NULL);
2d3b65
   g_assert_nonnull (variant);
2d3b65
 
2d3b65
   normal_variant = g_variant_get_normal_form (variant);
2d3b65
   g_assert_nonnull (normal_variant);
2d3b65
 
2d3b65
+  g_free (aligned_data);
2d3b65
   g_variant_unref (normal_variant);
2d3b65
   g_variant_unref (variant);
2d3b65
 }
2d3b65
@@ -4838,6 +4844,7 @@ test_normal_checking_tuple_offsets (void)
2d3b65
 static void
2d3b65
 test_normal_checking_empty_object_path (void)
2d3b65
 {
2d3b65
+  gpointer aligned_data;
2d3b65
   const guint8 data[] = {
2d3b65
     0x20, 0x20, 0x00, 0x00, 0x00, 0x00,
2d3b65
     '(', 'h', '(', 'a', 'i', 'a', 'b', 'i', 'o', ')', ')',
2d3b65
@@ -4846,13 +4853,15 @@ test_normal_checking_empty_object_path (void)
2d3b65
   GVariant *variant = NULL;
2d3b65
   GVariant *normal_variant = NULL;
2d3b65
 
2d3b65
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
2d3b65
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
2d3b65
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data, size,
2d3b65
                                      FALSE, NULL, NULL);
2d3b65
   g_assert_nonnull (variant);
2d3b65
 
2d3b65
   normal_variant = g_variant_get_normal_form (variant);
2d3b65
   g_assert_nonnull (normal_variant);
2d3b65
 
2d3b65
+  g_free (aligned_data);
2d3b65
   g_variant_unref (normal_variant);
2d3b65
   g_variant_unref (variant);
2d3b65
 }
2d3b65
-- 
2d3b65
2.19.1
2d3b65
4200aa
From 4ef58e5661849317a1110c9b93957f2c608677dd Mon Sep 17 00:00:00 2001
4200aa
From: Simon McVittie <smcv@collabora.com>
4200aa
Date: Thu, 3 Jan 2019 08:21:40 +0000
4200aa
Subject: [PATCH 2/2] gvariant test: Also force alignment for tuple test data
4200aa
4200aa
glib!552 (commit 9eed22b3) fixed this for the tests that failed on i686,
4200aa
but this additional test failed on Debian's s390x port
4200aa
(IBM z/Architecture, 64-bit big-endian).
4200aa
4200aa
Signed-off-by: Simon McVittie <smcv@collabora.com>
4200aa
---
4200aa
 glib/tests/gvariant.c | 7 +++++--
4200aa
 1 file changed, 5 insertions(+), 2 deletions(-)
4200aa
4200aa
diff --git a/glib/tests/gvariant.c b/glib/tests/gvariant.c
4200aa
index a7b19826d..c4a996c1f 100644
4200aa
--- a/glib/tests/gvariant.c
4200aa
+++ b/glib/tests/gvariant.c
4200aa
@@ -4820,6 +4820,7 @@ test_normal_checking_array_offsets (void)
4200aa
 static void
4200aa
 test_normal_checking_tuple_offsets (void)
4200aa
 {
4200aa
+  gpointer aligned_data;
4200aa
   const guint8 data[] = {
4200aa
     0x07, 0xe5, 0x00, 0x07, 0x00, 0x07,
4200aa
     '(', 'a', 's', 'a', 's', 'a', 's', 'a', 's', 'a', 's', 'a', 's', ')',
4200aa
@@ -4828,13 +4829,15 @@ test_normal_checking_tuple_offsets (void)
4200aa
   GVariant *variant = NULL;
4200aa
   GVariant *normal_variant = NULL;
4200aa
 
4200aa
-  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, data, size,
4200aa
-                                     FALSE, NULL, NULL);
4200aa
+  aligned_data = g_memdup (data, size); /* guarantee alignment */
4200aa
+  variant = g_variant_new_from_data (G_VARIANT_TYPE_VARIANT, aligned_data,
4200aa
+                                     size, FALSE, NULL, NULL);
4200aa
   g_assert_nonnull (variant);
4200aa
 
4200aa
   normal_variant = g_variant_get_normal_form (variant);
4200aa
   g_assert_nonnull (normal_variant);
4200aa
 
4200aa
+  g_free (aligned_data);
4200aa
   g_variant_unref (normal_variant);
4200aa
   g_variant_unref (variant);
4200aa
 }
4200aa
-- 
4200aa
2.19.1