Commit 6cf6b0a6 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Shuah Khan
Browse files

kunit: tool: Implement listing of available architectures

To implement custom scripting around kunit.py it is useful to get a list of
available architectures. While it is possible to manually inspect
tools/testing/kunit/qemu_configs/, this is annoying to implement and
introduces a dependency on a kunit.py implementation detail.

Introduce 'kunit.py run --arch help' which lists all known architectures
in an easy to parse list. This is equivalent on how QEMU implements
listing of possible argument values.

Link: https://lore.kernel.org/r/20250415-kunit-list-v2-1-aa452cd317ae@linutronix.de


Signed-off-by: default avatarThomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: default avatarRae Moar <rmoar@google.com>
Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 9aa08e76
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -182,6 +182,8 @@ via UML. To run tests on qemu, by default it requires two flags:
  is ignored), the tests will run via UML. Non-UML architectures,
  for example: i386, x86_64, arm and so on; run on qemu.

  ``--arch help`` lists all valid ``--arch`` values.

- ``--cross_compile``: Specifies the Kbuild toolchain. It passes the
  same argument as passed to the ``CROSS_COMPILE`` variable used by
  Kbuild. As a reminder, this will be the prefix for the toolchain
+8 −0
Original line number Diff line number Diff line
@@ -14,6 +14,7 @@ import os
import shlex
import shutil
import signal
import sys
import threading
from typing import Iterator, List, Optional, Tuple
from types import FrameType
@@ -201,6 +202,13 @@ def _default_qemu_config_path(arch: str) -> str:
		return config_path

	options = [f[:-3] for f in os.listdir(QEMU_CONFIGS_DIR) if f.endswith('.py')]

	if arch == 'help':
		print('um')
		for option in options:
			print(option)
		sys.exit()

	raise ConfigError(arch + ' is not a valid arch, options are ' + str(sorted(options)))

def _get_qemu_ops(config_path: str,