]> arthur.barton.de Git - bup.git/commitdiff
Add a testcase for strip_path
authorZoran Zaric <zz@zoranzaric.de>
Fri, 7 Jan 2011 11:16:23 +0000 (12:16 +0100)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 8 Jan 2011 09:47:59 +0000 (01:47 -0800)
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>
lib/bup/t/thelpers.py

index 306d39b943118b3dc0698354fd00e518ac3b2a9b..ebb80f8ec17af8c58fb363fff4fb90c0fe46cb9d 100644 (file)
@@ -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")
+