commit ae52aaa51d2f9eedf103448dcdb7e9dfef5273cb from: Sergey Bronnikov date: Sat Feb 27 16:11:12 2021 UTC tests: add test_readdir_big() commit - 8895eb30f0af8eb746db0c68dd8d77201fe1cd08 commit + ae52aaa51d2f9eedf103448dcdb7e9dfef5273cb blob - f135b239d95584cb077c01c29dceaf5e8f9f365a blob + f5ae84859eb38ab5f3cd0ba8ebcff1e7e24e9093 --- tests/test_unreliablefs.py +++ tests/test_unreliablefs.py @@ -292,7 +292,32 @@ def test_readdir(setup_unreliablefs): os.unlink(subfile) 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