kunit.py (715a1284d89a740b197b3bad5eb20d36a397382f) | kunit.py (09641f7c7d8f1309fe9ad9ce4e6a1697016d73ba) |
---|---|
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> --- 29 unchanged lines hidden (view full) --- 38KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] 39 40class KunitStatus(Enum): 41 SUCCESS = auto() 42 CONFIG_FAILURE = auto() 43 BUILD_FAILURE = auto() 44 TEST_FAILURE = auto() 45 | 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> --- 29 unchanged lines hidden (view full) --- 38KernelDirectoryPath = sys.argv[0].split('tools/testing/kunit/')[0] 39 40class KunitStatus(Enum): 41 SUCCESS = auto() 42 CONFIG_FAILURE = auto() 43 BUILD_FAILURE = auto() 44 TEST_FAILURE = auto() 45 |
46def get_kernel_root_path(): 47 parts = sys.argv[0] if not __file__ else __file__ 48 parts = os.path.realpath(parts).split('tools/testing/kunit') | 46def get_kernel_root_path() -> str: 47 path = sys.argv[0] if not __file__ else __file__ 48 parts = os.path.realpath(path).split('tools/testing/kunit') |
49 if len(parts) != 2: 50 sys.exit(1) 51 return parts[0] 52 53def config_tests(linux: kunit_kernel.LinuxSourceTree, 54 request: KunitConfigRequest) -> KunitResult: 55 kunit_parser.print_with_timestamp('Configuring KUnit Kernel ...') 56 --- 109 unchanged lines hidden (view full) --- 166 'Elapsed time: %.3fs total, %.3fs configuring, %.3fs ' + 167 'building, %.3fs running\n') % ( 168 run_end - run_start, 169 config_result.elapsed_time, 170 build_result.elapsed_time, 171 exec_result.elapsed_time)) 172 return parse_result 173 | 49 if len(parts) != 2: 50 sys.exit(1) 51 return parts[0] 52 53def config_tests(linux: kunit_kernel.LinuxSourceTree, 54 request: KunitConfigRequest) -> KunitResult: 55 kunit_parser.print_with_timestamp('Configuring KUnit Kernel ...') 56 --- 109 unchanged lines hidden (view full) --- 166 'Elapsed time: %.3fs total, %.3fs configuring, %.3fs ' + 167 'building, %.3fs running\n') % ( 168 run_end - run_start, 169 config_result.elapsed_time, 170 build_result.elapsed_time, 171 exec_result.elapsed_time)) 172 return parse_result 173 |
174def add_common_opts(parser): | 174def add_common_opts(parser) -> None: |
175 parser.add_argument('--build_dir', 176 help='As in the make command, it specifies the build ' 177 'directory.', 178 type=str, default='.kunit', metavar='build_dir') 179 parser.add_argument('--make_options', 180 help='X=Y make option, can be repeated.', 181 action='append') 182 parser.add_argument('--alltests', 183 help='Run all KUnit tests through allyesconfig', 184 action='store_true') 185 | 175 parser.add_argument('--build_dir', 176 help='As in the make command, it specifies the build ' 177 'directory.', 178 type=str, default='.kunit', metavar='build_dir') 179 parser.add_argument('--make_options', 180 help='X=Y make option, can be repeated.', 181 action='append') 182 parser.add_argument('--alltests', 183 help='Run all KUnit tests through allyesconfig', 184 action='store_true') 185 |
186def add_build_opts(parser): | 186def add_build_opts(parser) -> None: |
187 parser.add_argument('--jobs', 188 help='As in the make command, "Specifies the number of ' 189 'jobs (commands) to run simultaneously."', 190 type=int, default=8, metavar='jobs') 191 | 187 parser.add_argument('--jobs', 188 help='As in the make command, "Specifies the number of ' 189 'jobs (commands) to run simultaneously."', 190 type=int, default=8, metavar='jobs') 191 |
192def add_exec_opts(parser): | 192def add_exec_opts(parser) -> None: |
193 parser.add_argument('--timeout', 194 help='maximum number of seconds to allow for all tests ' 195 'to run. This does not include time taken to build the ' 196 'tests.', 197 type=int, 198 default=300, 199 metavar='timeout') 200 | 193 parser.add_argument('--timeout', 194 help='maximum number of seconds to allow for all tests ' 195 'to run. This does not include time taken to build the ' 196 'tests.', 197 type=int, 198 default=300, 199 metavar='timeout') 200 |
201def add_parse_opts(parser): | 201def add_parse_opts(parser) -> None: |
202 parser.add_argument('--raw_output', help='don\'t format output from kernel', 203 action='store_true') 204 parser.add_argument('--json', 205 nargs='?', 206 help='Stores test results in a JSON, and either ' 207 'prints to stdout or saves to file if a ' 208 'filename is specified', 209 type=str, const='stdout', default=None) --- 139 unchanged lines hidden --- | 202 parser.add_argument('--raw_output', help='don\'t format output from kernel', 203 action='store_true') 204 parser.add_argument('--json', 205 nargs='?', 206 help='Stores test results in a JSON, and either ' 207 'prints to stdout or saves to file if a ' 208 'filename is specified', 209 type=str, const='stdout', default=None) --- 139 unchanged lines hidden --- |