From 357c5a47d5973d59d0c8645177b81252feed058a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D1=83=D1=81=D0=BB=D0=B0=D0=BD=20=D0=98=D0=B6=D0=B1?= =?UTF-8?q?=D1=83=D0=BB=D0=B0=D1=82=D0=BE=D0=B2?= Date: Fri, 5 Oct 2018 18:36:53 +0000 Subject: [PATCH] fileutils test: use current time instead of zero This works around weird issues MS C runtime has when dealing with timestamps close to zero, where timezone adjustment could result in a negative timestamp. --- glib/tests/fileutils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/glib/tests/fileutils.c b/glib/tests/fileutils.c index adc735d79..6e3966fde 100644 --- a/glib/tests/fileutils.c +++ b/glib/tests/fileutils.c @@ -888,6 +888,7 @@ test_stdio_wrappers (void) struct utimbuf ut; GError *error = NULL; GStatBuf path_statbuf, cwd_statbuf; + time_t now; /* The permissions tests here don’t work when running as root. */ #ifdef G_OS_UNIX @@ -957,14 +958,16 @@ test_stdio_wrappers (void) g_assert_cmpint (ret, ==, 0); #endif - ut.actime = ut.modtime = (time_t)0; + now = time (NULL); + + ut.actime = ut.modtime = now; ret = g_utime ("test-create", &ut); g_assert_cmpint (ret, ==, 0); ret = g_lstat ("test-create", &buf); g_assert_cmpint (ret, ==, 0); - g_assert_cmpint (buf.st_atime, ==, (time_t)0); - g_assert_cmpint (buf.st_mtime, ==, (time_t)0); + g_assert_cmpint (buf.st_atime, ==, now); + g_assert_cmpint (buf.st_mtime, ==, now); g_chdir (".."); g_remove ("mkdir-test/test-create");