diff --git a/Makefile b/Makefile index 80c0418ef78..f618ece61cd 100644 --- a/Makefile +++ b/Makefile @@ -135,7 +135,7 @@ test: setup # python static code checks poetry run mypy kiwi # unit tests - poetry run bash -c 'pushd test/unit && pytest -n 5 \ + poetry run bash -c 'pushd test/unit && pytest -n 8 \ --doctest-modules --no-cov-on-fail --cov=kiwi \ --cov-report=term-missing --cov-fail-under=100 \ --cov-config .coveragerc' diff --git a/doc/source/commands/system_build.rst b/doc/source/commands/system_build.rst index ea0e8f6b5da..c4a1107c2ac 100644 --- a/doc/source/commands/system_build.rst +++ b/doc/source/commands/system_build.rst @@ -25,7 +25,7 @@ SYNOPSIS [--add-package=...] [--add-bootstrap-package=...] [--ca-cert=...] - [--ca-target-distribution=] + [--ca-target-distribution=] [--delete-package=...] [--set-container-derived-from=] [--set-container-tag=] diff --git a/doc/source/commands/system_prepare.rst b/doc/source/commands/system_prepare.rst index 8f50d253041..8f539805845 100644 --- a/doc/source/commands/system_prepare.rst +++ b/doc/source/commands/system_prepare.rst @@ -23,7 +23,7 @@ SYNOPSIS [--add-package=...] [--add-bootstrap-package=...] [--ca-cert=...] - [--ca-target-distribution=] + [--ca-target-distribution=] [--delete-package=...] [--set-container-derived-from=] [--set-container-tag=] diff --git a/kiwi/tasks/system_build.py b/kiwi/tasks/system_build.py index 7fe70370f4d..2eee9372eba 100644 --- a/kiwi/tasks/system_build.py +++ b/kiwi/tasks/system_build.py @@ -29,7 +29,7 @@ [--add-package=...] [--add-bootstrap-package=...] [--ca-cert=...] - [--ca-target-distribution=] + [--ca-target-distribution=] [--delete-package=...] [--set-container-derived-from=] [--set-container-tag=] diff --git a/kiwi/tasks/system_prepare.py b/kiwi/tasks/system_prepare.py index a5af171430d..07e5d3a7075 100644 --- a/kiwi/tasks/system_prepare.py +++ b/kiwi/tasks/system_prepare.py @@ -29,7 +29,7 @@ [--add-package=...] [--add-bootstrap-package=...] [--ca-cert=...] - [--ca-target-distribution=] + [--ca-target-distribution=] [--delete-package=...] [--set-container-derived-from=] [--set-container-tag=] diff --git a/test/unit/bootloader/config/grub2_test.py b/test/unit/bootloader/config/grub2_test.py index 41d4471ba56..1eea34b0443 100644 --- a/test/unit/bootloader/config/grub2_test.py +++ b/test/unit/bootloader/config/grub2_test.py @@ -697,6 +697,7 @@ def test_setup_default_grub_s390_secure_execution( grub_default.write = Mock() mock_sysconfig.return_value = grub_default mock_exists.return_value = True + self.bootloader.bls = True self.bootloader.terminal_input = 'serial' self.bootloader.terminal_output = 'gfxterm' self.bootloader.theme = 'openSUSE' @@ -754,6 +755,7 @@ def test_setup_default_grub( grub_default.write = Mock() mock_sysconfig.return_value = grub_default mock_exists.return_value = True + self.bootloader.bls = True self.bootloader.terminal_input = 'serial' self.bootloader.terminal_output = 'gfxterm' self.bootloader.theme = 'openSUSE' @@ -794,6 +796,7 @@ def test_setup_default_grub_empty_kernelcmdline( grub_default = MagicMock() mock_sysconfig.return_value = grub_default mock_exists.return_value = True + self.bootloader.bls = True self.bootloader.terminal_input = 'serial' self.bootloader.terminal_output = 'serial' self.bootloader.theme = 'openSUSE' @@ -840,6 +843,7 @@ def test_setup_default_grub_use_of_by_partuuid( grub_default = MagicMock() mock_sysconfig.return_value = grub_default mock_exists.return_value = True + self.bootloader.bls = True self.bootloader.terminal_input = 'serial' self.bootloader.terminal_output = 'serial' self.bootloader.theme = 'openSUSE' @@ -889,6 +893,7 @@ def test_setup_default_grub_use_of_by_label( self.bootloader.displayname = 'Bob' self.bootloader.cmdline = 'abcd root=LABEL=foo console=tty0' self.bootloader.persistency_type = 'by-label' + self.bootloader.bls = True self.bootloader._setup_default_grub() diff --git a/test/unit/bootloader/config/zipl_test.py b/test/unit/bootloader/config/zipl_test.py index e624e12566c..b9d38687753 100644 --- a/test/unit/bootloader/config/zipl_test.py +++ b/test/unit/bootloader/config/zipl_test.py @@ -208,6 +208,8 @@ def test_get_template_parameters( self.bootloader.timeout = 0 self.bootloader.disk_type = 'CDL' self.bootloader.disk_blocksize = 4096 + self.bootloader.custom_args['secure_image_file'] = \ + 'bootpath/kernel-filename.cc' assert self.bootloader._get_template_parameters() == { 'secure_image_file': 'bootpath/kernel-filename.cc', 'kernel_file': 'vmlinuz', diff --git a/test/unit/system/setup_test.py b/test/unit/system/setup_test.py index 41b0ec0731e..d57f2912c74 100644 --- a/test/unit/system/setup_test.py +++ b/test/unit/system/setup_test.py @@ -374,25 +374,33 @@ def side_effect(arg): self.setup_with_real_xml.import_description() @patch('kiwi.command.Command.run') - def test_cleanup(self, mock_command): + @patch('os.path.isdir') + @patch('kiwi.system.setup.Path.wipe') + @patch('kiwi.system.setup.MountManager') + def test_cleanup( + self, + mock_MountManager, + mock_Path_wipe, + mock_os_path_isdir, + mock_Command_run + ): + image_meta = Mock() + mock_MountManager.return_value = image_meta + mock_os_path_isdir.return_value = True self.setup.cleanup() - assert mock_command.call_args_list == [ - call( - [ - 'chroot', 'root_dir', 'rm', '-f', - '.kconfig', - '.profile', - 'config.bootoptions' - ] - ), - call( - command=['mountpoint', '-q', 'root_dir/image'], - raise_on_error=False - ), - call( - ['rm', '-r', '-f', 'root_dir/image'] - ) - ] + mock_Command_run.assert_called_once_with( + [ + 'chroot', 'root_dir', 'rm', '-f', + '.kconfig', + '.profile', + 'config.bootoptions' + ] + ) + mock_MountManager.assert_called_once_with( + device='none', mountpoint='root_dir/image' + ) + image_meta.umount.assert_called_once_with() + mock_Path_wipe.assert_called_once_with('root_dir/image') @patch('kiwi.system.setup.ArchiveTar') @patch('kiwi.system.setup.glob.iglob') diff --git a/test/unit/tasks/system_build_test.py b/test/unit/tasks/system_build_test.py index 125da22b6a0..7f15eba726c 100644 --- a/test/unit/tasks/system_build_test.py +++ b/test/unit/tasks/system_build_test.py @@ -13,6 +13,7 @@ from ..test_helper import argv_kiwi_tests +from kiwi.defaults import Defaults from kiwi.tasks.system_build import SystemBuildTask @@ -22,6 +23,7 @@ def inject_fixtures(self, caplog): self._caplog = caplog def setup(self): + Defaults.set_platform_name('x86_64') sys.argv = [ sys.argv[0], '--profile', 'vmxFlavour', 'system', 'build', '--description', '../data/description', diff --git a/test/unit/tasks/system_prepare_test.py b/test/unit/tasks/system_prepare_test.py index 76ef271cc18..b2ac4020aee 100644 --- a/test/unit/tasks/system_prepare_test.py +++ b/test/unit/tasks/system_prepare_test.py @@ -13,6 +13,7 @@ from ..test_helper import argv_kiwi_tests +from kiwi.defaults import Defaults from kiwi.tasks.system_prepare import SystemPrepareTask @@ -22,6 +23,7 @@ def inject_fixtures(self, caplog): self._caplog = caplog def setup(self): + Defaults.set_platform_name('x86_64') sys.argv = [ sys.argv[0], '--profile', 'vmxFlavour', 'system', 'prepare', '--description', '../data/description', diff --git a/test/unit/xml_state_test.py b/test/unit/xml_state_test.py index ebcd6aefc97..e9db043f4c0 100644 --- a/test/unit/xml_state_test.py +++ b/test/unit/xml_state_test.py @@ -1244,8 +1244,12 @@ def test_get_build_type_bootloader_bls(self, mock_bootloader): assert self.state.get_build_type_bootloader_bls() is False self.bootloader.get_bls.return_value = True assert self.state.get_build_type_bootloader_bls() is True - self.bootloader.get_bls.return_value = None - assert self.state.get_build_type_bootloader_bls() is True + # The behavior for this is different on some distributions + # because of the different default state. See + # kiwi-revert-bls-default-for-suse.patch + # As long as we cary this patch the following test is disabled + # self.bootloader.get_bls.return_value = None + # assert self.state.get_build_type_bootloader_bls() is True @patch('kiwi.xml_parse.type_.get_bootloader') def test_get_build_type_bootloader_console(self, mock_bootloader):