Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 1 | From 3c56ff21b9a5fe18f9cec9b97ae1788fdf5d563e Mon Sep 17 00:00:00 2001 |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 2 | From: Ross Burton <ross.burton@arm.com> |
| 3 | Date: Tue, 6 Jul 2021 19:26:03 +0100 |
| 4 | Subject: [PATCH] gio/tests/g-file-info: don't assume million-in-one events |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 5 | |
| 6 | Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2990] |
| 7 | Signed-off-by: Ross Burton <ross.burton@arm.com> |
| 8 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 9 | don't happen |
| 10 | |
| 11 | The access and creation time tests create a file, gets the time in |
| 12 | seconds, then gets the time in microseconds and assumes that the |
| 13 | difference between the two has to be above 0. |
| 14 | |
| 15 | As rare as this may be, it can happen: |
| 16 | |
| 17 | $ stat g-file-info-test-50A450 -c %y |
| 18 | 2021-07-06 18:24:56.000000767 +0100 |
| 19 | |
| 20 | Change the test to simply assert that the difference not negative to |
| 21 | handle this case. |
| 22 | |
| 23 | This is the same fix as 289f8b, but that was just modification time. |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 24 | |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 25 | --- |
| 26 | gio/tests/g-file-info.c | 4 ++-- |
| 27 | 1 file changed, 2 insertions(+), 2 deletions(-) |
| 28 | |
| 29 | diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 30 | index d9ad045..c9b12b0 100644 |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 31 | --- a/gio/tests/g-file-info.c |
| 32 | +++ b/gio/tests/g-file-info.c |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 33 | @@ -307,7 +307,7 @@ test_g_file_info_access_time (void) |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 34 | g_assert_nonnull (dt_usecs); |
| 35 | |
| 36 | ts = g_date_time_difference (dt_usecs, dt); |
| 37 | - g_assert_cmpint (ts, >, 0); |
| 38 | + g_assert_cmpint (ts, >=, 0); |
| 39 | g_assert_cmpint (ts, <, G_USEC_PER_SEC); |
| 40 | |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 41 | /* Try again with nanosecond precision. */ |
| 42 | @@ -442,7 +442,7 @@ test_g_file_info_creation_time (void) |
Patrick Williams | 2390b1b | 2022-11-03 13:47:49 -0500 | [diff] [blame] | 43 | g_assert_nonnull (dt_usecs); |
| 44 | |
| 45 | ts = g_date_time_difference (dt_usecs, dt); |
| 46 | - g_assert_cmpint (ts, >, 0); |
| 47 | + g_assert_cmpint (ts, >=, 0); |
| 48 | g_assert_cmpint (ts, <, G_USEC_PER_SEC); |
| 49 | |
Patrick Williams | 7784c42 | 2022-11-17 07:29:11 -0600 | [diff] [blame^] | 50 | /* Try again with nanosecond precision. */ |