Skip to contentSkip to conversation

glib-2.0: Update ptest fix to upstream backport

PATCH New Richard Purdie 1 participant 1 message May 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 glib-2.0: Update ptest fix to upstream backport

Update the ptest fix to match the one accepted upstream.

---
 ...-support-Fix-snap-test-ordering-race.patch | 107 +++++++++++
 .../glib-2.0/glib-2.0/fix-ptest.patch         | 166 ------------------
 meta/recipes-core/glib-2.0/glib-2.0_2.76.2.bb |   2 +-
 3 files changed, 108 insertions(+), 167 deletions(-)
 create mode 100644 meta/recipes-core/glib-2.0/glib-2.0/0001-gio-tests-portal-support-Fix-snap-test-ordering-race.patch
 delete mode 100644 meta/recipes-core/glib-2.0/glib-2.0/fix-ptest.patch
meta/recipes-core/glib-2.0/glib-2.0/0001-gio-tests-portal-support-Fix-snap-test-ordering-race.patch new file +107 -0
new file mode 100644
index 00000000000..9e2bc1338b1
@@ -0,0 +1,107 @@
+From f47503cc5ae10de6dee319ba6cff257eddabf33e Mon Sep 17 00:00:00 2001
+From: Richard Purdie <[email protected]>
+Date: Tue, 30 May 2023 11:52:38 +0100
+Subject: [PATCH] gio/tests/portal-support: Fix snap test ordering race
+
+When the gnome test runner executes the tests, the test appear to execute in disk
+order. This means it sometimes works and sometimes we see breakage in portal-support-snap
+and portal-support-snap-classic.
+
+The issue is that some tests create config files but some don't. If they run
+in the wrong order, tests see config files they shouldn't and break.
+
+Fix this by deleting the files after each test run, properly cleaning up after
+themselves. The cleanup code is based upon gtestutils.c:rm_rf().
+
+Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/commit/c63cf19d9a8a6ae315a7f9a3fe4ea60c8cf5dece]
+
+Signed-off-by: Richard Purdie <[email protected]>
+---
+ gio/tests/portal-support-snap-classic.c |  3 +++
+ gio/tests/portal-support-snap.c         |  3 +++
+ gio/tests/portal-support-utils.c        | 27 +++++++++++++++++++++++++
+ gio/tests/portal-support-utils.h        |  2 ++
+ 4 files changed, 35 insertions(+)
+
+diff --git a/gio/tests/portal-support-snap-classic.c b/gio/tests/portal-support-snap-classic.c
+index 8c0ed90c2..5b67865e7 100644
+--- a/gio/tests/portal-support-snap-classic.c
++++ b/gio/tests/portal-support-snap-classic.c
+@@ -66,6 +66,9 @@ tests_teardown (SetupData *setup_data,
+   else
+     g_unsetenv ("SNAP");
+ 
++  cleanup_snapfiles (setup_data->snap_path);
++  cleanup_snapfiles (setup_data->bin_path);
++
+   g_clear_pointer (&setup_data->old_path, g_free);
+   g_clear_pointer (&setup_data->old_snap, g_free);
+ }
+diff --git a/gio/tests/portal-support-snap.c b/gio/tests/portal-support-snap.c
+index 7dd14d82f..cd904678f 100644
+--- a/gio/tests/portal-support-snap.c
++++ b/gio/tests/portal-support-snap.c
+@@ -67,6 +67,9 @@ tests_teardown (SetupData *setup_data,
+   else
+     g_unsetenv ("SNAP");
+ 
++  cleanup_snapfiles (setup_data->snap_path);
++  cleanup_snapfiles (setup_data->bin_path);
++
+   g_clear_pointer (&setup_data->old_path, g_free);
+   g_clear_pointer (&setup_data->old_snap, g_free);
+ }
+diff --git a/gio/tests/portal-support-utils.c b/gio/tests/portal-support-utils.c
+index ae7073a3a..b7ee22630 100644
+--- a/gio/tests/portal-support-utils.c
++++ b/gio/tests/portal-support-utils.c
+@@ -26,6 +26,33 @@
+ #include <glib.h>
+ #include <glib/gstdio.h>
+ 
++
++void
++cleanup_snapfiles (const gchar *path)
++{
++  GDir *dir = NULL;
++  const gchar *entry;
++
++  dir = g_dir_open (path, 0, NULL);
++  if (dir == NULL)
++    {
++      /* Assume it’s a file. Ignore failure. */
++      (void) g_remove (path);
++      return;
++    }
++
++  while ((entry = g_dir_read_name (dir)) != NULL)
++    {
++      gchar *sub_path = g_build_filename (path, entry, NULL);
++      cleanup_snapfiles (sub_path);
++      g_free (sub_path);
++    }
++
++  g_dir_close (dir);
++
++  g_rmdir (path);
++}
++
+ void
+ create_fake_snapctl (const char *path,
+                      const char *supported_op)
+diff --git a/gio/tests/portal-support-utils.h b/gio/tests/portal-support-utils.h
+index 40c035b43..defbdcd4e 100644
+--- a/gio/tests/portal-support-utils.h
++++ b/gio/tests/portal-support-utils.h
+@@ -23,6 +23,8 @@
+ 
+ #include <glib.h>
+ 
++void cleanup_snapfiles (const gchar *path);
++
+ void create_fake_snap_yaml (const char *snap_path,
+                             gboolean is_classic);
+ 
+-- 
+2.39.2
+
meta/recipes-core/glib-2.0/glib-2.0/fix-ptest.patch deleted +0 -166

166 lines not on this page · raw message

meta/recipes-core/glib-2.0/glib-2.0_2.76.2.bb +1 -1
index 7a0ed6b6036..6a9a5f359c6 100644
@@ -15,7 +15,7 @@ SRC_URI = "${GNOME_MIRROR}/glib/${SHRT_VER}/glib-${PV}.tar.xz \
            file://0001-meson-Run-atomics-test-on-clang-as-well.patch \
            file://0001-gio-tests-resources.c-comment-out-a-build-host-only-.patch \
            file://0001-Avoid-having-g_futex_simple-inadvertently-modify-err.patch \
-           file://fix-ptest.patch \
+           file://0001-gio-tests-portal-support-Fix-snap-test-ordering-race.patch \
            "
 SRC_URI:append:class-native = " file://relocate-modules.patch"
 
Signature · 1 line
2.39.2