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