From c14810e08f23640a70e2dfa6a71dd217dc2d60bc Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 22 Oct 2024 16:15:18 +0100 Subject: [PATCH] tests: Fix calls to deprecated API in unix-mounts tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes commit aac56f1618aabfcf4c6b3ef1ee5b87322208e9ad — I missed this while reviewing it, but the unit tests were partially changed to call the new APIs, without being fully changed. This caused the build to succeed on Linux, but fail on macOS due to using a deprecated API. Actually, a better approach for the unit tests would be to consistently call the *old* APIs, as they all immediately call the new APIs. Then we get coverage of both old and new for free, at the cost of putting `G_GNUC_BEGIN_IGNORE_DEPRECATIONS` at the top of the test file. Signed-off-by: Philip Withnall Helps: #3492 --- gio/tests/unix-mounts.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/gio/tests/unix-mounts.c b/gio/tests/unix-mounts.c index e09c5c08e..e24ec667b 100644 --- a/gio/tests/unix-mounts.c +++ b/gio/tests/unix-mounts.c @@ -38,6 +38,11 @@ #include #include +/* We test all of the old g_unix_mount_*() API before it was renamed to + * g_unix_mount_entry_*(). The old API calls the new API, so both methods get + * tested at once. */ +G_GNUC_BEGIN_IGNORE_DEPRECATIONS + static void test_is_system_fs_type (void) { @@ -313,7 +318,7 @@ test_get_mount_entries (void) res = g_file_set_contents (tmp_file, fake_mtab, -1, NULL); g_assert (res); - entries = g_unix_mount_entries_get_from_file (tmp_file, &time_read, &n_entries); + entries = g_unix_mounts_get_from_file (tmp_file, &time_read, &n_entries); if (entries == NULL) { @@ -331,25 +336,27 @@ test_get_mount_entries (void) for (size_t i = 0; i < n_entries; i++) { - g_assert_cmpstr (g_unix_mount_entry_get_device_path (entries[i]), ==, expected_entries[i].device_path); - g_assert_cmpstr (g_unix_mount_entry_get_fs_type (entries[i]), ==, expected_entries[i].fs_type); - g_assert_cmpstr (g_unix_mount_entry_get_mount_path (entries[i]), ==, expected_entries[i].mount_path); - g_assert_cmpstr (g_unix_mount_entry_get_options (entries[i]), ==, expected_entries[i].options); + g_assert_cmpstr (g_unix_mount_get_device_path (entries[i]), ==, expected_entries[i].device_path); + g_assert_cmpstr (g_unix_mount_get_fs_type (entries[i]), ==, expected_entries[i].fs_type); + g_assert_cmpstr (g_unix_mount_get_mount_path (entries[i]), ==, expected_entries[i].mount_path); + g_assert_cmpstr (g_unix_mount_get_options (entries[i]), ==, expected_entries[i].options); /* root_path is only supported by libmount */ #ifdef HAVE_LIBMOUNT - g_assert_cmpstr (g_unix_mount_entry_get_root_path (entries[i]), ==, expected_entries[i].root_path); + g_assert_cmpstr (g_unix_mount_get_root_path (entries[i]), ==, expected_entries[i].root_path); #else g_assert_null (g_unix_mount_get_root_path (entries[i])); #endif } for (size_t i = 0; i < n_entries; i++) - g_unix_mount_entry_free (entries[i]); + g_unix_mount_free (entries[i]); g_free (entries); g_free (tmp_file); } +G_GNUC_END_IGNORE_DEPRECATIONS + int main (int argc, char *argv[])