Skip to content

Commit 82206a0

Browse files
bjh83shuahkh
authored andcommitted
kunit: tool: handle when .kunit exists but .kunitconfig does not
Right now .kunitconfig and the build dir are automatically created if the build dir does not exists; however, if the build dir is present and .kunitconfig is not, kunit_tool will crash. Fix this by checking for both the build dir as well as the .kunitconfig. NOTE: This depends on commit 5578d00 ("kunit: tool: fix running kunit_tool from outside kernel tree") Link: https://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest.git/commit/?id=5578d008d9e06bb531fb3e62dd17096d9fd9c853 Signed-off-by: Brendan Higgins <brendanhiggins@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 67e2fae commit 82206a0

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

tools/testing/kunit/kunit.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ def main(argv, linux=None):
261261
if cli_args.subcommand == 'run':
262262
if not os.path.exists(cli_args.build_dir):
263263
os.mkdir(cli_args.build_dir)
264+
265+
if not os.path.exists(kunit_kernel.kunitconfig_path):
264266
create_default_kunitconfig()
265267

266268
if not linux:
@@ -277,10 +279,12 @@ def main(argv, linux=None):
277279
if result.status != KunitStatus.SUCCESS:
278280
sys.exit(1)
279281
elif cli_args.subcommand == 'config':
280-
if cli_args.build_dir:
281-
if not os.path.exists(cli_args.build_dir):
282-
os.mkdir(cli_args.build_dir)
283-
create_default_kunitconfig()
282+
if cli_args.build_dir and (
283+
not os.path.exists(cli_args.build_dir)):
284+
os.mkdir(cli_args.build_dir)
285+
286+
if not os.path.exists(kunit_kernel.kunitconfig_path):
287+
create_default_kunitconfig()
284288

285289
if not linux:
286290
linux = kunit_kernel.LinuxSourceTree()

0 commit comments

Comments
 (0)