From 43abf3d9e5736423fb1bb5d975b03f792bfc1297 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 15 Jun 2016 11:18:55 +0200 Subject: [PATCH] added minimum file size arg to find_random_files should make returned files more realistic --- testing/test_multivol_compression_sizes.py | 11 +++++++++-- 1 files changed, 9 insertions(+), 2 deletions(-) diff --git a/testing/test_multivol_compression_sizes.py b/testing/test_multivol_compression_sizes.py index 70895a9..58f09fc 100644 --- a/testing/test_multivol_compression_sizes.py +++ b/testing/test_multivol_compression_sizes.py @@ -70,13 +70,16 @@ def _get_random_file(dir_name, rec_level): return entry -def find_random_files(): +def find_random_files(min_file_size=100): """ generator over random file names Checks if files are readable by user (os.access) and excludes dirs with most volatile files and mounts; will still yield links or -- with a small probablility -- names of dirs with many parents (no '/usr' but maybe /usr/local/lib/python/site-packages/deltatar) + + :param int min_file_size: size (in bytes) that returned files have to have + at least """ # prepare list of dirs in START_DIR that are not EXCLUDE_DIRS @@ -102,7 +105,11 @@ def find_random_files(): if not os.access(next_result, os.R_OK): #print('cannot access {}, try next'.format(next_result)) continue - mode = os.stat(next_result).st_mode + statres = os.lstat(next_result) + if statres.st_size < min_file_size: + #print('file {} too small'.format(next_result)) + continue + mode = statres.st_mode if not any(mode_test(mode) for mode_test in OK_MODES): #print('mode not accepted for {}, try next'.format(next_result)) continue -- 1.7.1