aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-05 22:48:00 -0700
committerGravatar Nikolaus Rath <Nikolaus@rath.org>2017-04-07 16:40:15 -0700
commitdeb2fa355a29c1101ab566c4036b0992e0c14aa9 (patch)
tree089a717ce5a6bad0308aedd5f85372ca0a968b0b /test
parentd4092d70db9e3bda52a80ea0c687ed0d0e110124 (diff)
Renamed tst_write() to tst_open_write()
We are actually testing both opening of an existing file and writing to it.
Diffstat (limited to 'test')
-rwxr-xr-xtest/test_examples.py19
1 files changed, 12 insertions, 7 deletions
diff --git a/test/test_examples.py b/test/test_examples.py
index d7de380..9bea3e9 100755
--- a/test/test_examples.py
+++ b/test/test_examples.py
@@ -80,10 +80,10 @@ def test_passthrough(tmpdir, name, debug):
subprocess.check_call([ os.path.join(basename, 'test', 'test_syscalls'),
work_dir, ':' + src_dir ])
- tst_write(work_dir)
tst_readdir(src_dir, work_dir)
tst_mkdir(work_dir)
tst_rmdir(src_dir, work_dir)
+ tst_open_write(src_dir, work_dir)
tst_symlink(work_dir)
tst_mknod(work_dir)
tst_unlink(src_dir, work_dir)
@@ -367,12 +367,17 @@ def tst_chown(mnt_dir):
assert fstat.st_gid == gid_new
checked_unlink(filename, mnt_dir, isdir=True)
-
-def tst_write(mnt_dir):
- name = pjoin(mnt_dir, name_generator())
- shutil.copyfile(TEST_FILE, name)
- assert filecmp.cmp(name, TEST_FILE, False)
- checked_unlink(name, mnt_dir)
+def tst_open_write(src_dir, mnt_dir):
+ name = name_generator()
+ fd = os.open(pjoin(src_dir, name),
+ os.O_CREAT | os.O_RDWR)
+ os.close(fd)
+ fullname = pjoin(mnt_dir, name)
+ with open(fullname, 'wb') as fh_out, \
+ open(TEST_FILE, 'rb') as fh_in:
+ shutil.copyfileobj(fh_in, fh_out)
+
+ assert filecmp.cmp(fullname, TEST_FILE, False)
def tst_open_unlink(mnt_dir):
name = pjoin(mnt_dir, name_generator())