From: Nikolaus Rath Date: Thu, 6 Apr 2017 05:50:25 +0000 (-0700) Subject: Turn tst_mknod() into tst_create() X-Git-Tag: fuse-3.0.1~18 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4cfc2740b266ccaf8428c0d78c6d913480421d4c;p=qemu-gpiodev%2Flibfuse.git Turn tst_mknod() into tst_create() Ensure that we are really creating a new file. Don't attempt to write, we do that in tst_open_write(). --- diff --git a/test/test_examples.py b/test/test_examples.py index 9bea3e9..686d8ba 100755 --- a/test/test_examples.py +++ b/test/test_examples.py @@ -84,8 +84,8 @@ def test_passthrough(tmpdir, name, debug): tst_mkdir(work_dir) tst_rmdir(src_dir, work_dir) tst_open_write(src_dir, work_dir) + tst_create(work_dir) tst_symlink(work_dir) - tst_mknod(work_dir) tst_unlink(src_dir, work_dir) if os.getuid() == 0: tst_chown(work_dir) @@ -337,15 +337,22 @@ def tst_symlink(mnt_dir): assert linkname in os.listdir(mnt_dir) checked_unlink(linkname, mnt_dir) -def tst_mknod(mnt_dir): - filename = pjoin(mnt_dir, name_generator()) - shutil.copyfile(TEST_FILE, filename) - fstat = os.lstat(filename) +def tst_create(mnt_dir): + name = name_generator() + fullname = pjoin(mnt_dir, name) + 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) + + fd = os.open(fullname, os.O_CREAT | os.O_RDWR) + os.close(fd) + + assert name in os.listdir(mnt_dir) + fstat = os.lstat(fullname) assert stat.S_ISREG(fstat.st_mode) assert fstat.st_nlink == 1 - assert os.path.basename(filename) in os.listdir(mnt_dir) - assert filecmp.cmp(TEST_FILE, filename, False) - checked_unlink(filename, mnt_dir) + assert fstat.st_size == 0 def tst_chown(mnt_dir): filename = pjoin(mnt_dir, name_generator())