File: squashfs_test.py

package info (click to toggle)
kiwi 10.2.45-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 7,616 kB
  • sloc: python: 70,131; sh: 4,309; xml: 3,389; ansic: 391; makefile: 360
file content (76 lines) | stat: -rw-r--r-- 2,693 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from unittest.mock import patch

import unittest.mock as mock

from kiwi.defaults import Defaults
from kiwi.filesystem.squashfs import FileSystemSquashFs


class TestFileSystemSquashfs:
    @patch('os.path.exists')
    def setup(self, mock_exists):
        mock_exists.return_value = True
        self.squashfs = FileSystemSquashFs(mock.Mock(), 'root_dir')

    @patch('os.path.exists')
    def setup_method(self, cls, mock_exists):
        self.setup()

    @patch('kiwi.filesystem.squashfs.Command.run')
    def test_create_on_file(self, mock_command):
        Defaults.set_platform_name('x86_64')
        self.squashfs.create_on_file('myimage', 'label')
        mock_command.assert_called_once_with(
            [
                'mksquashfs', 'root_dir', 'myimage', '-noappend',
                '-b', '1M', '-comp', 'xz', '-Xbcj', 'x86'
            ]
        )

    @patch('kiwi.filesystem.squashfs.Command.run')
    def test_create_on_file_exclude_data(self, mock_command):
        Defaults.set_platform_name('ppc64le')
        self.squashfs.create_on_file('myimage', 'label', ['foo'])
        mock_command.assert_called_once_with(
            [
                'mksquashfs', 'root_dir', 'myimage', '-noappend', '-b', '1M',
                '-comp', 'xz', '-Xbcj', 'powerpc', '-wildcards', '-e', 'foo'
            ]
        )

    @patch('kiwi.filesystem.squashfs.Command.run')
    def test_create_on_file_unkown_arch(self, mock_command):
        Defaults.set_platform_name('aarch64')
        self.squashfs.create_on_file('myimage', 'label')
        mock_command.assert_called_once_with(
            [
                'mksquashfs', 'root_dir', 'myimage',
                '-noappend', '-b', '1M', '-comp', 'xz'
            ]
        )

    @patch('kiwi.filesystem.squashfs.Command.run')
    def test_create_on_file_gzip(self, mock_command):
        self.squashfs.custom_args = {
            'compression': 'gzip', 'create_options': []
        }
        self.squashfs.create_on_file('myimage', 'label')
        mock_command.assert_called_once_with(
            [
                'mksquashfs', 'root_dir', 'myimage',
                '-noappend', '-b', '1M', '-comp', 'gzip'
            ]
        )

    @patch('kiwi.filesystem.squashfs.Command.run')
    def test_create_on_file_no_compression(self, mock_command):
        self.squashfs.custom_args = {
            'compression': 'uncompressed', 'create_options': []
        }
        self.squashfs.create_on_file('myimage', 'label')
        mock_command.assert_called_once_with(
            [
                'mksquashfs', 'root_dir', 'myimage', '-noappend',
                '-b', '1M', '-noI', '-noD', '-noF', '-noX'
            ]
        )