- add a file that nearly fills the volume
- add a small file that should just fit in or not
- check expected number and size of volumes
-- repeat with max_volume_size +1, -1, +2, -2, +10, -10
-
-Repeat with compressed/encrypted data; for this have to find some random data
-that is repeatable (--> :py:mod:`create_pseudo_random_files`) and experiment a
-bit for suitable seeds and sizes
-
-e.g. for max_volume_size = RECORDSIZE + 1 * BLOCKSIZE
+- repeat with max_volume_size +1, +2, +10, ...
+- repeat with file sizes -1, -2, -10, ...
+e.g. for max_volume_size = RECORDSIZE + 1 * BLOCKSIZE:
File 0 has Info0 and blocks Dat00, Dat01, ... Dat0K, (Dat0L, Dat0M, Dat0N)
File 1 has Info1 and blocks Dat10, (Dat11)
end of end of
+-------+-------+-------+ ... +-------+-------+-------+-------+-------+
2: file0 needs next block: blocks = [MAX_VOLUME_BLOCKS-4, 1]
+ --> will add one block of zeros after end of volume
vol0: | Info0 | Dat00 | Dat01 | ... | Dat0K | Dat0L | Info1 | Dat10 | 0 | 0
+-------+-------+-------+ ... +-------+-------+-------+-------+-------+
3: file0 needs 2 more blocks: blocks = [MAX_VOLUME_BLOCKS-3, 1]
+ --> will add two blocks of zeros after end of volume
vol0: | Info0 | Dat00 | Dat01 | ... | Dat0K | Dat0L | Dat0M | Info1 | Dat10 |00
+-------+-------+-------+ ... +-------+-------+-------+-------+-------+
6: both need next block: blocks = [MAX_VOLUME_BLOCKS-4, 2]
vol0: | Info0 | Dat00 | Dat01 | ... | Dat0K | Dat0L | Info1 | Dat10 | |
-vol1: | VOL | Dat11 | 0 | 0 | | | | | |
+vol1: | VOL | Dat11 | 0 |0|...| | | | | |
+-------+-------+-------+ ... +-------+-------+-------+-------+-------+
-single huge file: blocks = [MAX_VOLUME_BLOCKS * 3,]
+(not tested: single huge file)
vol0: | Info0 | Dat00 | Dat01 | ... | Dat02 | Dat03 | Dat04 | wasted space |
-vol1: | VOL | Dat05 | Dat06 | Dat07 | ... | Dat08 | Dat09 | wasted space |
+vol1: | VOL | Dat05 | Dat06 | ... | Dat07 | Dat08 | Dat09 | wasted space |
vol2: | ... | | | | | | | | |
+-------+-------+-------+ ... +-------+-------+-------+-------+-------+
#: number of blocks per tar volume file
MAX_VOLUME_BLOCKS = N_BLOCKS_PER_RECORD + 1
+#: always print all test output; will produce ~10 lines of text for each of the
+#: ~48000 tests --> not recommended
+ALWAYS_PRINT_EVERYTHING = False
def fill_file(file_handle, data_size):
""" fill given file handle with nonsense data of given size """
file_size_offsets=(0, 0), volume_size_offset=0):
""" create TarFile with given configuration """
- # use "delayed" print dprnt, that only prints if necessary (i.e. something
- # went wrong)
+ # use delayed + conditional print dprnt, that only prints if necessary
+ # (i.e. if something went wrong)
output = []
dprnt = output.append
+ dprnt('-' * 72)
dprnt('testing with {} file blocks, expect {} volume blocks'
.format(file_blocks, volume_blocks_arg))
dprnt('expect offsets to be {} blocks'.format(offset_blocks))
size_str(expected_blocks * BLOCKSIZE)))
# print output only if something went wrong
- if not everything_ok:
+ if (not everything_ok) or ALWAYS_PRINT_EVERYTHING:
for line in output:
print(line)
n_errs = 0
n_tests = 0
n_tests_overall = len(tests) * len(size_offsets)**3
- with TemporaryDirectory() as temp_dir:
+ with TemporaryDirectory(prefix='deltatar_test_') as temp_dir:
for size_comb_idx, (file_sizes, vol_sizes, offsets) \
in enumerate(tests):
if fast_fail and n_errs > 0:
break
- print('-' * 72)
+ print('=' * 72)
print('size combination {}: ({}, {})'
.format(size_comb_idx, *file_sizes))
for volume_size_offset in size_offsets:
volume_size_offset=volume_size_offset)
if not test_succeeded:
n_errs += 1
+ if fast_fail:
+ print('stopping after test {} (fast-fail set)'
+ .format(n_tests))
return n_errs