From 7162b3c496e81d8d7b02b99397f777223b58d9d4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 14 Sep 2022 09:03:24 +0000 Subject: [PATCH 1/2] tests: skip g-file-info test if atime unsupported For example, g_file_query_info will not be able to determine access time for files on ZFS with atime=off. --- gio/tests/g-file-info.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c index 427ebffcc..75352790d 100644 --- a/gio/tests/g-file-info.c +++ b/gio/tests/g-file-info.c @@ -282,6 +282,15 @@ test_g_file_info_access_time (void) NULL, &error); g_assert_no_error (error); + if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_ACCESS)) + { + g_test_skip ("Skipping testing access time as it’s not supported by the kernel"); + g_file_delete (file, NULL, NULL); + g_clear_object (&file); + g_clear_object (&info); + return; + } + /* Check the access time is retrievable. */ dt = g_file_info_get_access_date_time (info); g_assert_nonnull (dt); From 7c74fe4c1d49d2bfcaf0785412c7d50b40c131e4 Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Wed, 14 Sep 2022 09:03:58 +0000 Subject: [PATCH 2/2] tests: skip based on g_file_info_has_attribute Per review request. Matches the style for the newly introduced skip check in test_g_file_info_access_time. --- gio/tests/g-file-info.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c index 75352790d..d9ad04583 100644 --- a/gio/tests/g-file-info.c +++ b/gio/tests/g-file-info.c @@ -417,9 +417,7 @@ test_g_file_info_creation_time (void) NULL, &error); g_assert_no_error (error); - /* Check the creation time is retrievable. */ - dt = g_file_info_get_creation_date_time (info); - if (!dt) + if (!g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_TIME_CREATED)) { g_test_skip ("Skipping testing creation time as it’s not supported by the kernel"); g_clear_object (&io_stream); @@ -429,6 +427,9 @@ test_g_file_info_creation_time (void) return; } + /* Check the creation time is retrievable. */ + dt = g_file_info_get_creation_date_time (info); + /* Try again with microsecond precision. */ g_clear_object (&info); info = g_file_query_info (file,