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.
This commit is contained in:
Руслан Ижбулатов 2018-10-05 18:36:53 +00:00
parent 62d387151d
commit 357c5a47d5

View File

@ -888,6 +888,7 @@ test_stdio_wrappers (void)
struct utimbuf ut; struct utimbuf ut;
GError *error = NULL; GError *error = NULL;
GStatBuf path_statbuf, cwd_statbuf; GStatBuf path_statbuf, cwd_statbuf;
time_t now;
/* The permissions tests here dont work when running as root. */ /* The permissions tests here dont work when running as root. */
#ifdef G_OS_UNIX #ifdef G_OS_UNIX
@ -957,14 +958,16 @@ test_stdio_wrappers (void)
g_assert_cmpint (ret, ==, 0); g_assert_cmpint (ret, ==, 0);
#endif #endif
ut.actime = ut.modtime = (time_t)0; now = time (NULL);
ut.actime = ut.modtime = now;
ret = g_utime ("test-create", &ut); ret = g_utime ("test-create", &ut);
g_assert_cmpint (ret, ==, 0); g_assert_cmpint (ret, ==, 0);
ret = g_lstat ("test-create", &buf); ret = g_lstat ("test-create", &buf);
g_assert_cmpint (ret, ==, 0); g_assert_cmpint (ret, ==, 0);
g_assert_cmpint (buf.st_atime, ==, (time_t)0); g_assert_cmpint (buf.st_atime, ==, now);
g_assert_cmpint (buf.st_mtime, ==, (time_t)0); g_assert_cmpint (buf.st_mtime, ==, now);
g_chdir (".."); g_chdir ("..");
g_remove ("mkdir-test/test-create"); g_remove ("mkdir-test/test-create");