]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
glib: Fix ptest race issue
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 27 May 2023 15:07:31 +0000 (16:07 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sun, 28 May 2023 08:08:51 +0000 (09:08 +0100)
gio/tests/portal: Fix 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 we sometimes 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. There are probably better ways to handle this but this patch should
at least let us check this is the issue.

I've tried to report upstream but their issue tracker account creation is struggling
and I can't get my account to work.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/glib-2.0/glib-2.0/fix-ptest.patch [new file with mode: 0644]
meta/recipes-core/glib-2.0/glib-2.0_2.76.2.bb

diff --git a/meta/recipes-core/glib-2.0/glib-2.0/fix-ptest.patch b/meta/recipes-core/glib-2.0/glib-2.0/fix-ptest.patch
new file mode 100644 (file)
index 0000000..1ae98be
--- /dev/null
@@ -0,0 +1,166 @@
+gio/tests/portal: Fix 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 we sometimes 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. There are probably better ways to handle this but this patch should
+at least let us check this is the issue.
+
+I've tried to report upstream but their issue tracker account creation is struggling
+and I can't get my account to work.
+
+Upstream-Status: Pending
+
+Index: glib-2.76.2/gio/tests/portal-support-snap-classic.c
+===================================================================
+--- glib-2.76.2.orig/gio/tests/portal-support-snap-classic.c
++++ glib-2.76.2/gio/tests/portal-support-snap-classic.c
+@@ -89,6 +89,9 @@ test_portal_support_snap_none (SetupData
+   g_assert_false (glib_should_use_portal ());
+   g_assert_true (glib_network_available_in_sandbox ());
+   g_assert_true (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ static void
+@@ -101,6 +104,9 @@ test_portal_support_snap_all (SetupData
+   g_assert_false (glib_should_use_portal ());
+   g_assert_true (glib_network_available_in_sandbox ());
+   g_assert_true (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ int
+Index: glib-2.76.2/gio/tests/portal-support-snap.c
+===================================================================
+--- glib-2.76.2.orig/gio/tests/portal-support-snap.c
++++ glib-2.76.2/gio/tests/portal-support-snap.c
+@@ -80,6 +80,8 @@ test_portal_support_snap_no_snapctl (Set
+   g_assert_false (glib_should_use_portal ());
+   g_assert_false (glib_network_available_in_sandbox ());
+   g_assert_false (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
+ }
+ static void
+@@ -92,6 +94,9 @@ test_portal_support_snap_none (SetupData
+   g_assert_false (glib_should_use_portal ());
+   g_assert_false (glib_network_available_in_sandbox ());
+   g_assert_false (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ static void
+@@ -104,6 +109,9 @@ test_portal_support_snap_all (SetupData
+   g_assert_true (glib_should_use_portal ());
+   g_assert_true (glib_network_available_in_sandbox ());
+   g_assert_true (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ static void
+@@ -116,6 +124,9 @@ test_portal_support_snap_desktop_only (S
+   g_assert_true (glib_should_use_portal ());
+   g_assert_true (glib_network_available_in_sandbox ());
+   g_assert_false (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ static void
+@@ -128,6 +139,9 @@ test_portal_support_snap_network_only (S
+   g_assert_false (glib_should_use_portal ());
+   g_assert_true (glib_network_available_in_sandbox ());
+   g_assert_false (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ static void
+@@ -140,6 +154,9 @@ test_portal_support_snap_gsettings_only
+   g_assert_false (glib_should_use_portal ());
+   g_assert_false (glib_network_available_in_sandbox ());
+   g_assert_true (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ static void
+@@ -182,6 +199,9 @@ test_portal_support_snap_updates_dynamic
+   g_assert_false (glib_should_use_portal ());
+   g_assert_false (glib_network_available_in_sandbox ());
+   g_assert_false (glib_has_dconf_access_in_sandbox ());
++
++  cleanup_snapfiles (setup->snap_path);
++  cleanup_snapfiles (setup->bin_path);
+ }
+ int
+Index: glib-2.76.2/gio/tests/portal-support-utils.c
+===================================================================
+--- glib-2.76.2.orig/gio/tests/portal-support-utils.c
++++ glib-2.76.2/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)
+Index: glib-2.76.2/gio/tests/portal-support-utils.h
+===================================================================
+--- glib-2.76.2.orig/gio/tests/portal-support-utils.h
++++ glib-2.76.2/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);
index f3a716eb9d7e3b365fff8d919a536f1a9b680b1c..7a0ed6b60366d16b8ada962543fa7718a25ca6dc 100644 (file)
@@ -15,6 +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 \
            "
 SRC_URI:append:class-native = " file://relocate-modules.patch"