Commit e3212513 authored by SeongJae Park's avatar SeongJae Park Committed by Shuah Khan

kunit: Create default config in '--build_dir'

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: default avatarBrendan Higgins <brendanhiggins@google.com>
Suggested-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarSeongJae Park <sjpark@amazon.de>
Reviewed-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Tested-by: default avatarBrendan Higgins <brendanhiggins@google.com>
Signed-off-by: default avatarShuah Khan <skhan@linuxfoundation.org>
parent 8c0140fa
...@@ -31,9 +31,9 @@ class KunitStatus(Enum): ...@@ -31,9 +31,9 @@ class KunitStatus(Enum):
TEST_FAILURE = auto() TEST_FAILURE = auto()
def create_default_kunitconfig(): 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', shutil.copyfile('arch/um/configs/kunit_defconfig',
kunit_kernel.KUNITCONFIG_PATH) kunit_kernel.kunitconfig_path)
def run_tests(linux: kunit_kernel.LinuxSourceTree, def run_tests(linux: kunit_kernel.LinuxSourceTree,
request: KunitRequest) -> KunitResult: request: KunitRequest) -> KunitResult:
...@@ -114,6 +114,13 @@ def main(argv, linux=None): ...@@ -114,6 +114,13 @@ 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 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: if cli_args.defconfig:
create_default_kunitconfig() create_default_kunitconfig()
......
...@@ -14,7 +14,7 @@ import os ...@@ -14,7 +14,7 @@ import os
import kunit_config import kunit_config
KCONFIG_PATH = '.config' KCONFIG_PATH = '.config'
KUNITCONFIG_PATH = 'kunitconfig' kunitconfig_path = 'kunitconfig'
class ConfigError(Exception): class ConfigError(Exception):
"""Represents an error trying to configure the Linux kernel.""" """Represents an error trying to configure the Linux kernel."""
...@@ -82,7 +82,7 @@ class LinuxSourceTree(object): ...@@ -82,7 +82,7 @@ class LinuxSourceTree(object):
def __init__(self): def __init__(self):
self._kconfig = kunit_config.Kconfig() self._kconfig = kunit_config.Kconfig()
self._kconfig.read_from_file(KUNITCONFIG_PATH) self._kconfig.read_from_file(kunitconfig_path)
self._ops = LinuxSourceTreeOperations() self._ops = LinuxSourceTreeOperations()
def clean(self): def clean(self):
......
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