Commit 1ee2ba89 authored by Daniel Latypov's avatar Daniel Latypov Committed by Shuah Khan

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: default avatarDaniel Latypov <dlatypov@google.com>
Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent e0cc8c05
...@@ -110,6 +110,14 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree, ...@@ -110,6 +110,14 @@ def build_tests(linux: kunit_kernel.LinuxSourceTree,
'built kernel successfully', 'built kernel successfully',
build_end - build_start) build_end - build_start)
def config_and_build_tests(linux: kunit_kernel.LinuxSourceTree,
request: KunitBuildRequest) -> KunitResult:
config_result = config_tests(linux, request)
if config_result.status != KunitStatus.SUCCESS:
return config_result
return build_tests(linux, request)
def _list_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -> List[str]: def _list_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitExecRequest) -> List[str]:
args = ['kunit.action=list'] args = ['kunit.action=list']
if request.kernel_args: if request.kernel_args:
...@@ -464,7 +472,7 @@ def main(argv, linux=None): ...@@ -464,7 +472,7 @@ def main(argv, linux=None):
make_options=cli_args.make_options, make_options=cli_args.make_options,
jobs=cli_args.jobs, jobs=cli_args.jobs,
alltests=cli_args.alltests) alltests=cli_args.alltests)
result = build_tests(linux, request) result = config_and_build_tests(linux, request)
kunit_parser.print_with_timestamp(( kunit_parser.print_with_timestamp((
'Elapsed time: %.3fs\n') % ( 'Elapsed time: %.3fs\n') % (
result.elapsed_time)) result.elapsed_time))
......
...@@ -526,7 +526,7 @@ class KUnitMainTest(unittest.TestCase): ...@@ -526,7 +526,7 @@ class KUnitMainTest(unittest.TestCase):
def test_build_passes_args_pass(self): def test_build_passes_args_pass(self):
kunit.main(['build'], self.linux_source_mock) kunit.main(['build'], self.linux_source_mock)
self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 0) self.assertEqual(self.linux_source_mock.build_reconfig.call_count, 1)
self.linux_source_mock.build_kernel.assert_called_once_with(False, 8, '.kunit', None) self.linux_source_mock.build_kernel.assert_called_once_with(False, 8, '.kunit', None)
self.assertEqual(self.linux_source_mock.run_kernel.call_count, 0) self.assertEqual(self.linux_source_mock.run_kernel.call_count, 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment