[elbe-devel] [RFC PATCH 3/6] tests efilesystem: Add tests for copy_fileslist
Torben Hohn
torben.hohn at linutronix.de
Wed Apr 15 16:38:52 CEST 2020
On Tue, Apr 07, 2020 at 03:32:43PM -0400, Olivier Dion wrote:
> 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.
please fix the comment.
> + 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
>
--
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
Hinweise zum Datenschutz finden Sie hier (Informations on data privacy
can be found here): https://linutronix.de/kontakt/Datenschutz.php
Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen |
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
More information about the elbe-devel
mailing list