Skip to content

Commit 6cf6b0a

Browse files
t-8chshuahkh
authored andcommitted
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/[email protected] Signed-off-by: Thomas Weißschuh <[email protected]> Reviewed-by: Rae Moar <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 9aa08e7 commit 6cf6b0a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

Documentation/dev-tools/kunit/run_wrapper.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ via UML. To run tests on qemu, by default it requires two flags:
182182
is ignored), the tests will run via UML. Non-UML architectures,
183183
for example: i386, x86_64, arm and so on; run on qemu.
184184

185+
``--arch help`` lists all valid ``--arch`` values.
186+
185187
- ``--cross_compile``: Specifies the Kbuild toolchain. It passes the
186188
same argument as passed to the ``CROSS_COMPILE`` variable used by
187189
Kbuild. As a reminder, this will be the prefix for the toolchain

tools/testing/kunit/kunit_kernel.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import shlex
1515
import shutil
1616
import signal
17+
import sys
1718
import threading
1819
from typing import Iterator, List, Optional, Tuple
1920
from types import FrameType
@@ -201,6 +202,13 @@ def _default_qemu_config_path(arch: str) -> str:
201202
return config_path
202203

203204
options = [f[:-3] for f in os.listdir(QEMU_CONFIGS_DIR) if f.endswith('.py')]
205+
206+
if arch == 'help':
207+
print('um')
208+
for option in options:
209+
print(option)
210+
sys.exit()
211+
204212
raise ConfigError(arch + ' is not a valid arch, options are ' + str(sorted(options)))
205213

206214
def _get_qemu_ops(config_path: str,

0 commit comments

Comments
 (0)