diff options
| author | Ryota Sakamoto <sakamo.ryota@gmail.com> | 2026-01-06 01:41:01 +0900 |
|---|---|---|
| committer | Shuah Khan <skhan@linuxfoundation.org> | 2026-01-05 15:35:22 -0700 |
| commit | 5c7a4741431b0a938dcbd22b90a4dc9a2903fc00 (patch) | |
| tree | e51b3b47a7a2ec45d82811654e49bf658ec6d79f /tools/testing/kunit/kunit.py | |
| parent | a7a81655dc90688f9ddff1c0b185d7a6fa8bfc7d (diff) | |
| download | linux-next-5c7a4741431b0a938dcbd22b90a4dc9a2903fc00.tar.gz linux-next-5c7a4741431b0a938dcbd22b90a4dc9a2903fc00.zip | |
kunit: respect KBUILD_OUTPUT env variable by default
Currently, kunit.py ignores the KBUILD_OUTPUT env variable and always
defaults to .kunit in the working directory. This behavior is inconsistent
with standard Kbuild behavior, where KBUILD_OUTPUT defines the build
artifact location.
This patch modifies kunit.py to respect KBUILD_OUTPUT if set. A .kunit
subdirectory is created inside KBUILD_OUTPUT to avoid polluting the build
directory.
Link: https://lore.kernel.org/r/20260106-kunit-kbuild_output-v2-1-582281797343@gmail.com
Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Ryota Sakamoto <sakamo.ryota@gmail.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'tools/testing/kunit/kunit.py')
| -rwxr-xr-x | tools/testing/kunit/kunit.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py index cd99c1956331..e3d82a038f93 100755 --- a/tools/testing/kunit/kunit.py +++ b/tools/testing/kunit/kunit.py @@ -323,11 +323,16 @@ def get_default_jobs() -> int: return ncpu raise RuntimeError("os.cpu_count() returned None") +def get_default_build_dir() -> str: + if 'KBUILD_OUTPUT' in os.environ: + return os.path.join(os.environ['KBUILD_OUTPUT'], '.kunit') + return '.kunit' + def add_common_opts(parser: argparse.ArgumentParser) -> None: parser.add_argument('--build_dir', help='As in the make command, it specifies the build ' 'directory.', - type=str, default='.kunit', metavar='DIR') + type=str, default=get_default_build_dir(), metavar='DIR') parser.add_argument('--make_options', help='X=Y make option, can be repeated.', action='append', metavar='X=Y') |
