Debian Codegraph @

test/unit/filesystem/squashfs_test.py

raw
1 from unittest.mock import patch
2
3 import unittest.mock as mock
4
5 from kiwi.defaults import Defaults
6 from kiwi.filesystem.squashfs import FileSystemSquashFs
7
8
9 class TestFileSystemSquashfs:
10 @patch('os.path.exists')
11 def setup(self, mock_exists):
12 mock_exists.return_value = True
13 self.squashfs = FileSystemSquashFs(mock.Mock(), 'root_dir')
14
15 @patch('os.path.exists')
16 def setup_method(self, cls, mock_exists):
17 self.setup()
18
19 @patch('kiwi.filesystem.squashfs.Command.run')
20 def test_create_on_file(self, mock_command):
21 Defaults.set_platform_name('x86_64')
22 self.squashfs.create_on_file('myimage', 'label')
23 mock_command.assert_called_once_with(
24 [
25 'mksquashfs', 'root_dir', 'myimage', '-noappend',
26 '-b', '1M', '-comp', 'xz', '-Xbcj', 'x86'
27 ]
28 )
29
30 @patch('kiwi.filesystem.squashfs.Command.run')
31 def test_create_on_file_exclude_data(self, mock_command):
32 Defaults.set_platform_name('ppc64le')
33 self.squashfs.create_on_file('myimage', 'label', ['foo'])
34 mock_command.assert_called_once_with(
35 [
36 'mksquashfs', 'root_dir', 'myimage', '-noappend', '-b', '1M',
37 '-comp', 'xz', '-Xbcj', 'powerpc', '-wildcards', '-e', 'foo'
38 ]
39 )
40
41 @patch('kiwi.filesystem.squashfs.Command.run')
42 def test_create_on_file_unkown_arch(self, mock_command):
43 Defaults.set_platform_name('aarch64')
44 self.squashfs.create_on_file('myimage', 'label')
45 mock_command.assert_called_once_with(
46 [
47 'mksquashfs', 'root_dir', 'myimage',
48 '-noappend', '-b', '1M', '-comp', 'xz'
49 ]
50 )
51
52 @patch('kiwi.filesystem.squashfs.Command.run')
53 def test_create_on_file_gzip(self, mock_command):
54 self.squashfs.custom_args = {
55 'compression': 'gzip', 'create_options': []
56 }
57 self.squashfs.create_on_file('myimage', 'label')
58 mock_command.assert_called_once_with(
59 [
60 'mksquashfs', 'root_dir', 'myimage',
61 '-noappend', '-b', '1M', '-comp', 'gzip'
62 ]
63 )
64
65 @patch('kiwi.filesystem.squashfs.Command.run')
66 def test_create_on_file_no_compression(self, mock_command):
67 self.squashfs.custom_args = {
68 'compression': 'uncompressed', 'create_options': []
69 }
70 self.squashfs.create_on_file('myimage', 'label')
71 mock_command.assert_called_once_with(
72 [
73 'mksquashfs', 'root_dir', 'myimage', '-noappend',
74 '-b', '1M', '-noI', '-noD', '-noF', '-noX'
75 ]
76 )