From 56a5cd1337ddcd33223106d7d872b0d1a3fbc7e0 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Jan 2019 12:16:37 +0000 Subject: [PATCH 1/2] trash test: Don't assume that ~/.local exists In a minimal autobuilder environment, this test could conceivably be the first thing to refer to ~/.local. Modified by Iain Lane : Don't try to create ~/.local from tests, but skip if it doesn't exist. Signed-off-by: Simon McVittie --- gio/tests/trash.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/gio/tests/trash.c b/gio/tests/trash.c index 1055585e5..b7df9363a 100644 --- a/gio/tests/trash.c +++ b/gio/tests/trash.c @@ -107,8 +107,19 @@ test_trash_symlinks (void) g_test_bug ("1522"); - /* The test assumes that ~/.local always exists. */ target = g_build_filename (g_get_home_dir (), ".local", NULL); + + if (!g_file_test (target, G_FILE_TEST_IS_DIR)) + { + gchar *message; + + message = g_strdup_printf ("Directory '%s' does not exist", target); + g_test_skip (message); + g_free (message); + g_free (target); + return; + } + target_mount = g_unix_mount_for (target, NULL); g_assert_nonnull (target_mount); g_test_message ("Target: %s (mount: %s)", target, g_unix_mount_get_mount_path (target_mount)); From 13282768c7c31b2b1914233e2c914afe015e461e Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 8 Jan 2019 12:39:46 +0000 Subject: [PATCH 2/2] trash test: Don't rely on being able to determine mount points If we can't find the mount point for target or tmp (as currently happens on Launchpad autobuilders, and perhaps relatedly, on a development system that uses btrfs), that's probably not great but is not really the point of this test. Signed-off-by: Simon McVittie --- gio/tests/trash.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/gio/tests/trash.c b/gio/tests/trash.c index b7df9363a..4bf8fd0ef 100644 --- a/gio/tests/trash.c +++ b/gio/tests/trash.c @@ -121,11 +121,40 @@ test_trash_symlinks (void) } target_mount = g_unix_mount_for (target, NULL); + + if (target_mount == NULL) + { + gchar *message; + + message = g_strdup_printf ("Unable to determine mount point for %s", + target); + g_test_skip (message); + g_free (message); + g_free (target); + return; + } + g_assert_nonnull (target_mount); g_test_message ("Target: %s (mount: %s)", target, g_unix_mount_get_mount_path (target_mount)); tmp = g_dir_make_tmp ("test-trashXXXXXX", &error); + g_assert_no_error (error); + g_assert_nonnull (tmp); tmp_mount = g_unix_mount_for (tmp, NULL); + + if (tmp_mount == NULL) + { + gchar *message; + + message = g_strdup_printf ("Unable to determine mount point for %s", tmp); + g_test_skip (message); + g_free (message); + g_unix_mount_free (target_mount); + g_free (target); + g_free (tmp); + return; + } + g_assert_nonnull (tmp_mount); g_test_message ("Tmp: %s (mount: %s)", tmp, g_unix_mount_get_mount_path (tmp_mount));