Skip to content

Commit 01397e8

Browse files
ihashuahkh
authored andcommitted
kunit: Fix TabError, remove defconfig code and handle when there is no kunitconfig
The identation before this code (`if not os.path.exists(cli_args.build_dir):``) was with spaces instead of tabs after fixed up merge conflits, this commit revert spaces to tabs: [iha@bbking linux]$ tools/testing/kunit/kunit.py run File "tools/testing/kunit/kunit.py", line 247 if not linux: ^ TabError: inconsistent use of tabs and spaces in indentation [iha@bbking linux]$ tools/testing/kunit/kunit.py run Traceback (most recent call last): File "tools/testing/kunit/kunit.py", line 338, in <module> main(sys.argv[1:]) File "tools/testing/kunit/kunit.py", line 215, in main add_config_opts(config_parser) [iha@bbking linux]$ tools/testing/kunit/kunit.py run Traceback (most recent call last): File "tools/testing/kunit/kunit.py", line 337, in <module> main(sys.argv[1:]) File "tools/testing/kunit/kunit.py", line 255, in main result = run_tests(linux, request) File "tools/testing/kunit/kunit.py", line 133, in run_tests request.defconfig, AttributeError: 'KunitRequest' object has no attribute 'defconfig' Handles when there is no .kunitconfig, the error due to merge conflicts between the following: commit 9bdf64b ("kunit: use KUnit defconfig by default") commit 45ba7a8 ("kunit: kunit_tool: Separate out config/build/exec/parse") [iha@bbking linux]$ tools/testing/kunit/kunit.py run Traceback (most recent call last): File "tools/testing/kunit/kunit.py", line 335, in <module> main(sys.argv[1:]) File "tools/testing/kunit/kunit.py", line 246, in main linux = kunit_kernel.LinuxSourceTree() File "../tools/testing/kunit/kunit_kernel.py", line 109, in __init__ self._kconfig.read_from_file(kunitconfig_path) File "t../ools/testing/kunit/kunit_config.py", line 88, in read_from_file with open(path, 'r') as f: FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig' Signed-off-by: Vitor Massaru Iha <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 9bdf64b commit 01397e8

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

tools/testing/kunit/kunit.py

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
KunitResult = namedtuple('KunitResult', ['status','result','elapsed_time'])
2424

2525
KunitConfigRequest = namedtuple('KunitConfigRequest',
26-
['build_dir', 'defconfig', 'make_options'])
26+
['build_dir', 'make_options'])
2727
KunitBuildRequest = namedtuple('KunitBuildRequest',
2828
['jobs', 'build_dir', 'alltests',
2929
'make_options'])
@@ -130,7 +130,6 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree,
130130
run_start = time.time()
131131

132132
config_request = KunitConfigRequest(request.build_dir,
133-
request.defconfig,
134133
request.make_options)
135134
config_result = config_tests(linux, config_request)
136135
if config_result.status != KunitStatus.SUCCESS:
@@ -212,7 +211,6 @@ def main(argv, linux=None):
212211
help='Ensures that .config contains all of '
213212
'the options in .kunitconfig')
214213
add_common_opts(config_parser)
215-
add_config_opts(config_parser)
216214

217215
build_parser = subparser.add_parser('build', help='Builds a kernel with KUnit tests')
218216
add_common_opts(build_parser)
@@ -238,11 +236,14 @@ def main(argv, linux=None):
238236
cli_args = parser.parse_args(argv)
239237

240238
if cli_args.subcommand == 'run':
241-
if not os.path.exists(cli_args.build_dir):
242-
os.mkdir(cli_args.build_dir)
243-
kunit_kernel.kunitconfig_path = os.path.join(
244-
cli_args.build_dir,
245-
kunit_kernel.kunitconfig_path)
239+
if not os.path.exists(cli_args.build_dir):
240+
os.mkdir(cli_args.build_dir)
241+
kunit_kernel.kunitconfig_path = os.path.join(
242+
cli_args.build_dir,
243+
kunit_kernel.kunitconfig_path)
244+
245+
if not os.path.exists(kunit_kernel.kunitconfig_path):
246+
create_default_kunitconfig()
246247

247248
if not linux:
248249
linux = kunit_kernel.LinuxSourceTree()
@@ -264,11 +265,13 @@ def main(argv, linux=None):
264265
cli_args.build_dir,
265266
kunit_kernel.kunitconfig_path)
266267

268+
if not os.path.exists(kunit_kernel.kunitconfig_path):
269+
create_default_kunitconfig()
270+
267271
if not linux:
268272
linux = kunit_kernel.LinuxSourceTree()
269273

270274
request = KunitConfigRequest(cli_args.build_dir,
271-
cli_args.defconfig,
272275
cli_args.make_options)
273276
result = config_tests(linux, request)
274277
kunit_parser.print_with_timestamp((
@@ -284,6 +287,9 @@ def main(argv, linux=None):
284287
cli_args.build_dir,
285288
kunit_kernel.kunitconfig_path)
286289

290+
if not os.path.exists(kunit_kernel.kunitconfig_path):
291+
create_default_kunitconfig()
292+
287293
if not linux:
288294
linux = kunit_kernel.LinuxSourceTree()
289295

@@ -305,6 +311,9 @@ def main(argv, linux=None):
305311
cli_args.build_dir,
306312
kunit_kernel.kunitconfig_path)
307313

314+
if not os.path.exists(kunit_kernel.kunitconfig_path):
315+
create_default_kunitconfig()
316+
308317
if not linux:
309318
linux = kunit_kernel.LinuxSourceTree()
310319

0 commit comments

Comments
 (0)