Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: tool: Enable virtio/PCI by default on UML

There are several tests which depend on PCI, and hence need a bunch of
extra options to run under UML. This makes it awkward to give
configuration instructions (whether in documentation, or as part of a
.kunitconfig file), as two separate, incompatible sets of config options
are required for UML and "most other architectures".

For non-UML architectures, it's possible to add default kconfig options
via the qemu_config python files, but there's no equivalent for UML. Add
a new tools/testing/kunit/configs/arch_uml.config file containing extra
kconfig options to use on UML.

Tested-by: José Expósito <jose.exposito89@gmail.com>
Reviewed-by: Daniel Latypov <dlatypov@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Daniel Latypov <dlatypov@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

David Gow and committed by
Shuah Khan
6fc3a863 53b46621

+27 -4
+5
tools/testing/kunit/configs/arch_uml.config
··· 1 + # Config options which are added to UML builds by default 2 + 3 + # Enable virtio/pci, as a lot of tests require it. 4 + CONFIG_VIRTIO_UML=y 5 + CONFIG_UML_PCI_OVER_VIRTIO=y
+10 -4
tools/testing/kunit/kunit_kernel.py
··· 26 26 OLD_KUNITCONFIG_PATH = 'last_used_kunitconfig' 27 27 DEFAULT_KUNITCONFIG_PATH = 'tools/testing/kunit/configs/default.config' 28 28 BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config' 29 + UML_KCONFIG_PATH = 'tools/testing/kunit/configs/arch_uml.config' 29 30 OUTFILE_PATH = 'test.log' 30 31 ABS_TOOL_PATH = os.path.abspath(os.path.dirname(__file__)) 31 32 QEMU_CONFIGS_DIR = os.path.join(ABS_TOOL_PATH, 'qemu_configs') ··· 54 53 except subprocess.CalledProcessError as e: 55 54 raise ConfigError(e.output.decode()) 56 55 57 - def make_arch_qemuconfig(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: 56 + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: 58 57 return base_kunitconfig 59 58 60 59 def make_allyesconfig(self, build_dir: str, make_options) -> None: ··· 110 109 self._kernel_command_line = qemu_arch_params.kernel_command_line + ' kunit_shutdown=reboot' 111 110 self._extra_qemu_params = qemu_arch_params.extra_qemu_params 112 111 113 - def make_arch_qemuconfig(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: 112 + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: 114 113 kconfig = kunit_config.parse_from_string(self._kconfig) 115 114 kconfig.merge_in_entries(base_kunitconfig) 116 115 return kconfig ··· 138 137 139 138 def __init__(self, cross_compile=None): 140 139 super().__init__(linux_arch='um', cross_compile=cross_compile) 140 + 141 + def make_arch_config(self, base_kunitconfig: kunit_config.Kconfig) -> kunit_config.Kconfig: 142 + kconfig = kunit_config.parse_file(UML_KCONFIG_PATH) 143 + kconfig.merge_in_entries(base_kunitconfig) 144 + return kconfig 141 145 142 146 def make_allyesconfig(self, build_dir: str, make_options) -> None: 143 147 stdout.print_with_timestamp( ··· 304 298 if build_dir and not os.path.exists(build_dir): 305 299 os.mkdir(build_dir) 306 300 try: 307 - self._kconfig = self._ops.make_arch_qemuconfig(self._kconfig) 301 + self._kconfig = self._ops.make_arch_config(self._kconfig) 308 302 self._kconfig.write_to_file(kconfig_path) 309 303 self._ops.make_olddefconfig(build_dir, make_options) 310 304 except ConfigError as e: ··· 335 329 return self.build_config(build_dir, make_options) 336 330 337 331 existing_kconfig = kunit_config.parse_file(kconfig_path) 338 - self._kconfig = self._ops.make_arch_qemuconfig(self._kconfig) 332 + self._kconfig = self._ops.make_arch_config(self._kconfig) 339 333 340 334 if self._kconfig.is_subset_of(existing_kconfig) and not self._kunitconfig_changed(build_dir): 341 335 return True
+12
tools/testing/kunit/kunit_tool_test.py
··· 430 430 f.write('CONFIG_KUNIT=y') 431 431 432 432 tree = kunit_kernel.LinuxSourceTree(build_dir) 433 + # Stub out the source tree operations, so we don't have 434 + # the defaults for any given architecture get in the 435 + # way. 436 + tree._ops = kunit_kernel.LinuxSourceTreeOperations('none', None) 433 437 mock_build_config = mock.patch.object(tree, 'build_config').start() 434 438 435 439 # Should generate the .config ··· 451 447 f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y') 452 448 453 449 tree = kunit_kernel.LinuxSourceTree(build_dir) 450 + # Stub out the source tree operations, so we don't have 451 + # the defaults for any given architecture get in the 452 + # way. 453 + tree._ops = kunit_kernel.LinuxSourceTreeOperations('none', None) 454 454 mock_build_config = mock.patch.object(tree, 'build_config').start() 455 455 456 456 self.assertTrue(tree.build_reconfig(build_dir, make_options=[])) ··· 471 463 f.write('CONFIG_KUNIT=y\nCONFIG_KUNIT_TEST=y') 472 464 473 465 tree = kunit_kernel.LinuxSourceTree(build_dir) 466 + # Stub out the source tree operations, so we don't have 467 + # the defaults for any given architecture get in the 468 + # way. 469 + tree._ops = kunit_kernel.LinuxSourceTreeOperations('none', None) 474 470 mock_build_config = mock.patch.object(tree, 'build_config').start() 475 471 476 472 # ... so we should trigger a call to build_config()