From bb47a2d79dd3710e537117713dd8aa722a1f5f3a Mon Sep 17 00:00:00 2001 From: Daniel Garcia Moreno Date: Mon, 8 Jul 2013 21:03:01 +0200 Subject: [PATCH] Test to check extract of gnu-tar file with multiple files and volumes --- testing/test_multivol.py | 35 +++++++++++++++++++++++++++++++++++ 1 files changed, 35 insertions(+), 0 deletions(-) diff --git a/testing/test_multivol.py b/testing/test_multivol.py index 688bd41..45157d4 100644 --- a/testing/test_multivol.py +++ b/testing/test_multivol.py @@ -249,6 +249,41 @@ class MultivolGnuFormatTest(unittest.TestCase): 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 -- 1.7.1