aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikolaus Rath <Nikolaus@rath.org>2017-08-06 10:24:23 +0200
committerNikolaus Rath <Nikolaus@rath.org>2017-08-06 11:07:23 +0200
commit95c65a62463031dd39a8776be500dcfb25c04c39 (patch)
tree6c52528658e850ee4956d41cdd61dff53c198ef5
parentf8df458f239de38d29be3161f46cd7fba74bdacf (diff)
downloadsshfs-95c65a62463031dd39a8776be500dcfb25c04c39.tar
sshfs-95c65a62463031dd39a8776be500dcfb25c04c39.tar.gz
sshfs-95c65a62463031dd39a8776be500dcfb25c04c39.tar.bz2
sshfs-95c65a62463031dd39a8776be500dcfb25c04c39.zip
Added seek and append tests.
-rwxr-xr-xtest/test_sshfs.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/test/test_sshfs.py b/test/test_sshfs.py
index 456aba4..446a617 100755
--- a/test/test_sshfs.py
+++ b/test/test_sshfs.py
@@ -95,6 +95,8 @@ def test_sshfs(tmpdir, debug, cache_timeout, sync_rd,
tst_readdir(src_dir, mnt_dir)
tst_open_read(src_dir, mnt_dir)
tst_open_write(src_dir, mnt_dir)
+ tst_append(src_dir, mnt_dir)
+ tst_seek(src_dir, mnt_dir)
tst_create(mnt_dir)
tst_passthrough(src_dir, mnt_dir, cache_timeout)
tst_mkdir(mnt_dir)
@@ -118,6 +120,17 @@ def test_sshfs(tmpdir, debug, cache_timeout, sync_rd,
else:
umount(mount_process, mnt_dir)
+@contextmanager
+def os_open(name, flags):
+ fd = os.open(name, flags)
+ try:
+ yield fd
+ finally:
+ os.close(fd)
+
+def os_create(name):
+ os.close(os.open(name, os.O_CREAT | os.O_RDWR))
+
def tst_unlink(src_dir, mnt_dir, cache_timeout):
name = name_generator()
fullname = mnt_dir + "/" + name
@@ -223,6 +236,32 @@ def tst_open_write(src_dir, mnt_dir):
assert filecmp.cmp(fullname, TEST_FILE, False)
+def tst_append(src_dir, mnt_dir):
+ name = name_generator()
+ os_create(pjoin(src_dir, name))
+ fullname = pjoin(mnt_dir, name)
+ with os_open(fullname, os.O_WRONLY) as fd:
+ os.write(fd, b'foo\n')
+ with os_open(fullname, os.O_WRONLY|os.O_APPEND) as fd:
+ os.write(fd, b'bar\n')
+
+ with open(fullname, 'rb') as fh:
+ assert fh.read() == b'foo\nbar\n'
+
+def tst_seek(src_dir, mnt_dir):
+ name = name_generator()
+ os_create(pjoin(src_dir, name))
+ fullname = pjoin(mnt_dir, name)
+ with os_open(fullname, os.O_WRONLY) as fd:
+ os.lseek(fd, 1, os.SEEK_SET)
+ os.write(fd, b'foobar\n')
+ with os_open(fullname, os.O_WRONLY) as fd:
+ os.lseek(fd, 4, os.SEEK_SET)
+ os.write(fd, b'com')
+
+ with open(fullname, 'rb') as fh:
+ assert fh.read() == b'\0foocom\n'
+
def tst_open_unlink(mnt_dir):
name = pjoin(mnt_dir, name_generator())
data1 = b'foo'