Merge branch 'backport-test-fix-glib-2-62' into 'glib-2-62'

Backport part of !1375 “tests: Skip g-file-info-filesystem-readonly test if bindfs fails” to glib-2-62

See merge request GNOME/glib!1394
This commit is contained in:
Simon McVittie
2020-02-28 12:48:23 +00:00

View File

@@ -25,7 +25,7 @@
#include <gio/gio.h> #include <gio/gio.h>
#include <gio/gunixmounts.h> #include <gio/gunixmounts.h>
static void static gboolean
run (GError **error, run (GError **error,
const gchar *argv0, const gchar *argv0,
...) ...)
@@ -34,6 +34,8 @@ run (GError **error,
const gchar *arg; const gchar *arg;
va_list ap; va_list ap;
GSubprocess *subprocess; GSubprocess *subprocess;
gchar *command_line = NULL;
gboolean success;
args = g_ptr_array_new (); args = g_ptr_array_new ();
@@ -44,14 +46,20 @@ run (GError **error,
g_ptr_array_add (args, NULL); g_ptr_array_add (args, NULL);
va_end (ap); va_end (ap);
command_line = g_strjoinv (" ", (gchar **) args->pdata);
g_test_message ("Running command `%s`", command_line);
g_free (command_line);
subprocess = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error); subprocess = g_subprocess_newv ((const gchar * const *) args->pdata, G_SUBPROCESS_FLAGS_NONE, error);
g_ptr_array_free (args, TRUE); g_ptr_array_free (args, TRUE);
if (subprocess == NULL) if (subprocess == NULL)
return; return FALSE;
g_subprocess_wait_check (subprocess, NULL, error); success = g_subprocess_wait_check (subprocess, NULL, error);
g_object_unref (subprocess); g_object_unref (subprocess);
return success;
} }
static void static void
@@ -105,8 +113,14 @@ test_filesystem_readonly (gconstpointer with_mount_monitor)
/* Use bindfs, which does not need root privileges, to mount the contents of one dir /* Use bindfs, which does not need root privileges, to mount the contents of one dir
* into another dir (and do the mount as readonly as per passed '-o ro' option) */ * into another dir (and do the mount as readonly as per passed '-o ro' option) */
run (&error, bindfs, "-n", "-o", "ro", dir_to_mount, dir_mountpoint, NULL); if (!run (&error, bindfs, "-n", "-o", "ro", dir_to_mount, dir_mountpoint, NULL))
g_assert_no_error (error); {
gchar *skip_message = g_strdup_printf ("Failed to run bindfs to set up test: %s", error->message);
g_test_skip (skip_message);
g_free (skip_message);
g_clear_error (&error);
return;
}
/* Let's check now, that the file is in indeed in a readonly filesystem */ /* Let's check now, that the file is in indeed in a readonly filesystem */
file_in_mountpoint = g_strdup_printf ("%s/example.txt", dir_mountpoint); file_in_mountpoint = g_strdup_printf ("%s/example.txt", dir_mountpoint);