diff --git a/gio/tests/g-file-info-filesystem-readonly.c b/gio/tests/g-file-info-filesystem-readonly.c index a715ef8d0..60937b143 100644 --- a/gio/tests/g-file-info-filesystem-readonly.c +++ b/gio/tests/g-file-info-filesystem-readonly.c @@ -61,6 +61,24 @@ assert_remove (const gchar *file) g_error ("failed to remove %s: %s", file, g_strerror (errno)); } +static gboolean +fuse_module_loaded (void) +{ + char *contents = NULL; + gboolean ret; + + if (!g_file_get_contents ("/proc/modules", &contents, NULL, NULL) || + contents == NULL) + { + g_free (contents); + return FALSE; + } + + ret = (strstr (contents, "\nfuse ") != NULL); + g_free (contents); + return ret; +} + static void test_filesystem_readonly (gconstpointer with_mount_monitor) { @@ -87,6 +105,18 @@ test_filesystem_readonly (gconstpointer with_mount_monitor) return; } + /* If the fuse module is loaded but there's no /dev/fuse, then we're + * we're probably in a rootless container and won't be able to + * use bindfs to run our tests */ + if (fuse_module_loaded () && + !g_file_test ("/dev/fuse", G_FILE_TEST_EXISTS)) + { + g_test_skip ("fuse support is needed to run this test (rootless container?)"); + g_free (fusermount); + g_free (bindfs); + return; + } + curdir = g_get_current_dir (); dir_to_mount = g_strdup_printf ("%s/dir_bindfs_to_mount", curdir); file_in_mount = g_strdup_printf ("%s/example.txt", dir_to_mount);