started a unittest for multi-volume with compression
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 8 Jun 2016 15:50:25 +0000 (17:50 +0200)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Wed, 15 Jun 2016 11:18:02 +0000 (13:18 +0200)
testing/test_multivol.py

index 0026881..de7eaed 100644 (file)
@@ -216,6 +216,44 @@ class MultivolGnuFormatTest(BaseTest):
 
         print('max err is {}, post={}'.format(max_err, max_err_post))
 
+    def test_multivol_compress(self):
+        ''' check creation of multiple volume when compression is on '''
+
+        # create the content of the file to compress and hash it
+        hash = self.create_file("big", 50000)
+
+        # create the tar file with volumes and compression
+        tarobj = TarFile.open("sample.tar.gz",
+                              mode="w#gz",
+                              format=self.tarfile_format,
+                              max_volume_size=30000,
+                              new_volume_handler=new_volume_handler,
+                              debug=3)
+        tarobj.add("big")
+        tarobj.list()
+        tarobj.close()
+
+        # check that the tar volumes were correctly created
+        assert os.path.exists("sample.tar.gz")
+        assert os.path.exists("sample.tar.gz.1")
+        assert not os.path.exists("sample.tar.gz.2")
+
+        # TODO: check size of first tar!
+
+        os.unlink("big")
+        assert not os.path.exists("big")
+
+        # extract with normal tar and check output
+        print('unpacking:')
+        import subprocess
+        output = subprocess.check_output(
+            "tar xvfM sample.tar.gz --file=sample.tar.gz.1".split(),
+            universal_newlines=True)
+        for line in output.splitlines():
+            print(line.rstrip())
+        assert os.path.exists("big")
+        assert hash == self.md5sum("big")
+
     def test_volume_extract1(self):
         '''
         Create a tar file with multiple volumes and one file and extract it