blob: c33fa88a765910b437ffb5e38b5704dfe0666910 [file] [log] [blame]
Patrick Williams2390b1b2022-11-03 13:47:49 -05001Upstream-Status: Backport [https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2990]
2Signed-off-by: Ross Burton <ross.burton@arm.com>
3
4From 14838522a706ebdcc3cdab661d4c368099fe3a4e Mon Sep 17 00:00:00 2001
5From: Ross Burton <ross.burton@arm.com>
6Date: Tue, 6 Jul 2021 19:26:03 +0100
7Subject: [PATCH] gio/tests/g-file-info: don't assume million-in-one events
8 don't happen
9
10The access and creation time tests create a file, gets the time in
11seconds, then gets the time in microseconds and assumes that the
12difference between the two has to be above 0.
13
14As rare as this may be, it can happen:
15
16$ stat g-file-info-test-50A450 -c %y
172021-07-06 18:24:56.000000767 +0100
18
19Change the test to simply assert that the difference not negative to
20handle this case.
21
22This 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
27diff --git a/gio/tests/g-file-info.c b/gio/tests/g-file-info.c
28index 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--
502.34.1
51