aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Rath <Nikolaus@rath.org>2017-09-20 12:06:31 +0100
committerNikolaus Rath <Nikolaus@rath.org>2017-09-20 12:06:31 +0100
commitb32c4a4ca1a5ec3d5da2276be7a8f06c652c498f (patch)
tree917bfc6d3d37e375a17890ee0ff8069527a163db
parentbc47eeb68cd78347ca0e32c74d299a75be1b28ab (diff)
downloadsshfs-b32c4a4ca1a5ec3d5da2276be7a8f06c652c498f.tar
sshfs-b32c4a4ca1a5ec3d5da2276be7a8f06c652c498f.tar.gz
sshfs-b32c4a4ca1a5ec3d5da2276be7a8f06c652c498f.tar.bz2
sshfs-b32c4a4ca1a5ec3d5da2276be7a8f06c652c498f.zip
tst_link(): fix test failure
-rwxr-xr-xtest/test_sshfs.py12
1 files changed, 10 insertions, 2 deletions
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',