Commit 01397e82 authored by Vitor Massaru Iha's avatar Vitor Massaru Iha Committed by Shuah Khan

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 9bdf64b3 ("kunit: use KUnit defconfig by default")
commit 45ba7a89 ("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: default avatarVitor Massaru Iha <vitor@massaru.org>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 9bdf64b3
...@@ -23,7 +23,7 @@ import kunit_parser ...@@ -23,7 +23,7 @@ import kunit_parser
KunitResult = namedtuple('KunitResult', ['status','result','elapsed_time']) KunitResult = namedtuple('KunitResult', ['status','result','elapsed_time'])
KunitConfigRequest = namedtuple('KunitConfigRequest', KunitConfigRequest = namedtuple('KunitConfigRequest',
['build_dir', 'defconfig', 'make_options']) ['build_dir', 'make_options'])
KunitBuildRequest = namedtuple('KunitBuildRequest', KunitBuildRequest = namedtuple('KunitBuildRequest',
['jobs', 'build_dir', 'alltests', ['jobs', 'build_dir', 'alltests',
'make_options']) 'make_options'])
...@@ -130,7 +130,6 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree, ...@@ -130,7 +130,6 @@ def run_tests(linux: kunit_kernel.LinuxSourceTree,
run_start = time.time() run_start = time.time()
config_request = KunitConfigRequest(request.build_dir, config_request = KunitConfigRequest(request.build_dir,
request.defconfig,
request.make_options) request.make_options)
config_result = config_tests(linux, config_request) config_result = config_tests(linux, config_request)
if config_result.status != KunitStatus.SUCCESS: if config_result.status != KunitStatus.SUCCESS:
...@@ -212,7 +211,6 @@ def main(argv, linux=None): ...@@ -212,7 +211,6 @@ def main(argv, linux=None):
help='Ensures that .config contains all of ' help='Ensures that .config contains all of '
'the options in .kunitconfig') 'the options in .kunitconfig')
add_common_opts(config_parser) add_common_opts(config_parser)
add_config_opts(config_parser)
build_parser = subparser.add_parser('build', help='Builds a kernel with KUnit tests') build_parser = subparser.add_parser('build', help='Builds a kernel with KUnit tests')
add_common_opts(build_parser) add_common_opts(build_parser)
...@@ -238,11 +236,14 @@ def main(argv, linux=None): ...@@ -238,11 +236,14 @@ def main(argv, linux=None):
cli_args = parser.parse_args(argv) cli_args = parser.parse_args(argv)
if cli_args.subcommand == 'run': if cli_args.subcommand == 'run':
if not os.path.exists(cli_args.build_dir): if not os.path.exists(cli_args.build_dir):
os.mkdir(cli_args.build_dir) os.mkdir(cli_args.build_dir)
kunit_kernel.kunitconfig_path = os.path.join( kunit_kernel.kunitconfig_path = os.path.join(
cli_args.build_dir, cli_args.build_dir,
kunit_kernel.kunitconfig_path) kunit_kernel.kunitconfig_path)
if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()
if not linux: if not linux:
linux = kunit_kernel.LinuxSourceTree() linux = kunit_kernel.LinuxSourceTree()
...@@ -264,11 +265,13 @@ def main(argv, linux=None): ...@@ -264,11 +265,13 @@ def main(argv, linux=None):
cli_args.build_dir, cli_args.build_dir,
kunit_kernel.kunitconfig_path) kunit_kernel.kunitconfig_path)
if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()
if not linux: if not linux:
linux = kunit_kernel.LinuxSourceTree() linux = kunit_kernel.LinuxSourceTree()
request = KunitConfigRequest(cli_args.build_dir, request = KunitConfigRequest(cli_args.build_dir,
cli_args.defconfig,
cli_args.make_options) cli_args.make_options)
result = config_tests(linux, request) result = config_tests(linux, request)
kunit_parser.print_with_timestamp(( kunit_parser.print_with_timestamp((
...@@ -284,6 +287,9 @@ def main(argv, linux=None): ...@@ -284,6 +287,9 @@ def main(argv, linux=None):
cli_args.build_dir, cli_args.build_dir,
kunit_kernel.kunitconfig_path) kunit_kernel.kunitconfig_path)
if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()
if not linux: if not linux:
linux = kunit_kernel.LinuxSourceTree() linux = kunit_kernel.LinuxSourceTree()
...@@ -305,6 +311,9 @@ def main(argv, linux=None): ...@@ -305,6 +311,9 @@ def main(argv, linux=None):
cli_args.build_dir, cli_args.build_dir,
kunit_kernel.kunitconfig_path) kunit_kernel.kunitconfig_path)
if not os.path.exists(kunit_kernel.kunitconfig_path):
create_default_kunitconfig()
if not linux: if not linux:
linux = kunit_kernel.LinuxSourceTree() linux = kunit_kernel.LinuxSourceTree()
......
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