From b32c4a4ca1a5ec3d5da2276be7a8f06c652c498f Mon Sep 17 00:00:00 2001 From: Nikolaus Rath Date: Wed, 20 Sep 2017 12:06:31 +0100 Subject: tst_link(): fix test failure --- test/test_sshfs.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test_sshfs.py b/test/test_sshfs.py index 224179f..0c8917b 100755 --- a/test/test_sshfs.py +++ b/test/test_sshfs.py @@ -111,7 +111,7 @@ def test_sshfs(tmpdir, debug, cache_timeout, sync_rd, # file timestamps. tst_utimens(mnt_dir, tol=1) - tst_link(mnt_dir) + tst_link(mnt_dir, cache_timeout) tst_truncate_path(mnt_dir) tst_truncate_fd(mnt_dir) tst_open_unlink(mnt_dir) @@ -282,7 +282,7 @@ def tst_open_unlink(mnt_dir): def tst_statvfs(mnt_dir): os.statvfs(mnt_dir) -def tst_link(mnt_dir): +def tst_link(mnt_dir, cache_timeout): name1 = pjoin(mnt_dir, name_generator()) name2 = pjoin(mnt_dir, name_generator()) shutil.copyfile(TEST_FILE, name1) @@ -293,6 +293,14 @@ def tst_link(mnt_dir): os.link(name1, name2) + # The link operation changes st_ctime, and if we're unlucky + # the kernel will keep the old value cached for name1, and + # retrieve the new value for name2 (at least, this is the only + # way I can explain the test failure). To avoid this problem, + # we need to wait until the cached value has expired. + if cache_timeout: + safe_sleep(cache_timeout) + fstat1 = os.lstat(name1) fstat2 = os.lstat(name2) for attr in ('st_mode', 'st_dev', 'st_uid', 'st_gid', -- cgit v1.2.3