From ef53246ede6fc52b29754d7c8bb8020fe23ddd19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Thu, 12 Mar 2026 19:05:31 +0100 Subject: [PATCH 1/6] Fix unit tests Due to us carrying a custom kiwi-revert-bls-default-for-suse.patch patch there is a different grub bootloader BLS behavior which causes some unit tests to fail when they run outside of the general source. This commit fixes it. --- test/unit/bootloader/config/grub2_test.py | 5 +++++ test/unit/xml_state_test.py | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) 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/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): From b700a0c76028985ea09f93ad18f2dc28639deeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Thu, 12 Mar 2026 19:23:59 +0100 Subject: [PATCH 2/6] Fixed docopt docstring When using doctopt argument information that contains the "|" symbol it gets wrongly evaluated as an option in newer versions of docopt. This commit changes the argument information to use a "," instead --- doc/source/commands/system_build.rst | 2 +- doc/source/commands/system_prepare.rst | 2 +- kiwi/tasks/system_build.py | 2 +- kiwi/tasks/system_prepare.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) 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=] From 91f9706e87ecc5b99853b4872507e891fff8211b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Fri, 13 Mar 2026 11:13:50 +0100 Subject: [PATCH 3/6] Increase xdist workers to 8 --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' From 4ff1dd2ffbd2b5bef9ff0f0905982c57ade1dfac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Fri, 13 Mar 2026 11:14:15 +0100 Subject: [PATCH 4/6] Fix race condition on architecture setting Make sure to not inherit arch settings from parallel runs of the unit tests. --- test/unit/tasks/system_build_test.py | 2 ++ test/unit/tasks/system_prepare_test.py | 2 ++ 2 files changed, 4 insertions(+) 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', From 11b95265386e6bfa037d555e42c024c26ee3c264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Fri, 13 Mar 2026 12:13:41 +0100 Subject: [PATCH 5/6] Fix race condition in test_get_template_parameters It should not depend on the order of the tests if the custom_args parameter secure_image_file got initialized or not --- test/unit/bootloader/config/zipl_test.py | 2 ++ 1 file changed, 2 insertions(+) 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', From 07c6acb0370fd6a41fe6e0d4d76ac12d21d1a562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcus=20Sch=C3=A4fer?= Date: Fri, 13 Mar 2026 12:24:45 +0100 Subject: [PATCH 6/6] Fixed TestSystemSetup::test_cleanup unit test The test was missing proper mocking and did not work as a generic test on all archs. --- test/unit/system/setup_test.py | 44 ++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 18 deletions(-) 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')