Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'linux_kselftest-kunit-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest

Pull kunit updates from Shuah Khan:
"kunit:
- add __rust_helper to helpers
- fix up const mismatch in many assert functions
- fix up const mismatch in test_list_sort
- protect KUNIT_BINARY_STR_ASSERTION against ERR_PTR values
- respect KBUILD_OUTPUT env variable by default
- add bash completion

kunit tool:
- add test for nested test result reporting
- do not overwrite test status based on subtest counts
- add 32-bit big endian ARM configuration to qemu_configs
- rename test_data_path() to _test_data_path()
- do not rely on implicit working directory change"

* tag 'linux_kselftest-kunit-6.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
kunit: add bash completion
kunit: tool: test: Don't rely on implicit working directory change
kunit: tool: test: Rename test_data_path() to _test_data_path()
kunit: qemu_configs: Add 32-bit big endian ARM configuration
kunit: tool: Don't overwrite test status based on subtest counts
kunit: tool: Add test for nested test result reporting
kunit: respect KBUILD_OUTPUT env variable by default
kunit: Protect KUNIT_BINARY_STR_ASSERTION against ERR_PTR values
test_list_sort: fix up const mismatch
kunit: fix up const mis-match in many assert functions
rust: kunit: add __rust_helper to helpers

+200 -40
+9
Documentation/dev-tools/kunit/run_wrapper.rst
··· 335 335 336 336 - ``--list_tests_attr``: If set, lists all tests that will be run and all of their 337 337 attributes. 338 + 339 + Command-line completion 340 + ============================== 341 + 342 + The kunit_tool comes with a bash completion script: 343 + 344 + .. code-block:: bash 345 + 346 + source tools/testing/kunit/kunit-completion.sh
+2 -1
include/kunit/test.h
··· 906 906 }; \ 907 907 \ 908 908 _KUNIT_SAVE_LOC(test); \ 909 - if (likely((__left) && (__right) && (strcmp(__left, __right) op 0))) \ 909 + if (likely(!IS_ERR_OR_NULL(__left) && !IS_ERR_OR_NULL(__right) && \ 910 + (strcmp(__left, __right) op 0))) \ 910 911 break; \ 911 912 \ 912 913 \
+6 -6
lib/kunit/assert.c
··· 51 51 const struct va_format *message, 52 52 struct string_stream *stream) 53 53 { 54 - struct kunit_unary_assert *unary_assert; 54 + const struct kunit_unary_assert *unary_assert; 55 55 56 56 unary_assert = container_of(assert, struct kunit_unary_assert, assert); 57 57 ··· 71 71 const struct va_format *message, 72 72 struct string_stream *stream) 73 73 { 74 - struct kunit_ptr_not_err_assert *ptr_assert; 74 + const struct kunit_ptr_not_err_assert *ptr_assert; 75 75 76 76 ptr_assert = container_of(assert, struct kunit_ptr_not_err_assert, 77 77 assert); ··· 117 117 const struct va_format *message, 118 118 struct string_stream *stream) 119 119 { 120 - struct kunit_binary_assert *binary_assert; 120 + const struct kunit_binary_assert *binary_assert; 121 121 122 122 binary_assert = container_of(assert, struct kunit_binary_assert, 123 123 assert); ··· 145 145 const struct va_format *message, 146 146 struct string_stream *stream) 147 147 { 148 - struct kunit_binary_ptr_assert *binary_assert; 148 + const struct kunit_binary_ptr_assert *binary_assert; 149 149 150 150 binary_assert = container_of(assert, struct kunit_binary_ptr_assert, 151 151 assert); ··· 185 185 const struct va_format *message, 186 186 struct string_stream *stream) 187 187 { 188 - struct kunit_binary_str_assert *binary_assert; 188 + const struct kunit_binary_str_assert *binary_assert; 189 189 190 190 binary_assert = container_of(assert, struct kunit_binary_str_assert, 191 191 assert); ··· 237 237 const struct va_format *message, 238 238 struct string_stream *stream) 239 239 { 240 - struct kunit_mem_assert *mem_assert; 240 + const struct kunit_mem_assert *mem_assert; 241 241 242 242 mem_assert = container_of(assert, struct kunit_mem_assert, 243 243 assert);
+2 -2
lib/tests/test_list_sort.c
··· 26 26 unsigned int serial; 27 27 }; 28 28 29 - static void check(struct kunit *test, struct debug_el *ela, struct debug_el *elb) 29 + static void check(struct kunit *test, const struct debug_el *ela, const struct debug_el *elb) 30 30 { 31 31 struct debug_el **elts = test->priv; 32 32 ··· 46 46 /* `priv` is the test pointer so check() can fail the test if the list is invalid. */ 47 47 static int cmp(void *priv, const struct list_head *a, const struct list_head *b) 48 48 { 49 - struct debug_el *ela, *elb; 49 + const struct debug_el *ela, *elb; 50 50 51 51 ela = container_of(a, struct debug_el, list); 52 52 elb = container_of(b, struct debug_el, list);
+1 -1
rust/helpers/kunit.c
··· 2 2 3 3 #include <kunit/test-bug.h> 4 4 5 - struct kunit *rust_helper_kunit_get_current_test(void) 5 + __rust_helper struct kunit *rust_helper_kunit_get_current_test(void) 6 6 { 7 7 return kunit_get_current_test(); 8 8 }
+34
tools/testing/kunit/kunit-completion.sh
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + # bash completion support for KUnit 3 + 4 + _kunit_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) 5 + 6 + _kunit() 7 + { 8 + local cur prev words cword 9 + _init_completion || return 10 + 11 + local script="${_kunit_dir}/kunit.py" 12 + 13 + if [[ $cword -eq 1 && "$cur" != -* ]]; then 14 + local cmds=$(${script} --list-cmds 2>/dev/null) 15 + COMPREPLY=($(compgen -W "${cmds}" -- "$cur")) 16 + return 0 17 + fi 18 + 19 + if [[ "$cur" == -* ]]; then 20 + if [[ -n "${words[1]}" && "${words[1]}" != -* ]]; then 21 + local opts=$(${script} ${words[1]} --list-opts 2>/dev/null) 22 + COMPREPLY=($(compgen -W "${opts}" -- "$cur")) 23 + return 0 24 + else 25 + local opts=$(${script} --list-opts 2>/dev/null) 26 + COMPREPLY=($(compgen -W "${opts}" -- "$cur")) 27 + return 0 28 + fi 29 + fi 30 + } 31 + 32 + complete -o default -F _kunit kunit.py 33 + complete -o default -F _kunit kunit 34 + complete -o default -F _kunit ./tools/testing/kunit/kunit.py
+36 -1
tools/testing/kunit/kunit.py
··· 323 323 return ncpu 324 324 raise RuntimeError("os.cpu_count() returned None") 325 325 326 + def get_default_build_dir() -> str: 327 + if 'KBUILD_OUTPUT' in os.environ: 328 + return os.path.join(os.environ['KBUILD_OUTPUT'], '.kunit') 329 + return '.kunit' 330 + 331 + def add_completion_opts(parser: argparse.ArgumentParser) -> None: 332 + parser.add_argument('--list-opts', 333 + help=argparse.SUPPRESS, 334 + action='store_true') 335 + 336 + def add_root_opts(parser: argparse.ArgumentParser) -> None: 337 + parser.add_argument('--list-cmds', 338 + help=argparse.SUPPRESS, 339 + action='store_true') 340 + add_completion_opts(parser) 341 + 326 342 def add_common_opts(parser: argparse.ArgumentParser) -> None: 327 343 parser.add_argument('--build_dir', 328 344 help='As in the make command, it specifies the build ' 329 345 'directory.', 330 - type=str, default='.kunit', metavar='DIR') 346 + type=str, default=get_default_build_dir(), metavar='DIR') 331 347 parser.add_argument('--make_options', 332 348 help='X=Y make option, can be repeated.', 333 349 action='append', metavar='X=Y') ··· 389 373 parser.add_argument('--qemu_args', 390 374 help='Additional QEMU arguments, e.g. "-smp 8"', 391 375 action='append', metavar='') 376 + 377 + add_completion_opts(parser) 392 378 393 379 def add_build_opts(parser: argparse.ArgumentParser) -> None: 394 380 parser.add_argument('--jobs', ··· 587 569 def main(argv: Sequence[str]) -> None: 588 570 parser = argparse.ArgumentParser( 589 571 description='Helps writing and running KUnit tests.') 572 + add_root_opts(parser) 590 573 subparser = parser.add_subparsers(dest='subcommand') 591 574 592 575 # The 'run' command will config, build, exec, and parse in one go. ··· 622 603 parse_parser.add_argument('file', 623 604 help='Specifies the file to read results from.', 624 605 type=str, nargs='?', metavar='input_file') 606 + add_completion_opts(parse_parser) 625 607 626 608 cli_args = parser.parse_args(massage_argv(argv)) 627 609 628 610 if get_kernel_root_path(): 629 611 os.chdir(get_kernel_root_path()) 612 + 613 + if cli_args.list_cmds: 614 + print(" ".join(subparser.choices.keys())) 615 + return 616 + 617 + if cli_args.list_opts: 618 + target_parser = subparser.choices.get(cli_args.subcommand) 619 + if not target_parser: 620 + target_parser = parser 621 + 622 + # Accessing private attribute _option_string_actions to get 623 + # the list of options. This is not a public API, but argparse 624 + # does not provide a way to inspect options programmatically. 625 + print(' '.join(target_parser._option_string_actions.keys())) 626 + return 630 627 631 628 subcomand_handler = subcommand_handlers_map.get(cli_args.subcommand, None) 632 629
+3
tools/testing/kunit/kunit_parser.py
··· 689 689 elif test.counts.get_status() == TestStatus.TEST_CRASHED: 690 690 test.status = TestStatus.TEST_CRASHED 691 691 692 + if status == TestStatus.FAILURE and test.counts.get_status() == TestStatus.SUCCESS: 693 + counts.add_status(status) 694 + 692 695 def parse_test(lines: LineStream, expected_num: int, log: List[str], is_subtest: bool, printer: Printer) -> Test: 693 696 """ 694 697 Finds next test to parse in LineStream, creates new Test object,
+81 -29
tools/testing/kunit/kunit_tool_test.py
··· 11 11 12 12 import tempfile, shutil # Handling test_tmpdir 13 13 14 + import io 14 15 import itertools 15 16 import json 16 17 import os 17 18 import signal 18 19 import subprocess 20 + import sys 19 21 from typing import Iterable 20 22 21 23 import kunit_config ··· 38 36 def tearDownModule(): 39 37 shutil.rmtree(test_tmpdir) 40 38 41 - def test_data_path(path): 39 + def _test_data_path(path): 42 40 return os.path.join(abs_test_data_dir, path) 43 41 44 42 class KconfigTest(unittest.TestCase): ··· 54 52 self.assertFalse(kconfig1.is_subset_of(kconfig0)) 55 53 56 54 def test_read_from_file(self): 57 - kconfig_path = test_data_path('test_read_from_file.kconfig') 55 + kconfig_path = _test_data_path('test_read_from_file.kconfig') 58 56 59 57 kconfig = kunit_config.parse_file(kconfig_path) 60 58 ··· 100 98 raise AssertionError(f'"{needle}" not found in {list(backup)}!') 101 99 102 100 def test_output_isolated_correctly(self): 103 - log_path = test_data_path('test_output_isolated_correctly.log') 101 + log_path = _test_data_path('test_output_isolated_correctly.log') 104 102 with open(log_path) as file: 105 103 result = kunit_parser.extract_tap_lines(file.readlines()) 106 104 self.assertContains('TAP version 14', result) ··· 111 109 self.assertContains('ok 1 - example', result) 112 110 113 111 def test_output_with_prefix_isolated_correctly(self): 114 - log_path = test_data_path('test_pound_sign.log') 112 + log_path = _test_data_path('test_pound_sign.log') 115 113 with open(log_path) as file: 116 114 result = kunit_parser.extract_tap_lines(file.readlines()) 117 115 self.assertContains('TAP version 14', result) ··· 140 138 self.assertContains('ok 3 - string-stream-test', result) 141 139 142 140 def test_parse_successful_test_log(self): 143 - all_passed_log = test_data_path('test_is_test_passed-all_passed.log') 141 + all_passed_log = _test_data_path('test_is_test_passed-all_passed.log') 144 142 with open(all_passed_log) as file: 145 143 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 146 144 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) 147 145 self.assertEqual(result.counts.errors, 0) 148 146 149 147 def test_parse_successful_nested_tests_log(self): 150 - all_passed_log = test_data_path('test_is_test_passed-all_passed_nested.log') 148 + all_passed_log = _test_data_path('test_is_test_passed-all_passed_nested.log') 151 149 with open(all_passed_log) as file: 152 150 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 153 151 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) 154 152 self.assertEqual(result.counts.errors, 0) 155 153 156 154 def test_kselftest_nested(self): 157 - kselftest_log = test_data_path('test_is_test_passed-kselftest.log') 155 + kselftest_log = _test_data_path('test_is_test_passed-kselftest.log') 158 156 with open(kselftest_log) as file: 159 157 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 160 158 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) 161 159 self.assertEqual(result.counts.errors, 0) 162 160 163 161 def test_parse_failed_test_log(self): 164 - failed_log = test_data_path('test_is_test_passed-failure.log') 162 + failed_log = _test_data_path('test_is_test_passed-failure.log') 165 163 with open(failed_log) as file: 166 164 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 167 165 self.assertEqual(kunit_parser.TestStatus.FAILURE, result.status) 168 166 self.assertEqual(result.counts.errors, 0) 169 167 168 + def test_parse_failed_nested_tests_log(self): 169 + nested_log = _test_data_path('test_is_test_passed-failure-nested.log') 170 + with open(nested_log) as file: 171 + result = kunit_parser.parse_run_tests(file.readlines(), stdout) 172 + self.assertEqual(kunit_parser.TestStatus.FAILURE, result.status) 173 + self.assertEqual(result.counts.failed, 2) 174 + self.assertEqual(kunit_parser.TestStatus.FAILURE, result.subtests[0].status) 175 + self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.subtests[0].subtests[0].status) 176 + self.assertEqual(kunit_parser.TestStatus.FAILURE, result.subtests[1].status) 177 + self.assertEqual(kunit_parser.TestStatus.FAILURE, result.subtests[1].subtests[0].status) 178 + 170 179 def test_no_header(self): 171 - empty_log = test_data_path('test_is_test_passed-no_tests_run_no_header.log') 180 + empty_log = _test_data_path('test_is_test_passed-no_tests_run_no_header.log') 172 181 with open(empty_log) as file: 173 182 result = kunit_parser.parse_run_tests( 174 183 kunit_parser.extract_tap_lines(file.readlines()), stdout) ··· 188 175 self.assertEqual(result.counts.errors, 1) 189 176 190 177 def test_missing_test_plan(self): 191 - missing_plan_log = test_data_path('test_is_test_passed-' 178 + missing_plan_log = _test_data_path('test_is_test_passed-' 192 179 'missing_plan.log') 193 180 with open(missing_plan_log) as file: 194 181 result = kunit_parser.parse_run_tests( ··· 199 186 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) 200 187 201 188 def test_no_tests(self): 202 - header_log = test_data_path('test_is_test_passed-no_tests_run_with_header.log') 189 + header_log = _test_data_path('test_is_test_passed-no_tests_run_with_header.log') 203 190 with open(header_log) as file: 204 191 result = kunit_parser.parse_run_tests( 205 192 kunit_parser.extract_tap_lines(file.readlines()), stdout) ··· 208 195 self.assertEqual(result.counts.errors, 1) 209 196 210 197 def test_no_tests_no_plan(self): 211 - no_plan_log = test_data_path('test_is_test_passed-no_tests_no_plan.log') 198 + no_plan_log = _test_data_path('test_is_test_passed-no_tests_no_plan.log') 212 199 with open(no_plan_log) as file: 213 200 result = kunit_parser.parse_run_tests( 214 201 kunit_parser.extract_tap_lines(file.readlines()), stdout) ··· 220 207 221 208 222 209 def test_no_kunit_output(self): 223 - crash_log = test_data_path('test_insufficient_memory.log') 210 + crash_log = _test_data_path('test_insufficient_memory.log') 224 211 print_mock = mock.patch('kunit_printer.Printer.print').start() 225 212 with open(crash_log) as file: 226 213 result = kunit_parser.parse_run_tests( ··· 231 218 self.assertEqual(result.counts.errors, 1) 232 219 233 220 def test_skipped_test(self): 234 - skipped_log = test_data_path('test_skip_tests.log') 221 + skipped_log = _test_data_path('test_skip_tests.log') 235 222 with open(skipped_log) as file: 236 223 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 237 224 ··· 240 227 self.assertEqual(result.counts, kunit_parser.TestCounts(passed=4, skipped=1)) 241 228 242 229 def test_skipped_all_tests(self): 243 - skipped_log = test_data_path('test_skip_all_tests.log') 230 + skipped_log = _test_data_path('test_skip_all_tests.log') 244 231 with open(skipped_log) as file: 245 232 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 246 233 ··· 248 235 self.assertEqual(result.counts, kunit_parser.TestCounts(skipped=5)) 249 236 250 237 def test_ignores_hyphen(self): 251 - hyphen_log = test_data_path('test_strip_hyphen.log') 238 + hyphen_log = _test_data_path('test_strip_hyphen.log') 252 239 with open(hyphen_log) as file: 253 240 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 254 241 ··· 262 249 result.subtests[1].name) 263 250 264 251 def test_ignores_prefix_printk_time(self): 265 - prefix_log = test_data_path('test_config_printk_time.log') 252 + prefix_log = _test_data_path('test_config_printk_time.log') 266 253 with open(prefix_log) as file: 267 254 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 268 255 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) ··· 270 257 self.assertEqual(result.counts.errors, 0) 271 258 272 259 def test_ignores_multiple_prefixes(self): 273 - prefix_log = test_data_path('test_multiple_prefixes.log') 260 + prefix_log = _test_data_path('test_multiple_prefixes.log') 274 261 with open(prefix_log) as file: 275 262 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 276 263 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) ··· 278 265 self.assertEqual(result.counts.errors, 0) 279 266 280 267 def test_prefix_mixed_kernel_output(self): 281 - mixed_prefix_log = test_data_path('test_interrupted_tap_output.log') 268 + mixed_prefix_log = _test_data_path('test_interrupted_tap_output.log') 282 269 with open(mixed_prefix_log) as file: 283 270 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 284 271 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) ··· 286 273 self.assertEqual(result.counts.errors, 0) 287 274 288 275 def test_prefix_poundsign(self): 289 - pound_log = test_data_path('test_pound_sign.log') 276 + pound_log = _test_data_path('test_pound_sign.log') 290 277 with open(pound_log) as file: 291 278 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 292 279 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) ··· 294 281 self.assertEqual(result.counts.errors, 0) 295 282 296 283 def test_kernel_panic_end(self): 297 - panic_log = test_data_path('test_kernel_panic_interrupt.log') 284 + panic_log = _test_data_path('test_kernel_panic_interrupt.log') 298 285 with open(panic_log) as file: 299 286 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 300 287 self.assertEqual(kunit_parser.TestStatus.TEST_CRASHED, result.status) ··· 302 289 self.assertGreaterEqual(result.counts.errors, 1) 303 290 304 291 def test_pound_no_prefix(self): 305 - pound_log = test_data_path('test_pound_no_prefix.log') 292 + pound_log = _test_data_path('test_pound_no_prefix.log') 306 293 with open(pound_log) as file: 307 294 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 308 295 self.assertEqual(kunit_parser.TestStatus.SUCCESS, result.status) ··· 331 318 'Failures: all_failed_suite, some_failed_suite.test2') 332 319 333 320 def test_ktap_format(self): 334 - ktap_log = test_data_path('test_parse_ktap_output.log') 321 + ktap_log = _test_data_path('test_parse_ktap_output.log') 335 322 with open(ktap_log) as file: 336 323 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 337 324 self.assertEqual(result.counts, kunit_parser.TestCounts(passed=3)) ··· 340 327 self.assertEqual('case_2', result.subtests[0].subtests[1].name) 341 328 342 329 def test_parse_subtest_header(self): 343 - ktap_log = test_data_path('test_parse_subtest_header.log') 330 + ktap_log = _test_data_path('test_parse_subtest_header.log') 344 331 with open(ktap_log) as file: 345 332 kunit_parser.parse_run_tests(file.readlines(), stdout) 346 333 self.print_mock.assert_any_call(StrContains('suite (1 subtest)')) 347 334 348 335 def test_parse_attributes(self): 349 - ktap_log = test_data_path('test_parse_attributes.log') 336 + ktap_log = _test_data_path('test_parse_attributes.log') 350 337 with open(ktap_log) as file: 351 338 result = kunit_parser.parse_run_tests(file.readlines(), stdout) 352 339 ··· 479 466 want_kconfig = kunit_config.Kconfig() 480 467 want_kconfig.add_entry('NOT_REAL', 'y') 481 468 482 - tree = kunit_kernel.LinuxSourceTree('', kconfig_add=['CONFIG_NOT_REAL=y']) 469 + tree = kunit_kernel.LinuxSourceTree('', kunitconfig_paths=[os.devnull], 470 + kconfig_add=['CONFIG_NOT_REAL=y']) 483 471 self.assertTrue(want_kconfig.is_subset_of(tree._kconfig), msg=tree._kconfig) 484 472 485 473 def test_invalid_arch(self): ··· 492 478 return subprocess.Popen(['echo "hi\nbye"'], shell=True, text=True, stdout=subprocess.PIPE) 493 479 494 480 with tempfile.TemporaryDirectory('') as build_dir: 495 - tree = kunit_kernel.LinuxSourceTree(build_dir) 481 + tree = kunit_kernel.LinuxSourceTree(build_dir, kunitconfig_paths=[os.devnull]) 496 482 mock.patch.object(tree._ops, 'start', side_effect=fake_start).start() 497 483 498 484 with self.assertRaises(ValueError): ··· 569 555 self.addCleanup(mock.patch.stopall) 570 556 571 557 def _json_for(self, log_file): 572 - with open(test_data_path(log_file)) as file: 558 + with open(_test_data_path(log_file)) as file: 573 559 test_result = kunit_parser.parse_run_tests(file, stdout) 574 560 json_obj = kunit_json.get_json_result( 575 561 test=test_result, ··· 610 596 611 597 class KUnitMainTest(unittest.TestCase): 612 598 def setUp(self): 613 - path = test_data_path('test_is_test_passed-all_passed.log') 599 + path = _test_data_path('test_is_test_passed-all_passed.log') 614 600 with open(path) as file: 615 601 all_passed_log = file.readlines() 616 602 617 603 self.print_mock = mock.patch('kunit_printer.Printer.print').start() 604 + mock.patch.dict(os.environ, clear=True).start() 618 605 self.addCleanup(mock.patch.stopall) 619 606 620 607 self.mock_linux_init = mock.patch.object(kunit_kernel, 'LinuxSourceTree').start() ··· 731 716 self.print_mock.assert_any_call(StrContains('Testing complete.')) 732 717 733 718 def test_run_builddir(self): 719 + build_dir = '.kunit' 720 + kunit.main(['run', '--build_dir=.kunit']) 721 + self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1) 722 + self.linux_source_mock.run_kernel.assert_called_once_with( 723 + args=None, build_dir=build_dir, filter_glob='', filter='', filter_action=None, timeout=300) 724 + self.print_mock.assert_any_call(StrContains('Testing complete.')) 725 + 726 + @mock.patch.dict(os.environ, {'KBUILD_OUTPUT': '/tmp'}) 727 + def test_run_builddir_from_env(self): 728 + build_dir = '/tmp/.kunit' 729 + kunit.main(['run']) 730 + self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1) 731 + self.linux_source_mock.run_kernel.assert_called_once_with( 732 + args=None, build_dir=build_dir, filter_glob='', filter='', filter_action=None, timeout=300) 733 + self.print_mock.assert_any_call(StrContains('Testing complete.')) 734 + 735 + @mock.patch.dict(os.environ, {'KBUILD_OUTPUT': '/tmp'}) 736 + def test_run_builddir_override(self): 734 737 build_dir = '.kunit' 735 738 kunit.main(['run', '--build_dir=.kunit']) 736 739 self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1) ··· 887 854 mock.call(args=None, build_dir='.kunit', filter_glob='suite.test2', filter='', filter_action=None, timeout=300), 888 855 mock.call(args=None, build_dir='.kunit', filter_glob='suite2.test1', filter='', filter_action=None, timeout=300), 889 856 ]) 857 + 858 + @mock.patch.object(sys, 'stdout', new_callable=io.StringIO) 859 + def test_list_cmds(self, mock_stdout): 860 + kunit.main(['--list-cmds']) 861 + output = mock_stdout.getvalue() 862 + output_cmds = sorted(output.split()) 863 + expected_cmds = sorted(['build', 'config', 'exec', 'parse', 'run']) 864 + self.assertEqual(output_cmds, expected_cmds) 865 + 866 + @mock.patch.object(sys, 'stdout', new_callable=io.StringIO) 867 + def test_run_list_opts(self, mock_stdout): 868 + kunit.main(['run', '--list-opts']) 869 + output = mock_stdout.getvalue() 870 + output_cmds = set(output.split()) 871 + self.assertIn('--help', output_cmds) 872 + self.assertIn('--kunitconfig', output_cmds) 873 + self.assertIn('--jobs', output_cmds) 874 + self.assertIn('--kernel_args', output_cmds) 875 + self.assertIn('--raw_output', output_cmds) 890 876 891 877 if __name__ == '__main__': 892 878 unittest.main()
+16
tools/testing/kunit/qemu_configs/armeb.py
··· 1 + # SPDX-License-Identifier: GPL-2.0 2 + 3 + from ..qemu_config import QemuArchParams 4 + 5 + QEMU_ARCH = QemuArchParams(linux_arch='arm', 6 + kconfig=''' 7 + CONFIG_CPU_BIG_ENDIAN=y 8 + CONFIG_ARCH_VIRT=y 9 + CONFIG_SERIAL_AMBA_PL010=y 10 + CONFIG_SERIAL_AMBA_PL010_CONSOLE=y 11 + CONFIG_SERIAL_AMBA_PL011=y 12 + CONFIG_SERIAL_AMBA_PL011_CONSOLE=y''', 13 + qemu_arch='arm', 14 + kernel_path='arch/arm/boot/zImage', 15 + kernel_command_line='console=ttyAMA0', 16 + extra_qemu_params=['-machine', 'virt'])
+10
tools/testing/kunit/test_data/test_is_test_passed-failure-nested.log
··· 1 + KTAP version 1 2 + 1..2 3 + KTAP version 1 4 + 1..1 5 + ok 1 test 1 6 + not ok 1 subtest 1 7 + KTAP version 1 8 + 1..1 9 + not ok 1 subsubtest 1 10 + not ok 2 subtest 2