kunit.py (e756dbebd95d7ea7ae2a2343e8924eee10ec6253) | kunit.py (a9333bd344ad6eaf942221e0497ed65ec3224052) |
---|---|
1#!/usr/bin/env python3 2# SPDX-License-Identifier: GPL-2.0 3# 4# A thin wrapper on top of the KUnit Kernel 5# 6# Copyright (C) 2019, Google LLC. 7# Author: Felix Guo <felixguoxiuping@gmail.com> 8# Author: Brendan Higgins <brendanhiggins@google.com> 9 10import argparse 11import os 12import re | 1#!/usr/bin/env python3 2# SPDX-License-Identifier: GPL-2.0 3# 4# A thin wrapper on top of the KUnit Kernel 5# 6# Copyright (C) 2019, Google LLC. 7# Author: Felix Guo <felixguoxiuping@gmail.com> 8# Author: Brendan Higgins <brendanhiggins@google.com> 9 10import argparse 11import os 12import re |
13import shlex |
|
13import sys 14import time 15 16assert sys.version_info >= (3, 7), "Python version is too old" 17 18from dataclasses import dataclass 19from enum import Enum, auto 20from typing import Iterable, List, Optional, Sequence, Tuple --- 298 unchanged lines hidden (view full) --- 319 'home directory called `toolchains`).'), 320 metavar='PREFIX') 321 322 parser.add_argument('--qemu_config', 323 help=('Takes a path to a path to a file containing ' 324 'a QemuArchParams object.'), 325 type=str, metavar='FILE') 326 | 14import sys 15import time 16 17assert sys.version_info >= (3, 7), "Python version is too old" 18 19from dataclasses import dataclass 20from enum import Enum, auto 21from typing import Iterable, List, Optional, Sequence, Tuple --- 298 unchanged lines hidden (view full) --- 320 'home directory called `toolchains`).'), 321 metavar='PREFIX') 322 323 parser.add_argument('--qemu_config', 324 help=('Takes a path to a path to a file containing ' 325 'a QemuArchParams object.'), 326 type=str, metavar='FILE') 327 |
328 parser.add_argument('--qemu_args', 329 help='Additional QEMU arguments, e.g. "-smp 8"', 330 action='append', metavar='') 331 |
|
327def add_build_opts(parser) -> None: 328 parser.add_argument('--jobs', 329 help='As in the make command, "Specifies the number of ' 330 'jobs (commands) to run simultaneously."', 331 type=int, default=get_default_jobs(), metavar='N') 332 333def add_exec_opts(parser) -> None: 334 parser.add_argument('--timeout', --- 29 unchanged lines hidden (view full) --- 364 help='Stores test results in a JSON, and either ' 365 'prints to stdout or saves to file if a ' 366 'filename is specified', 367 type=str, const='stdout', default=None, metavar='FILE') 368 369 370def tree_from_args(cli_args: argparse.Namespace) -> kunit_kernel.LinuxSourceTree: 371 """Returns a LinuxSourceTree based on the user's arguments.""" | 332def add_build_opts(parser) -> None: 333 parser.add_argument('--jobs', 334 help='As in the make command, "Specifies the number of ' 335 'jobs (commands) to run simultaneously."', 336 type=int, default=get_default_jobs(), metavar='N') 337 338def add_exec_opts(parser) -> None: 339 parser.add_argument('--timeout', --- 29 unchanged lines hidden (view full) --- 369 help='Stores test results in a JSON, and either ' 370 'prints to stdout or saves to file if a ' 371 'filename is specified', 372 type=str, const='stdout', default=None, metavar='FILE') 373 374 375def tree_from_args(cli_args: argparse.Namespace) -> kunit_kernel.LinuxSourceTree: 376 """Returns a LinuxSourceTree based on the user's arguments.""" |
377 # Allow users to specify multiple arguments in one string, e.g. '-smp 8' 378 qemu_args: List[str] = [] 379 if cli_args.qemu_args: 380 for arg in cli_args.qemu_args: 381 qemu_args.extend(shlex.split(arg)) 382 |
|
372 return kunit_kernel.LinuxSourceTree(cli_args.build_dir, 373 kunitconfig_path=cli_args.kunitconfig, 374 kconfig_add=cli_args.kconfig_add, 375 arch=cli_args.arch, 376 cross_compile=cli_args.cross_compile, | 383 return kunit_kernel.LinuxSourceTree(cli_args.build_dir, 384 kunitconfig_path=cli_args.kunitconfig, 385 kconfig_add=cli_args.kconfig_add, 386 arch=cli_args.arch, 387 cross_compile=cli_args.cross_compile, |
377 qemu_config_path=cli_args.qemu_config) | 388 qemu_config_path=cli_args.qemu_config, 389 extra_qemu_args=qemu_args) |
378 379 380def main(argv): 381 parser = argparse.ArgumentParser( 382 description='Helps writing and running KUnit tests.') 383 subparser = parser.add_subparsers(dest='subcommand') 384 385 # The 'run' command will config, build, exec, and parse in one go. --- 115 unchanged lines hidden --- | 390 391 392def main(argv): 393 parser = argparse.ArgumentParser( 394 description='Helps writing and running KUnit tests.') 395 subparser = parser.add_subparsers(dest='subcommand') 396 397 # The 'run' command will config, build, exec, and parse in one go. --- 115 unchanged lines hidden --- |