Skip to content

Commit 1ee2ba8

Browse files
dlatypovshuahkh
authored andcommitted
kunit: tool: make build subcommand also reconfigure if needed
If I created a kunitconfig file that was incomplete, then $ ./tools/testing/kunit/kunit.py build --kunitconfig=my_kunitconfig would silently drop all the options with unmet dependencies! This is because it doesn't do the config check that `kunit.py config` does. So if I want to safely build a kernel for testing, I have to do $ ./tools/testing/kunit/kunit.py config <flags> $ ./tools/testing/kunit/kunit.py build <flags, again> It seems unlikely that any user of kunit.py would want the current `build` semantics. So make it effectively do `kunit.py config` + `kunit.py build`. Signed-off-by: Daniel Latypov <[email protected]> Reviewed-by: Brendan Higgins <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent e0cc8c0 commit 1ee2ba8

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tools/testing/kunit/kunit.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree,
110110
'built kernel successfully',
111111
build_end - build_start)
112112

113+
def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree,
114+
request: KunitBuildRequest) -> KunitResult:
115+
config_result = config_tests(linux, request)
116+
if config_result.status != KunitStatus.SUCCESS:
117+
return config_result
118+
119+
return build_tests(linux, request)
120+
113121
def _list_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -> List[str]:
114122
args = ['kunit.action=list']
115123
if request.kernel_args:
@@ -464,7 +472,7 @@ def main(argv, linux=None):
464472
make_options=cli_args.make_options,
465473
jobs=cli_args.jobs,
466474
alltests=cli_args.alltests)
467-
result = build_tests(linux, request)
475+
result = config_and_build_tests(linux, request)
468476
kunit_parser.print_with_timestamp((
469477
'Elapsed time: %.3fs\n') % (
470478
result.elapsed_time))

tools/testing/kunit/kunit_tool_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ def test_config_passes_args_pass(self):
526526

527527
def test_build_passes_args_pass(self):
528528
kunit.main(['build'], self.linux_source_mock)
529-
self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 0)
529+
self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1)
530530
self.linux_source_mock.build_kernel.assert_called_once_with(False, 8, '.kunit', None)
531531
self.assertEqual(self.linux_source_mock.run_kernel.call_count, 0)
532532

0 commit comments

Comments
 (0)