Patch up file test to allow for a bit of time discrepancy

Since one cannot really compare system time to filesystem time (see e.g.
https://lkml.org/lkml/2017/3/30/809), allow for 1 second error to avoid
(or at least minimize) random test failures.
This commit is contained in:
Mike Gelfand 2017-07-21 00:45:30 +03:00
parent 88134ea62f
commit 55b41c9015
1 changed files with 12 additions and 12 deletions

View File

@ -184,8 +184,8 @@ static int test_get_info(void)
check_ptr(err, ==, NULL);
check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint(info.size, ==, 4);
check_int(info.last_modified_at, >=, t);
check_int(info.last_modified_at, <=, time(NULL));
check_int(info.last_modified_at, >=, t - 1);
check_int(info.last_modified_at, <=, time(NULL) + 1);
/* Good file info (by handle) */
fd = tr_sys_file_open(path1, TR_SYS_FILE_READ, 0, NULL);
@ -194,8 +194,8 @@ static int test_get_info(void)
check_ptr(err, ==, NULL);
check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint(info.size, ==, 4);
check_int(info.last_modified_at, >=, t);
check_int(info.last_modified_at, <=, time(NULL));
check_int(info.last_modified_at, >=, t - 1);
check_int(info.last_modified_at, <=, time(NULL) + 1);
tr_sys_file_close(fd, NULL);
tr_sys_path_remove(path1, NULL);
@ -208,8 +208,8 @@ static int test_get_info(void)
check_ptr(err, ==, NULL);
check_int(info.type, ==, TR_SYS_PATH_IS_DIRECTORY);
check_uint(info.size, !=, (uint64_t)-1);
check_int(info.last_modified_at, >=, t);
check_int(info.last_modified_at, <=, time(NULL));
check_int(info.last_modified_at, >=, t - 1);
check_int(info.last_modified_at, <=, time(NULL) + 1);
tr_sys_path_remove(path1, NULL);
if (create_symlink(path1, path2, false))
@ -228,8 +228,8 @@ static int test_get_info(void)
check_ptr(err, ==, NULL);
check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint(info.size, ==, 4);
check_int(info.last_modified_at, >=, t);
check_int(info.last_modified_at, <=, time(NULL));
check_int(info.last_modified_at, >=, t - 1);
check_int(info.last_modified_at, <=, time(NULL) + 1);
/* Good file info (by handle) */
fd = tr_sys_file_open(path1, TR_SYS_FILE_READ, 0, NULL);
@ -238,8 +238,8 @@ static int test_get_info(void)
check_ptr(err, ==, NULL);
check_int(info.type, ==, TR_SYS_PATH_IS_FILE);
check_uint(info.size, ==, 4);
check_int(info.last_modified_at, >=, t);
check_int(info.last_modified_at, <=, time(NULL));
check_int(info.last_modified_at, >=, t - 1);
check_int(info.last_modified_at, <=, time(NULL) + 1);
tr_sys_file_close(fd, NULL);
tr_sys_path_remove(path2, NULL);
@ -252,8 +252,8 @@ static int test_get_info(void)
check_ptr(err, ==, NULL);
check_int(info.type, ==, TR_SYS_PATH_IS_DIRECTORY);
check_uint(info.size, !=, (uint64_t)-1);
check_int(info.last_modified_at, >=, t);
check_int(info.last_modified_at, <=, time(NULL));
check_int(info.last_modified_at, >=, t - 1);
check_int(info.last_modified_at, <=, time(NULL) + 1);
tr_sys_path_remove(path2, NULL);
tr_sys_path_remove(path1, NULL);