diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2004-07-20 22:07:44 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2004-07-20 22:07:44 (GMT) |
commit | a4f651a2ae9288df1006c6f5a1ca922a5120dde1 (patch) | |
tree | cc1782fa721e12738be7c5273ec25d958781ef3a /Lib/test/test_tarfile.py | |
parent | 0662f8a5eaa19f7eed6978eed1af32563359fb93 (diff) | |
download | cpython-a4f651a2ae9288df1006c6f5a1ca922a5120dde1.zip cpython-a4f651a2ae9288df1006c6f5a1ca922a5120dde1.tar.gz cpython-a4f651a2ae9288df1006c6f5a1ca922a5120dde1.tar.bz2 |
SF #857297 and 916874, improve handling of hard links when extracting
Diffstat (limited to 'Lib/test/test_tarfile.py')
-rw-r--r-- | Lib/test/test_tarfile.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index bd3fd8e..52b6204 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -293,6 +293,24 @@ class WriteGNULongTest(unittest.TestCase): self._test(("longnam/" * 127) + "longname_", ("longlnk/" * 127) + "longlink_") +class ExtractHardlinkTest(BaseTest): + + def test_hardlink(self): + """Test hardlink extraction (bug #857297) + """ + # Prevent errors from being caught + self.tar.errorlevel = 1 + + self.tar.extract("0-REGTYPE", dirname()) + try: + # Extract 1-LNKTYPE which is a hardlink to 0-REGTYPE + self.tar.extract("1-LNKTYPE", dirname()) + except EnvironmentError, e: + import errno + if e.errno == errno.ENOENT: + self.fail("hardlink not extracted properly") + + # Gzip TestCases class ReadTestGzip(ReadTest): comp = "gz" @@ -337,6 +355,9 @@ def test_main(): WriteGNULongTest, ] + if hasattr(os, "link"): + tests.append(ExtractHardlinkTest) + if gzip: tests.extend([ ReadTestGzip, ReadStreamTestGzip, |