Skip to content

Commit

Permalink
tests: add test_readdir_big()
Browse files Browse the repository at this point in the history
  • Loading branch information
ligurio committed Feb 27, 2021
1 parent 0e7d31e commit 0e01f7a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/test_unreliablefs.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,31 @@ def test_readdir(setup_unreliablefs):
os.rmdir(subdir)
os.rmdir(src_newdir)

def test_readdir_big(setup_unreliablefs):
mnt_dir, src_dir = setup_unreliablefs

# Add enough entries so that readdir needs to be called
# multiple times.
fnames = []
for i in range(500):
fname = ('A rather long filename to make sure that we '
'fill up the buffer - ' * 3) + str(i)
with open(pjoin(src_dir, fname), 'w') as fh:
fh.write('File %d' % i)
fnames.append(fname)

listdir_is = sorted(os.listdir(mnt_dir))
listdir_should = sorted(os.listdir(src_dir))
assert listdir_is == listdir_should

for fname in fnames:
stat_src = os.stat(pjoin(src_dir, fname))
stat_mnt = os.stat(pjoin(mnt_dir, fname))
assert stat_src.st_mtime == stat_mnt.st_mtime
assert stat_src.st_ctime == stat_mnt.st_ctime
assert stat_src.st_size == stat_mnt.st_size
os.unlink(pjoin(src_dir, fname))

def test_truncate_path(setup_unreliablefs):
mnt_dir, src_dir = setup_unreliablefs
assert len(TEST_DATA) > 1024
Expand Down

0 comments on commit 0e01f7a

Please sign in to comment.