[elbe-devel] [PATCH 3/3] tests efilesystem: add deeplinks test for copy_filelist()
Torben Hohn
torben.hohn at linutronix.de
Thu Mar 5 12:12:26 CET 2020
/bin -> usr/bin is located at the rootlevel. This works with the current
implementation in copy_filelist(). But when a link is relative and deeper
in the directory hirarchy, things break.
Add a test for this case.
Needs cleanup in the comments.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/tests/test_efilesystem.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/elbepack/tests/test_efilesystem.py b/elbepack/tests/test_efilesystem.py
index d37eac291..07c0961d0 100644
--- a/elbepack/tests/test_efilesystem.py
+++ b/elbepack/tests/test_efilesystem.py
@@ -42,3 +42,23 @@ class TestCopyFilelist(unittest.TestCase):
copy_filelist(src, ['/bin', '/bin/bla'], dst)
self.assertEqual(dst.read_file('/usr/bin/bla'), 'bla')
+
+ def test_deeplinks(self):
+ src = TmpdirFilesystem()
+ src.mkdir_p('/a/b/c')
+
+ # create a proper relative path, that should
+ # work fine from inside.
+ src.symlink('c', '/a/b/d')
+
+ # we would actually want to write to /bin/bla
+ # but since the link points to /usr/bin without
+ # chroot, this is not possible.
+ src.write_file('/a/b/c/bla', 0o644, 'bla')
+
+ dst = TmpdirFilesystem()
+
+ copy_filelist(src, ['/a', '/a/b', '/a/b/d', '/a/b/d/bla'], dst)
+
+ self.assertEqual(dst.read_file('/usr/bin/bla'), 'bla')
+
--
2.20.1
More information about the elbe-devel
mailing list