Skip to contentSkip to conversation

kunit: tool: handle when .kunit exists but .kunitconfig does not

PATCH New Brendan Higgins 1 participant 1 message Sep 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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 5578d008d9e0 ("kunit: tool: fix running kunit_tool from outside kernel tree")

---
 tools/testing/kunit/kunit.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tools/testing/kunit/kunit.py +8 -4
index e2caf4e24ecb2..8ab17e21a3578 100755
@@ -243,6 +243,8 @@ def main(argv, linux=None):
 	if cli_args.subcommand == 'run':
 		if not os.path.exists(cli_args.build_dir):
 			os.mkdir(cli_args.build_dir)
+
+		if not os.path.exists(kunit_kernel.kunitconfig_path):
 			create_default_kunitconfig()
 
 		if not linux:
@@ -258,10 +260,12 @@ def main(argv, linux=None):
 		if result.status != KunitStatus.SUCCESS:
 			sys.exit(1)
 	elif cli_args.subcommand == 'config':
-		if cli_args.build_dir:
-			if not os.path.exists(cli_args.build_dir):
-				os.mkdir(cli_args.build_dir)
-				create_default_kunitconfig()
+		if cli_args.build_dir and (
+				not os.path.exists(cli_args.build_dir)):
+			os.mkdir(cli_args.build_dir)
+
+		if not os.path.exists(kunit_kernel.kunitconfig_path):
+			create_default_kunitconfig()
 
 		if not linux:
 			linux = kunit_kernel.LinuxSourceTree()

base-commit: d96fe1a5485fa978a6e3690adc4dbe4d20b5baa4

Signature · 1 line
2.28.0.681.g6f77f65b4e-goog