Skip to content

Commit e321251

Browse files
sj-awsshuahkh
authored andcommitted
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: 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>
1 parent 8c0140f commit e321251

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

tools/testing/kunit/kunit.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ class KunitStatus(Enum):
3131
TEST_FAILURE = auto()
3232

3333
def create_default_kunitconfig():
34-
if not os.path.exists(kunit_kernel.KUNITCONFIG_PATH):
34+
if not os.path.exists(kunit_kernel.kunitconfig_path):
3535
shutil.copyfile('arch/um/configs/kunit_defconfig',
36-
kunit_kernel.KUNITCONFIG_PATH)
36+
kunit_kernel.kunitconfig_path)
3737

3838
def run_tests(linux: kunit_kernel.LinuxSourceTree,
3939
request: KunitRequest) -> KunitResult:
@@ -114,6 +114,13 @@ def main(argv, linux=None):
114114
cli_args = parser.parse_args(argv)
115115

116116
if cli_args.subcommand == 'run':
117+
if cli_args.build_dir:
118+
if not os.path.exists(cli_args.build_dir):
119+
os.mkdir(cli_args.build_dir)
120+
kunit_kernel.kunitconfig_path = os.path.join(
121+
cli_args.build_dir,
122+
kunit_kernel.kunitconfig_path)
123+
117124
if cli_args.defconfig:
118125
create_default_kunitconfig()
119126

tools/testing/kunit/kunit_kernel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import kunit_config
1515

1616
KCONFIG_PATH = '.config'
17-
KUNITCONFIG_PATH = 'kunitconfig'
17+
kunitconfig_path = 'kunitconfig'
1818

1919
class ConfigError(Exception):
2020
"""Represents an error trying to configure the Linux kernel."""
@@ -82,7 +82,7 @@ class LinuxSourceTree(object):
8282

8383
def __init__(self):
8484
self._kconfig = kunit_config.Kconfig()
85-
self._kconfig.read_from_file(KUNITCONFIG_PATH)
85+
self._kconfig.read_from_file(kunitconfig_path)
8686
self._ops = LinuxSourceTreeOperations()
8787

8888
def clean(self):

0 commit comments

Comments
 (0)