[elbe-devel] [RFC PATCH 4/6] tests efilesystem: Add deeplinks test for copy_filelist

Olivier Dion dion at linutronix.de
Tue Apr 7 21:32:44 CEST 2020


From: Torben Hohn <torben.hohn at linutronix.de>

/bin -> usr/bin is located at the root level. This works with the
current implementation in copy_filelist(). But when a link is relative
and deeper in the directory hierarchy, things break.

Add a test for this case.

Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
 elbepack/tests/test_efilesystem.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/elbepack/tests/test_efilesystem.py b/elbepack/tests/test_efilesystem.py
index d0f2d8fb..49d111e8 100644
--- a/elbepack/tests/test_efilesystem.py
+++ b/elbepack/tests/test_efilesystem.py
@@ -43,3 +43,20 @@ class TestCopyFilelist(unittest.TestCase):
         copy_filelist(self.src, ['/bin/bla'], self.dst)
 
         self.assertEqual(self.dst.read_file('/usr/bin/bla'), 'bla')
+
+    def test_deeplinks(self):
+
+        self.src.mkdir_p('/a/b/c')
+
+        # create a proper relative path, that should
+        # work fine from inside.
+        self.src.symlink('c', '/a/b/d')
+
+        # we would actually want to write to /a/b/d/bla but since the
+        # link points to /a/b/c/bla (c instead of d) without chroot,
+        # this is not possible.
+        self.src.write_file('/a/b/d/bla', 0o644, 'bla')
+
+        copy_filelist(self.src, ['/a/b/d/bla'], self.dst)
+
+        self.assertEqual(self.dst.read_file('/a/b/c/bla'), 'bla')
-- 
2.26.0




More information about the elbe-devel mailing list