adapt concat_compress unit tests to gzip block sequence
authorPhilipp Gesang <philipp.gesang@intra2net.com>
Thu, 6 Apr 2017 13:42:15 +0000 (15:42 +0200)
committerThomas Jarosch <thomas.jarosch@intra2net.com>
Mon, 2 Apr 2018 11:34:08 +0000 (13:34 +0200)
The unit tests assume that compression of three files requires
three distinct Gzip blocks. The first one of these is empty and
serves no purpose, differing from the others by containing the
more or less redundant archive name. This is no longer the case
after the revision of the header code: the first block will still
have the archive name in the metadata but also contain the first
file.

Thus, adapt the unit tests to no longer check for and then ignore
the empty initial gzip block.

testing/test_concat_compress.py

index 56f58e0..2359bec 100644 (file)
@@ -315,7 +315,6 @@ class ConcatCompressTest(BaseTest):
         individually decompressed and "untarred", thanks to be using the
         concat gzip tar format.
         '''
-
         # create sample data
         hash = dict()
         hash["big"] = self.create_file("big", 50000)
@@ -339,14 +338,13 @@ class ConcatCompressTest(BaseTest):
 
         filesplit.split_file(GZ_MAGIC_BYTES, "sample.tar.gz.", "sample.tar.gz")
 
-        assert os.path.exists("sample.tar.gz.0") # beginning of the tar file
-        assert os.path.exists("sample.tar.gz.1") # first file
-        assert os.path.exists("sample.tar.gz.2") # second file
-        assert os.path.exists("sample.tar.gz.3") # third file
-        assert not os.path.exists("sample.tar.gz.4") # nothing else
+        assert os.path.exists("sample.tar.gz.0") # first file
+        assert os.path.exists("sample.tar.gz.1") # second file
+        assert os.path.exists("sample.tar.gz.2") # third file
+        assert not os.path.exists("sample.tar.gz.3") # nothing else
 
         # extract and check output
-        for i in range(1, 4):
+        for i in range(0, 3):
             tarobj = TarFile.open("sample.tar.gz.%d" % i,
                                 mode="r|gz")
             tarobj.extractall()
@@ -388,14 +386,13 @@ class ConcatCompressTest(BaseTest):
         # extract using the command line this time
         os.system("python3 filesplit.py -s $'\\x1f\\x8b' -p sample.tar.gz. sample.tar.gz")
 
-        assert os.path.exists("sample.tar.gz.0") # beginning of the tar file
-        assert os.path.exists("sample.tar.gz.1") # first file
-        assert os.path.exists("sample.tar.gz.2") # second file
-        assert os.path.exists("sample.tar.gz.3") # third file
-        assert not os.path.exists("sample.tar.gz.4") # nothing else
+        assert os.path.exists("sample.tar.gz.0") # first file
+        assert os.path.exists("sample.tar.gz.1") # second file
+        assert os.path.exists("sample.tar.gz.2") # third file
+        assert not os.path.exists("sample.tar.gz.3") # nothing else
 
         # extract and check output
-        for i in range(1, 4):
+        for i in range(0, 3):
             os.system("gzip -cd sample.tar.gz.%d > sample.%d.tar" % (i, i))
             os.system("tar xf sample.%d.tar" % i)
 
@@ -441,21 +438,20 @@ class ConcatCompressTest(BaseTest):
         # equivalent to $ python filesplit.py -s $'\x1f\x8b' -p sample.tar.gz. sample.tar.gz
         filesplit.split_file(GZ_MAGIC_BYTES, "sample.tar.gz.", "sample.tar.gz")
 
-        assert os.path.exists("sample.tar.gz.0") # beginning of the tar file
-        assert os.path.exists("sample.tar.gz.1") # first file
-        assert os.path.exists("sample.tar.gz.2") # second file
-        assert os.path.exists("sample.tar.gz.3") # third file
-        assert not os.path.exists("sample.tar.gz.4") # nothing else
+        assert os.path.exists("sample.tar.gz.0") # first file
+        assert os.path.exists("sample.tar.gz.1") # second file
+        assert os.path.exists("sample.tar.gz.2") # third file
+        assert not os.path.exists("sample.tar.gz.3") # nothing else
 
         # extract and check output
-        for i in range(1, 4):
+        for i in range(0, 3):
             try:
                 tarobj = TarFile.open("sample.tar.gz.%d" % i,
                                     mode="r|gz")
                 tarobj.extractall()
                 tarobj.close()
             except Exception as e:
-                if i == 1: # big file doesn't extract well because it's corrupted
+                if i == 0: # big file doesn't extract well because it's corrupted
                     pass
                 else:
                     raise Exception("Error extracting a tar.gz not related to the broken 'big' file")