diff options
author | Anthony Rebello <rebello.anthony@gmail.com> | 2020-01-25 04:17:09 -0600 |
---|---|---|
committer | Nikolaus Rath <Nikolaus@rath.org> | 2020-01-25 10:17:09 +0000 |
commit | aaa5c0931e79453091587e7e625ea92af061c249 (patch) | |
tree | c420210302765f6c1300d80e7587ad3d812a01c7 /test | |
parent | 1caba629ff8e718a5af054be71338a8c3cb84d62 (diff) | |
download | fuse-aaa5c0931e79453091587e7e625ea92af061c249.tar.gz |
Fixes 477, optional src_dir in tst_(rmdir,unlink) (#493)
tst_rmdir and tst_unlink now pass for passthrough_hp.
Previously, tst_rmdir and tst_unlink created the directory / file
using src_dir, causing the test to fail as the cache was stale.
Now, the src_dir is optional. When cache is enabled, tst_rmdir
and tst_unlink do not provide a src_dir, forcing the test to
use mnt_dir itself.
Diffstat (limited to 'test')
-rwxr-xr-x | test/test_examples.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/test/test_examples.py b/test/test_examples.py index 5d6dacc..da50b2a 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -143,8 +143,8 @@ def test_passthrough(short_tmpdir, name, debug, output_checker, writeback): tst_append(src_dir, work_dir) tst_seek(src_dir, work_dir) tst_mkdir(work_dir) - tst_rmdir(src_dir, work_dir) - tst_unlink(src_dir, work_dir) + tst_rmdir(work_dir, src_dir) + tst_unlink(work_dir, src_dir) tst_symlink(work_dir) if os.getuid() == 0: tst_chown(work_dir) @@ -199,8 +199,14 @@ def test_passthrough_hp(short_tmpdir, cache, output_checker): tst_append(src_dir, mnt_dir) tst_seek(src_dir, mnt_dir) tst_mkdir(mnt_dir) - tst_rmdir(src_dir, mnt_dir) - tst_unlink(src_dir, mnt_dir) + if cache: + # if cache is enabled, no operations should go through + # src_dir as the cache will become stale. + tst_rmdir(mnt_dir) + tst_unlink(mnt_dir) + else: + tst_rmdir(mnt_dir, src_dir) + tst_unlink(mnt_dir, src_dir) tst_symlink(mnt_dir) if os.getuid() == 0: tst_chown(mnt_dir) @@ -387,10 +393,13 @@ def os_open(name, flags): def os_create(name): os.close(os.open(name, os.O_CREAT | os.O_RDWR)) -def tst_unlink(src_dir, mnt_dir): +def tst_unlink(mnt_dir, src_dir=None): name = name_generator() fullname = mnt_dir + "/" + name - with open(pjoin(src_dir, name), 'wb') as fh: + srcname = fullname + if src_dir is not None: + srcname = pjoin(src_dir, name) + with open(srcname, 'wb') as fh: fh.write(b'hello') assert name in os.listdir(mnt_dir) os.unlink(fullname) @@ -410,10 +419,13 @@ def tst_mkdir(mnt_dir): assert fstat.st_nlink in (1,2) assert dirname in os.listdir(mnt_dir) -def tst_rmdir(src_dir, mnt_dir): +def tst_rmdir(mnt_dir, src_dir=None): name = name_generator() fullname = mnt_dir + "/" + name - os.mkdir(pjoin(src_dir, name)) + srcname = fullname + if src_dir is not None: + srcname = pjoin(src_dir, name) + os.mkdir(srcname) assert name in os.listdir(mnt_dir) os.rmdir(fullname) with pytest.raises(OSError) as exc_info: |