]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kunit: Create default config in '--build_dir'
authorSeongJae Park <sjpark@amazon.de>
Fri, 20 Dec 2019 05:14:05 +0000 (05:14 +0000)
committerShuah Khan <skhan@linuxfoundation.org>
Mon, 23 Dec 2019 17:52:41 +0000 (10:52 -0700)
If both '--build_dir' and '--defconfig' are given, the handling of
'--defconfig' ignores '--build_dir' option.  This commit modifies the
behavior to respect '--build_dir' option.

Reported-by: Brendan Higgins <brendanhiggins@google.com>
Suggested-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: SeongJae Park <sjpark@amazon.de>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Tested-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
tools/testing/kunit/kunit.py
tools/testing/kunit/kunit_kernel.py

index f8f26951cd1b513992acd10b46b3ca9022cfebc9..5b222418eacdfa28178f8596ef2482b4c518157b 100755 (executable)
@@ -31,9 +31,9 @@ class KunitStatus(Enum):
        TEST_FAILURE = auto()
 
 def create_default_kunitconfig():
-       if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH):
+       if not os.path.exists(kunit_kernel.kunitconfig_path):
                shutil.copyfile('arch/um/configs/kunit_defconfig',
-                               kunit_kernel.KUNITCONFIG_PATH)
+                               kunit_kernel.kunitconfig_path)
 
 def run_tests(linux: kunit_kernel.LinuxSourceTree,
              request: KunitRequest) -> KunitResult:
@@ -114,6 +114,13 @@ def main(argv, linux=None):
        cli_args = parser.parse_args(argv)
 
        if cli_args.subcommand == 'run':
+               if cli_args.build_dir:
+                       if not os.path.exists(cli_args.build_dir):
+                               os.mkdir(cli_args.build_dir)
+                       kunit_kernel.kunitconfig_path = os.path.join(
+                               cli_args.build_dir,
+                               kunit_kernel.kunitconfig_path)
+
                if cli_args.defconfig:
                        create_default_kunitconfig()
 
index bf3876835331327c7525fb3727647bd9070ec0b9..c04a12e2f711deba71bb3de2d04f492daef71535 100644 (file)
@@ -14,7 +14,7 @@ import os
 import kunit_config
 
 KCONFIG_PATH = '.config'
-KUNITCONFIG_PATH = 'kunitconfig'
+kunitconfig_path = 'kunitconfig'
 
 class ConfigError(Exception):
        """Represents an error trying to configure the Linux kernel."""
@@ -82,7 +82,7 @@ class LinuxSourceTree(object):
 
        def __init__(self):
                self._kconfig = kunit_config.Kconfig()
-               self._kconfig.read_from_file(KUNITCONFIG_PATH)
+               self._kconfig.read_from_file(kunitconfig_path)
                self._ops = LinuxSourceTreeOperations()
 
        def clean(self):