adjust acceptable size window for compressed unit test data
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Fri, 5 May 2017 12:27:29 +0000 (14:27 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
A low bound of 330 causes the test to fail with version 1.2.3 of
zlib.

Earlier this did not occur because in concat mode, tarfile would
always write an empty zlib compressed chunk right at the
beginning of the archive and then immediately create a new one as
soon as actual input arrived. For this reason, the resulting
archive size remained within the bounds chosen in
test_multivol.py. Due to the removal of the redundancy, this is
no longer the case. The problem is masked on newer versions of
zlib (tested: 1.2.8 of fc25) which create larger compressed files
in general for the same inputs.

For the “test_compress_single” unit test, the input consists of a
an archive 61440 bytes. Compress with level 9, window bits 31,
and a memlevel of 9, the output length is:

    version     size (B)
    1.2.3       308
    1.2.8       324

Add to that the file name in our custom header and the latter
passes 330 B whereas the former doesn’t.

A lower bound of 315 is justified.

testing/test_multivol.py

index 8c9790e..72fb0d9 100644 (file)
@@ -268,7 +268,10 @@ class MultivolGnuFormatTest(BaseTest):
 
         # check size of first volume
         size = os.stat("sample.tar.gz").st_size
-        assert 330 < size < 410, 'size of sample.tar.gz is {}'.format(size)
+        arbitrary_low_size_bound  = 315 # adjust if zlib changes
+        arbitrary_high_size_bound = 410 # adjust if zlib changes
+        assert arbitrary_low_size_bound < size < arbitrary_high_size_bound, \
+               'size of sample.tar.gz is {}'.format(size)
 
         os.unlink("big")
         assert not os.path.exists("big")