From c7d9cd3be7bf20a5fe14c5a0e2c2445253016602 Mon Sep 17 00:00:00 2001 From: Christian Herdtweck Date: Wed, 27 Jul 2016 09:49:26 +0200 Subject: [PATCH] minor improvements --- testing/test_volume_split.py | 20 +++++++++++++------- 1 files changed, 13 insertions(+), 7 deletions(-) diff --git a/testing/test_volume_split.py b/testing/test_volume_split.py index 2c96631..0f1660b 100755 --- a/testing/test_volume_split.py +++ b/testing/test_volume_split.py @@ -49,7 +49,7 @@ N_BLOCKS_PER_RECORD = RECORDSIZE // BLOCKSIZE MAX_VOLUME_BLOCKS = N_BLOCKS_PER_RECORD + 1 #: size of big file: fits into first volume even if not compressed -BIG_SIZE = (MAX_VOLUME_BLOCKS-3) * BLOCKSIZE +BIG_SIZE = (MAX_VOLUME_BLOCKS-4) * BLOCKSIZE #: max size of small files SMALL_MAX_SIZE = 2 * BLOCKSIZE @@ -64,7 +64,7 @@ SEED_BITS = int(log2(sys.maxsize+1)) HASH_BUF_SIZE = 4096 #: modes for tar file creation -CREATE_MODES = 'w:tar', 'w|tar', 'w|gz', 'w|bz2', 'w#gz' +CREATE_MODES = 'w:tar', 'w|tar', 'w|gz', 'w|bz2', 'w#gz', \ #'w#gz.aes128', 'w#gz.aes256', 'w#aes128', 'w#aes256' # not currently working: 'w:gz', 'w:bz2', @@ -150,7 +150,7 @@ def do_test(seed, create_mode, extract_mode, temp_dir, print_everything=False): output = [] if print_everything: print('-' * 72) - prefix = '{:9d}: '.format(seed) + prefix = '{:10d}: '.format(seed) dprnt = lambda val: print(prefix + val) else: dprnt = output.append @@ -207,7 +207,7 @@ def do_test(seed, create_mode, extract_mode, temp_dir, print_everything=False): # add big file big_name, big_hash, file_info = create_file(BIG_SIZE, temp_dir) - files[big_name] = big_hash + files[big_name] = (big_hash, BIG_SIZE) dprnt('adding big file {} of size {}, info {} with hash {}' .format(big_name, BIG_SIZE, file_info, big_hash)) tarobj.add(big_name, arcname=basename(big_name)) @@ -226,7 +226,7 @@ def do_test(seed, create_mode, extract_mode, temp_dir, print_everything=False): small_size = random.randint(0, SMALL_MAX_SIZE) small_name, small_hash, file_info = create_file(small_size, temp_dir) - files[small_name] = small_hash + files[small_name] = (small_hash, small_size) dprnt('adding small file {} of size {}, info {} with hash {}' .format(small_name, small_size, file_info, small_hash)) tarobj.add(small_name, arcname=basename(small_name)) @@ -269,12 +269,18 @@ def do_test(seed, create_mode, extract_mode, temp_dir, print_everything=False): for file_name in os.listdir(temp_dir): dprnt('listdir: {}'.format(file_name)) - for file_name, file_hash in files.items(): + for file_name, (file_hash, file_size) in files.items(): if not os.path.exists(file_name): everything_ok = False dprnt('failed to find file {} after extraction' .format(file_name)) continue + if os.stat(file_name).st_size != file_size: + everything_ok = False + dprnt('wrong size for file {} after extraction: {} != {}' + .format(file_name, os.stat(file_name).st_size, + file_size)) + continue if hash_file(file_name) != file_hash: everything_ok = False dprnt('wrong hash for file {} after extraction: {} != {}' @@ -296,7 +302,7 @@ def do_test(seed, create_mode, extract_mode, temp_dir, print_everything=False): pass if (not print_everything) and (not everything_ok): - prefix = '{:9d}: '.format(seed) + prefix = '{:10d}: '.format(seed) for line in output: print(prefix + line) elif print_everything and everything_ok: -- 1.7.1