assert os.path.exists("big")
assert hash == self.md5sum("big")
+ def test_volume_extract3(self):
+ '''
+ Create a multivolume tar file with gnu tar command with multiple
+ files, extract it with tarfile library
+ '''
+ # create the content of the file to compress and hash it
+ hash = dict()
+ hash["big"] = self.create_file("big", 5*1024*1024)
+ hash["small"] = self.create_file("small", 100)
+ hash["small2"] = self.create_file("small2", 354)
+
+ # create the tar file with volumes
+ os.system("tar cM --format=%s -L 3M big small small2 --file=sample.tar "\
+ "--file=sample.tar.1" % self.tar_command_format)
+
+ # check that the tar volumes were correctly created
+ assert os.path.exists("sample.tar")
+ assert os.path.exists("sample.tar.1")
+ assert not os.path.exists("sample.tar.2")
+
+ for key, value in hash.iteritems():
+ os.unlink(key)
+ assert not os.path.exists(key)
+
+ # extract and check output
+ tarobj = TarFile.open("sample.tar",
+ mode="r",
+ new_volume_handler=new_volume_handler)
+ tarobj.extractall()
+ tarobj.close()
+
+ for key, value in hash.iteritems():
+ assert os.path.exists(key)
+ assert value == self.md5sum(key)
+
def test_multivol_multifile_extract(self):
'''
create a multivolume tar file with multiple files and extracts it