From: Nikolaus Rath Date: Thu, 6 Apr 2017 05:45:31 +0000 (-0700) Subject: Added tst_unlink() X-Git-Tag: fuse-3.0.1~20 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=d4092d70db9e3bda52a80ea0c687ed0d0e110124;p=qemu-gpiodev%2Flibfuse.git Added tst_unlink() To check for unlink() support without requiring create()/mknod(). --- diff --git a/test/test_examples.py b/test/test_examples.py index 3bc3674..d7de380 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -86,6 +86,7 @@ def test_passthrough(tmpdir, name, debug): tst_rmdir(src_dir, work_dir) tst_symlink(work_dir) tst_mknod(work_dir) + tst_unlink(src_dir, work_dir) if os.getuid() == 0: tst_chown(work_dir) # Underlying fs may not have full nanosecond resolution @@ -292,6 +293,18 @@ def checked_unlink(filename, path, isdir=False): assert exc_info.value.errno == errno.ENOENT assert filename not in os.listdir(path) +def tst_unlink(src_dir, mnt_dir): + name = name_generator() + fullname = mnt_dir + "/" + name + with open(pjoin(src_dir, name), 'wb') as fh: + fh.write(b'hello') + assert name in os.listdir(mnt_dir) + os.unlink(fullname) + with pytest.raises(OSError) as exc_info: + os.stat(fullname) + assert exc_info.value.errno == errno.ENOENT + assert name not in os.listdir(mnt_dir) + def tst_mkdir(mnt_dir): dirname = name_generator() fullname = mnt_dir + "/" + dirname