[elbe-devel] [PATCH v2 3/9] tests efilesystem: Add tests for copy_fileslist

Bastian Germann bage at linutronix.de
Mon May 11 14:39:07 CEST 2020


Am 04.05.20 um 20:00 schrieb dion at linutronix.de (Olivier Dion):
> 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>

Reviewed-by: Bastian Germann <bage 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..cdf713ca
> --- /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')
> +
> +        self.src.write_file('/bin/bla', 0o644, 'bla')
> +
> +        copy_filelist(self.src, ['/bin/bla'], self.dst)
> +
> +        # We should now have the same content from /SRC/usr/bin/bla in
> +        # /DST/usr/bin/bla
> +        self.assertEqual(self.src.read_file('/usr/bin/bla'),
> +                         self.dst.read_file('/usr/bin/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')
> +
> +        self.src.write_file('/bin/bla', 0o644, 'bla')
> +
> +        copy_filelist(self.src, ['/bin/bla'], self.dst)
> +
> +        # We should now have the same content from /SRC/usr/bin/bla in
> +        # /DST/usr/bin/bla
> +        self.assertEqual(self.src.read_file('/usr/bin/bla'),
> +                         self.dst.read_file('/usr/bin/bla'))
> 



More information about the elbe-devel mailing list