kunit.py (9c3a0f285248899dfa81585bc5d5bc9ebdb8fead) | kunit.py (6cb51a1874d0617579a6bf095b87a510f7dc07ba) |
---|---|
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> --- 16 unchanged lines hidden (view full) --- 25KunitResult = namedtuple('KunitResult', ['status','result','elapsed_time']) 26 27KunitConfigRequest = namedtuple('KunitConfigRequest', 28 ['build_dir', 'make_options']) 29KunitBuildRequest = namedtuple('KunitBuildRequest', 30 ['jobs', 'build_dir', 'alltests', 31 'make_options']) 32KunitExecRequest = namedtuple('KunitExecRequest', | 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> --- 16 unchanged lines hidden (view full) --- 25KunitResult = namedtuple('KunitResult', ['status','result','elapsed_time']) 26 27KunitConfigRequest = namedtuple('KunitConfigRequest', 28 ['build_dir', 'make_options']) 29KunitBuildRequest = namedtuple('KunitBuildRequest', 30 ['jobs', 'build_dir', 'alltests', 31 'make_options']) 32KunitExecRequest = namedtuple('KunitExecRequest', |
33 ['timeout', 'build_dir', 'alltests', 'filter_glob']) | 33 ['timeout', 'build_dir', 'alltests', 34 'filter_glob', 'kernel_args']) |
34KunitParseRequest = namedtuple('KunitParseRequest', 35 ['raw_output', 'input_data', 'build_dir', 'json']) 36KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 37 'build_dir', 'alltests', 'filter_glob', | 35KunitParseRequest = namedtuple('KunitParseRequest', 36 ['raw_output', 'input_data', 'build_dir', 'json']) 37KunitRequest = namedtuple('KunitRequest', ['raw_output','timeout', 'jobs', 38 'build_dir', 'alltests', 'filter_glob', |
38 'json', 'make_options']) | 39 'kernel_args', 'json', 'make_options']) |
39 40KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] 41 42class KunitStatus(Enum): 43 SUCCESS = auto() 44 CONFIG_FAILURE = auto() 45 BUILD_FAILURE = auto() 46 TEST_FAILURE = auto() --- 42 unchanged lines hidden (view full) --- 89 'built kernel successfully', 90 build_end - build_start) 91 92def exec_tests(linux: kunit_kernel.LinuxSourceTree, 93 request: KunitExecRequest) -> KunitResult: 94 kunit_parser.print_with_timestamp('Starting KUnit Kernel ...') 95 test_start = time.time() 96 result = linux.run_kernel( | 40 41KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] 42 43class KunitStatus(Enum): 44 SUCCESS = auto() 45 CONFIG_FAILURE = auto() 46 BUILD_FAILURE = auto() 47 TEST_FAILURE = auto() --- 42 unchanged lines hidden (view full) --- 90 'built kernel successfully', 91 build_end - build_start) 92 93def exec_tests(linux: kunit_kernel.LinuxSourceTree, 94 request: KunitExecRequest) -> KunitResult: 95 kunit_parser.print_with_timestamp('Starting KUnit Kernel ...') 96 test_start = time.time() 97 result = linux.run_kernel( |
98 args=request.kernel_args, |
|
97 timeout=None if request.alltests else request.timeout, 98 filter_glob=request.filter_glob, 99 build_dir=request.build_dir) 100 101 test_end = time.time() 102 103 return KunitResult(KunitStatus.SUCCESS, 104 result, --- 42 unchanged lines hidden (view full) --- 147 build_request = KunitBuildRequest(request.jobs, request.build_dir, 148 request.alltests, 149 request.make_options) 150 build_result = build_tests(linux, build_request) 151 if build_result.status != KunitStatus.SUCCESS: 152 return build_result 153 154 exec_request = KunitExecRequest(request.timeout, request.build_dir, | 99 timeout=None if request.alltests else request.timeout, 100 filter_glob=request.filter_glob, 101 build_dir=request.build_dir) 102 103 test_end = time.time() 104 105 return KunitResult(KunitStatus.SUCCESS, 106 result, --- 42 unchanged lines hidden (view full) --- 149 build_request = KunitBuildRequest(request.jobs, request.build_dir, 150 request.alltests, 151 request.make_options) 152 build_result = build_tests(linux, build_request) 153 if build_result.status != KunitStatus.SUCCESS: 154 return build_result 155 156 exec_request = KunitExecRequest(request.timeout, request.build_dir, |
155 request.alltests, request.filter_glob) | 157 request.alltests, request.filter_glob, 158 request.kernel_args) |
156 exec_result = exec_tests(linux, exec_request) 157 if exec_result.status != KunitStatus.SUCCESS: 158 return exec_result 159 160 parse_request = KunitParseRequest(request.raw_output, 161 exec_result.result, 162 request.build_dir, 163 request.json) --- 69 unchanged lines hidden (view full) --- 233 parser.add_argument('filter_glob', 234 help='maximum number of seconds to allow for all tests ' 235 'to run. This does not include time taken to build the ' 236 'tests.', 237 type=str, 238 nargs='?', 239 default='', 240 metavar='filter_glob') | 159 exec_result = exec_tests(linux, exec_request) 160 if exec_result.status != KunitStatus.SUCCESS: 161 return exec_result 162 163 parse_request = KunitParseRequest(request.raw_output, 164 exec_result.result, 165 request.build_dir, 166 request.json) --- 69 unchanged lines hidden (view full) --- 236 parser.add_argument('filter_glob', 237 help='maximum number of seconds to allow for all tests ' 238 'to run. This does not include time taken to build the ' 239 'tests.', 240 type=str, 241 nargs='?', 242 default='', 243 metavar='filter_glob') |
244 parser.add_argument('--kernel_args', 245 help='Kernel command-line parameters. Maybe be repeated', 246 action='append') |
|
241 242def add_parse_opts(parser) -> None: 243 parser.add_argument('--raw_output', help='don\'t format output from kernel', 244 action='store_true') 245 parser.add_argument('--json', 246 nargs='?', 247 help='Stores test results in a JSON, and either ' 248 'prints to stdout or saves to file if a ' --- 55 unchanged lines hidden (view full) --- 304 qemu_config_path=cli_args.qemu_config) 305 306 request = KunitRequest(cli_args.raw_output, 307 cli_args.timeout, 308 cli_args.jobs, 309 cli_args.build_dir, 310 cli_args.alltests, 311 cli_args.filter_glob, | 247 248def add_parse_opts(parser) -> None: 249 parser.add_argument('--raw_output', help='don\'t format output from kernel', 250 action='store_true') 251 parser.add_argument('--json', 252 nargs='?', 253 help='Stores test results in a JSON, and either ' 254 'prints to stdout or saves to file if a ' --- 55 unchanged lines hidden (view full) --- 310 qemu_config_path=cli_args.qemu_config) 311 312 request = KunitRequest(cli_args.raw_output, 313 cli_args.timeout, 314 cli_args.jobs, 315 cli_args.build_dir, 316 cli_args.alltests, 317 cli_args.filter_glob, |
318 cli_args.kernel_args, |
|
312 cli_args.json, 313 cli_args.make_options) 314 result = run_tests(linux, request) 315 if result.status != KunitStatus.SUCCESS: 316 sys.exit(1) 317 elif cli_args.subcommand == 'config': 318 if cli_args.build_dir and ( 319 not os.path.exists(cli_args.build_dir)): --- 38 unchanged lines hidden (view full) --- 358 kunitconfig_path=cli_args.kunitconfig, 359 arch=cli_args.arch, 360 cross_compile=cli_args.cross_compile, 361 qemu_config_path=cli_args.qemu_config) 362 363 exec_request = KunitExecRequest(cli_args.timeout, 364 cli_args.build_dir, 365 cli_args.alltests, | 319 cli_args.json, 320 cli_args.make_options) 321 result = run_tests(linux, request) 322 if result.status != KunitStatus.SUCCESS: 323 sys.exit(1) 324 elif cli_args.subcommand == 'config': 325 if cli_args.build_dir and ( 326 not os.path.exists(cli_args.build_dir)): --- 38 unchanged lines hidden (view full) --- 365 kunitconfig_path=cli_args.kunitconfig, 366 arch=cli_args.arch, 367 cross_compile=cli_args.cross_compile, 368 qemu_config_path=cli_args.qemu_config) 369 370 exec_request = KunitExecRequest(cli_args.timeout, 371 cli_args.build_dir, 372 cli_args.alltests, |
366 cli_args.filter_glob) | 373 cli_args.filter_glob, 374 cli_args.kernel_args) |
367 exec_result = exec_tests(linux, exec_request) 368 parse_request = KunitParseRequest(cli_args.raw_output, 369 exec_result.result, 370 cli_args.build_dir, 371 cli_args.json) 372 result = parse_tests(parse_request) 373 kunit_parser.print_with_timestamp(( 374 'Elapsed time: %.3fs\n') % ( --- 21 unchanged lines hidden --- | 375 exec_result = exec_tests(linux, exec_request) 376 parse_request = KunitParseRequest(cli_args.raw_output, 377 exec_result.result, 378 cli_args.build_dir, 379 cli_args.json) 380 result = parse_tests(parse_request) 381 kunit_parser.print_with_timestamp(( 382 'Elapsed time: %.3fs\n') % ( --- 21 unchanged lines hidden --- |