Skip to content

Commit

Permalink
Add a testcase for strip_path
Browse files Browse the repository at this point in the history
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 <zz@zoranzaric.de>
  • Loading branch information
zoranzaric authored and apenwarr committed Jan 8, 2011
1 parent 0ee1a48 commit f2d396c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/bup/t/thelpers.py
@@ -1,3 +1,4 @@
import os
from bup.helpers import *
from wvtest import *

Expand Down Expand Up @@ -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")

0 comments on commit f2d396c

Please sign in to comment.