From: Philipp Gesang Date: Fri, 11 Aug 2017 09:39:42 +0000 (+0200) Subject: test recovery behavior with traling data X-Git-Tag: v2.2~7^2~79 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=517d35b782681803fc2f3241e485029fdffae037;p=python-delta-tar test recovery behavior with traling data --- diff --git a/runtests.py b/runtests.py index 6e25aba..d8128b8 100755 --- a/runtests.py +++ b/runtests.py @@ -31,7 +31,10 @@ from testing.test_recover import \ , RecoverCorruptHeaderGZAESTest \ , RecoverCorruptEntireHeaderTest \ , RecoverCorruptEntireHeaderGZTest \ - , RecoverCorruptEntireHeaderGZAESTest + , RecoverCorruptEntireHeaderGZAESTest \ + , RecoverCorruptTrailingDataTest \ + , RecoverCorruptTrailingDataGZTest \ + , RecoverCorruptTrailingDataGZAESTest from testing.test_rescue_tar import RescueTarTest from testing.test_encryption import EncryptionTest from testing.test_deltatar import (DeltaTarTest, DeltaTar2Test, @@ -75,6 +78,9 @@ if __name__ == "__main__": , RecoverCorruptEntireHeaderTest , RecoverCorruptEntireHeaderGZTest , RecoverCorruptEntireHeaderGZAESTest + , RecoverCorruptTrailingDataTest + , RecoverCorruptTrailingDataGZTest + , RecoverCorruptTrailingDataGZAESTest ]: try: t = group (n) diff --git a/testing/test_recover.py b/testing/test_recover.py index 8d7d5b9..e062980 100644 --- a/testing/test_recover.py +++ b/testing/test_recover.py @@ -118,6 +118,15 @@ def corrupt_payload_start (_, fname, compress, encrypt): flip_bits (fname, tarfile.BLOCKSIZE + 1) +def corrupt_trailing_data (_, fname, compress, encrypt): + """ + Modify the byte following the object header structure of the format. + """ + junk = os.urandom (42) + fd = os.open (fname, os.O_WRONLY | os.O_APPEND) + os.write (fd, junk) + os.close (fd) + ############################################################################### ## tests ## @@ -326,3 +335,32 @@ class RecoverCorruptEntireHeaderGZAESTest (RecoverTest): CORRUPT = corrupt_entire_header MISMATCHES = 0 + +class RecoverCorruptTrailingDataTest (RecoverTest): + # plain Tar is indifferent against traling data and the results + # are consistent + COMPRESSION = None + PASSWORD = None + FAILURES = 0 + CORRUPT = corrupt_trailing_data + MISMATCHES = 0 + + +class RecoverCorruptTrailingDataGZTest (RecoverTest): + # reading past the final object will cause decompression failure; + # all objects except for the last survive unharmed though + COMPRESSION = "#gz" + PASSWORD = None + FAILURES = 1 + CORRUPT = corrupt_trailing_data + MISMATCHES = 0 + + +class RecoverCorruptTrailingDataGZAESTest (RecoverTest): + COMPRESSION = "#gz" + PASSWORD = TEST_PASSWORD + FAILURES = 0 + CORRUPT = corrupt_trailing_data + MISMATCHES = 0 + +