From: Zoran Zaric Date: Fri, 7 Jan 2011 11:16:23 +0000 (+0100) Subject: Add a testcase for strip_path X-Git-Tag: bup-0.21^2~1 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=bup.git;a=commitdiff_plain;h=f2d396cb9811c6aaa5ea1f500873ccbde9a04149 Add a testcase for strip_path As reported by Aleksandr Milewski strip_path has a bug when the prefix is a symlink. This case is addressed with this test. Signed-off-by: Zoran Zaric --- diff --git a/lib/bup/t/thelpers.py b/lib/bup/t/thelpers.py index 306d39b..ebb80f8 100644 --- a/lib/bup/t/thelpers.py +++ b/lib/bup/t/thelpers.py @@ -1,3 +1,4 @@ +import os from bup.helpers import * from wvtest import * @@ -28,3 +29,25 @@ def test_strip_base_path(): path = "/var/backup/daily.0/localhost/etc/" base_paths = ["/var", "/var/backup", "/var/backup/daily.0/localhost"] WVPASSEQ(strip_base_path(path, base_paths), '/etc') + +@wvtest +def test_strip_symlinked_base_path(): + tmpdir = os.path.join(os.getcwd(),"test_strip_symlinked_base_path.tmp") + symlink_src = os.path.join(tmpdir, "private", "var") + symlink_dst = os.path.join(tmpdir, "var") + path = os.path.join(symlink_dst, "a") + + os.mkdir(tmpdir) + os.mkdir(os.path.join(tmpdir, "private")) + os.mkdir(symlink_src) + os.symlink(symlink_src, symlink_dst) + + result = strip_base_path(path, [symlink_dst]) + + os.remove(symlink_dst) + os.rmdir(symlink_src) + os.rmdir(os.path.join(tmpdir, "private")) + os.rmdir(tmpdir) + + WVPASSEQ(result, "/a") +