[elbe-devel] [RFC PATCH 3/6] tests efilesystem: Add tests for copy_fileslist
Olivier Dion
dion at linutronix.de
Tue Apr 7 21:32:43 CEST 2020
From: Torben Hohn <torben.hohn at linutronix.de>
In buster /bin is just a link to /usr/bin. This poses problems with
elbepack.efilesystem.copy_filelist() for example when the link is
absolute.
Write 2 testcases for the usrmerge 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 | 45 ++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 elbepack/tests/test_efilesystem.py
diff --git a/elbepack/tests/test_efilesystem.py b/elbepack/tests/test_efilesystem.py
new file mode 100644
index 00000000..d0f2d8fb
--- /dev/null
+++ b/elbepack/tests/test_efilesystem.py
@@ -0,0 +1,45 @@
+
+import unittest
+
+from elbepack.filesystem import TmpdirFilesystem
+from elbepack.efilesystem import copy_filelist
+
+class TestCopyFilelist(unittest.TestCase):
+
+ def setUp(self):
+ self.src = TmpdirFilesystem()
+ self.dst = TmpdirFilesystem()
+
+ def test_usrmerge_abs(self):
+
+ self.src.mkdir_p('/usr/bin')
+
+ # this will link to /usr/bin in the host RFS,
+ # when no special logic is applied.
+ self.src.symlink('/usr/bin', '/bin')
+
+ # we would actually want to write to /bin/bla
+ # but since the link points to /usr/bin without
+ # chroot, this is not possible.
+ self.src.write_file('/usr/bin/bla', 0o644, 'bla')
+
+ copy_filelist(self.src, ['/bin/bla'], self.dst)
+
+ self.assertEqual(self.dst.read_file('/usr/bin/bla'), 'bla')
+
+ def test_usrmerge_rel(self):
+
+ self.src.mkdir_p('/usr/bin')
+
+ # create a proper relative path, that should
+ # work fine from inside.
+ self.src.symlink('usr/bin', '/bin')
+
+ # we would actually want to write to /bin/bla
+ # but since the link points to /usr/bin without
+ # chroot, this is not possible.
+ self.src.write_file('/usr/bin/bla', 0o644, 'bla')
+
+ copy_filelist(self.src, ['/bin/bla'], self.dst)
+
+ self.assertEqual(self.dst.read_file('/usr/bin/bla'), 'bla')
--
2.26.0
More information about the elbe-devel
mailing list