Fix nits in the kunit
Subsystems (4)
v3 cover Fix nits in the kunit
This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.
Changes from v2 (https://lore.kernel.org/linux-kselftest/[email protected]/T/#t):
- Make 'build_dir' if not exists (missed from v3 by mistake)
SeongJae Park (5):
docs/kunit/start: Use in-tree 'kunit_defconfig'
kunit: Remove duplicated defconfig creation
kunit: Create default config in '--build_dir'
kunit: Place 'test.log' under the 'build_dir'
kunit: Rename 'kunitconfig' to '.kunitconfig'
Documentation/dev-tools/kunit/start.rst | 13 +++++-------- tools/testing/kunit/kunit.py | 16 ++++++++++------ tools/testing/kunit/kunit_kernel.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/5 docs/kunit/start: Use in-tree 'kunit_defconfig'
From: SeongJae Park <[email protected]>
The kunit doc suggests users to get the default kunitconfig from an external git tree. However, the file is already located under the arch/um/configs/ of the kernel tree. Because the local file is easier to access and maintain, this commit updates the doc to use it.
--- Documentation/dev-tools/kunit/start.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Documentation/dev-tools/kunit/start.rst +1 -2
@@ -29,9 +29,8 @@ regular Kernel config, with the specific test targets as well. .. code-block:: bash - git clone -b master https://kunit.googlesource.com/kunitconfig $PATH_TO_KUNITCONFIG_REPO cd $PATH_TO_LINUX_REPO - ln -s $PATH_TO_KUNIT_CONFIG_REPO/kunitconfig kunitconfig + cp arch/um/configs/kunit_defconfig kunitconfig You may want to add kunitconfig to your local gitignore.
Signature · 1 line
2.7.4
PATCH v3 2/5 kunit: Remove duplicated defconfig creation
In reply to SeongJae ParkFrom: SeongJae Park <[email protected]>
'--defconfig' option is handled by the 'main() of the 'kunit.py' but again handled in following 'run_tests()'. This commit removes this duplicated handling of the option in the 'run_tests()'.
--- tools/testing/kunit/kunit.py | 3 --- 1 file changed, 3 deletions(-)
tools/testing/kunit/kunit.py +0 -3
@@ -37,9 +37,6 @@ def create_default_kunitconfig(): def run_tests(linux: kunit_kernel.LinuxSourceTree, request: KunitRequest) -> KunitResult: - if request.defconfig: - create_default_kunitconfig() - config_start = time.time() success = linux.build_reconfig(request.build_dir) config_end = time.time()
Signature · 1 line
2.7.4
PATCH v3 3/5 kunit: Create default config in '--build_dir'
In reply to SeongJae ParkFrom: SeongJae Park <[email protected]>
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.
--- tools/testing/kunit/kunit.py | 11 +++++++++-- tools/testing/kunit/kunit_kernel.py | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-)
tools/testing/kunit/kunit.py +9 -2
@@ -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()
tools/testing/kunit/kunit_kernel.py +2 -2
@@ -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):
Signature · 1 line
2.7.4
Re: [PATCH v3 3/5] kunit: Create default config in '--build_dir'
Quoted 10 lines · SeongJae Park
From: SeongJae Park <[email protected]>
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.
Signed-off-by SeongJae Park <[email protected]>Suggested-by Brendan Higgins <[email protected]>Reported-by Brendan Higgins <[email protected]>
PATCH v3 4/5 kunit: Place 'test.log' under the 'build_dir'
In reply to SeongJae ParkFrom: SeongJae Park <[email protected]>
'kunit' writes the 'test.log' under the kernel source directory even though a 'build_dir' option is given. As users who use the option might expect the outputs to be placed under the specified directory, this commit modifies the logic to write the log file under the 'build_dir'.
--- tools/testing/kunit/kunit_kernel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/kunit/kunit_kernel.py +1 -1
@@ -143,7 +143,7 @@ class LinuxSourceTree(object): def run_kernel(self, args=[], timeout=None, build_dir=None): args.extend(['mem=256M']) process = self._ops.linux_bin(args, timeout, build_dir) - with open('test.log', 'w') as f: + with open(os.path.join(build_dir, 'test.log'), 'w') as f: for line in process.stdout: f.write(line.rstrip().decode('ascii') + '\n') yield line.rstrip().decode('ascii')
Signature · 1 line
2.7.4
PATCH v3 5/5 kunit: Rename 'kunitconfig' to '.kunitconfig'
In reply to SeongJae ParkFrom: SeongJae Park <[email protected]>
This commit renames 'kunitconfig' to '.kunitconfig' so that it can be automatically ignored by git and do not disturb people who want to type 'kernel/' by pressing only the 'k' and then 'tab' key.
--- Documentation/dev-tools/kunit/start.rst | 12 +++++------- tools/testing/kunit/kunit.py | 2 +- tools/testing/kunit/kunit_kernel.py | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-)
Documentation/dev-tools/kunit/start.rst +5 -7
@@ -21,18 +21,16 @@ The wrapper can be run with: ./tools/testing/kunit/kunit.py run -Creating a kunitconfig -====================== +Creating a .kunitconfig +======================= The Python script is a thin wrapper around Kbuild as such, it needs to be -configured with a ``kunitconfig`` file. This file essentially contains the +configured with a ``.kunitconfig`` file. This file essentially contains the regular Kernel config, with the specific test targets as well. .. code-block:: bash cd $PATH_TO_LINUX_REPO - cp arch/um/configs/kunit_defconfig kunitconfig - -You may want to add kunitconfig to your local gitignore. + cp arch/um/configs/kunit_defconfig .kunitconfig Verifying KUnit Works ---------------------
@@ -147,7 +145,7 @@ and the following to ``drivers/misc/Makefile``: obj-$(CONFIG_MISC_EXAMPLE_TEST) += example-test.o -Now add it to your ``kunitconfig``: +Now add it to your ``.kunitconfig``: .. code-block:: none
tools/testing/kunit/kunit.py +1 -1
@@ -108,7 +108,7 @@ def main(argv, linux=None): type=str, default=None, metavar='build_dir') run_parser.add_argument('--defconfig', - help='Uses a default kunitconfig.', + help='Uses a default .kunitconfig.', action='store_true') cli_args = parser.parse_args(argv)
tools/testing/kunit/kunit_kernel.py +2 -2
@@ -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."""
@@ -111,7 +111,7 @@ class LinuxSourceTree(object): return True def build_reconfig(self, build_dir): - """Creates a new .config if it is not a subset of the kunitconfig.""" + """Creates a new .config if it is not a subset of the .kunitconfig.""" kconfig_path = get_kconfig_path(build_dir) if os.path.exists(kconfig_path): existing_kconfig = kunit_config.Kconfig()
Signature · 1 line
2.7.4
Quoted 14 lines · SeongJae Park
This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.
Changes from v2 (https://lore.kernel.org/linux-kselftest/[email protected]/T/#t):
- Make 'build_dir' if not exists (missed from v3 by mistake)SeongJae Park (5):
docs/kunit/start: Use in-tree 'kunit_defconfig'
kunit: Remove duplicated defconfig creation
kunit: Create default config in '--build_dir'
kunit: Place 'test.log' under the 'build_dir'
kunit: Rename 'kunitconfig' to '.kunitconfig'
Quoted 4 lines
Documentation/dev-tools/kunit/start.rst | 13 +++++-------- tools/testing/kunit/kunit.py | 16 ++++++++++------ tools/testing/kunit/kunit_kernel.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-)
Thanks!
Quoted 15 lines · Brendan Higgins
Quoted 14 lines · SeongJae Park
This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.
Changes from v2 (https://lore.kernel.org/linux-kselftest/[email protected]/T/#t):
- Make 'build_dir' if not exists (missed from v3 by mistake)SeongJae Park (5):
docs/kunit/start: Use in-tree 'kunit_defconfig'
kunit: Remove duplicated defconfig creation
kunit: Create default config in '--build_dir'
kunit: Place 'test.log' under the 'build_dir'
kunit: Rename 'kunitconfig' to '.kunitconfig'
Quoted 6 lines
Quoted 4 lines
Documentation/dev-tools/kunit/start.rst | 13 +++++-------- tools/testing/kunit/kunit.py | 16 ++++++++++------ tools/testing/kunit/kunit_kernel.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-)Tested-by Brendan Higgins <[email protected]>
I just realized that I forgot to test for something...
The following command fails:
./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12 --defconfig
[11:17:13] Building KUnit Kernel ...
[11:17:16] Starting KUnit Kernel ...
Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 142, in <module>
main(sys.argv[1:])
File "tools/testing/kunit/kunit.py", line 135, in main
result = run_tests(linux, request)
File "tools/testing/kunit/kunit.py", line 67, in run_tests
test_result = kunit_parser.parse_run_tests(kunit_output)
File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 283, in parse_run_tests test_result = parse_test_result(list(isolate_kunit_output(kernel_output)))
File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 54, in isolate_kunit_output for line in kernel_output:
File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_kernel.py", line 146, in run_kernel with open(os.path.join(build_dir, 'test.log'), 'w') as f:
File "/usr/lib/python3.7/posixpath.py", line 80, in join
a = os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneType
It seems as though you assume that build_dir is always populated by the flag.
Quoted 45 lines · Brendan Higgins
Quoted 15 lines · Brendan Higgins
Quoted 14 lines · SeongJae Park
This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.
Changes from v2 (https://lore.kernel.org/linux-kselftest/[email protected]/T/#t):
- Make 'build_dir' if not exists (missed from v3 by mistake)SeongJae Park (5):
docs/kunit/start: Use in-tree 'kunit_defconfig'
kunit: Remove duplicated defconfig creation
kunit: Create default config in '--build_dir'
kunit: Place 'test.log' under the 'build_dir'
kunit: Rename 'kunitconfig' to '.kunitconfig'Quoted 6 lines
Quoted 4 lines
Documentation/dev-tools/kunit/start.rst | 13 +++++-------- tools/testing/kunit/kunit.py | 16 ++++++++++------ tools/testing/kunit/kunit_kernel.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-)Tested-by Brendan Higgins <[email protected]>I just realized that I forgot to test for something...
The following command fails:
./tools/testing/kunit/kunit.pyrun --timeout=60 --jobs=12 --defconfig[11:17:13] Building KUnit Kernel ...
[11:17:16] Starting KUnit Kernel ...
Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 142, in <module>main(sys.argv[1:]) File "tools/testing/kunit/kunit.py", line 135, in main result = run_tests(linux, request) File "tools/testing/kunit/kunit.py", line 67, in run_tests test_result = kunit_parser.parse_run_tests(kunit_output) File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 283, in parse_run_tests test_result = parse_test_result(list(isolate_kunit_output(kernel_output))) File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 54, in isolate_kunit_output for line in kernel_output: File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_kernel.py", line 146, in run_kernel with open(os.path.join(build_dir, 'test.log'), 'w') as f:
Quoted 5 lines
File "
/usr/lib/python3.7/posixpath.py", line 80, in join
a =os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneTypeIt seems as though you assume that
build_diris always populated by the flag.
Sorry for not checking the case. The 4th patch, "kunit: Place 'test.log' under the 'build_dir'" made the bug. I fixed the 4th patch and tested with below commands:
./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12
--defconfig --build_dir .kunit
./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12 --defconfigJust sent the 4th version patchset including the fix:
http://lkml.kernel.org/r/[email protected]
I will consider adding some tests that can check such cases in the 'kunit_tools_test.py' later.
Thanks,
SeongJae Park
Quoted 58 lines · SeongJae Park
Quoted 45 lines · Brendan Higgins
Quoted 15 lines · Brendan Higgins
Quoted 14 lines · SeongJae Park
This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.
Changes from v2 (https://lore.kernel.org/linux-kselftest/[email protected]/T/#t):
- Make 'build_dir' if not exists (missed from v3 by mistake)SeongJae Park (5):
docs/kunit/start: Use in-tree 'kunit_defconfig'
kunit: Remove duplicated defconfig creation
kunit: Create default config in '--build_dir'
kunit: Place 'test.log' under the 'build_dir'
kunit: Rename 'kunitconfig' to '.kunitconfig'Quoted 6 lines
Quoted 4 lines
Documentation/dev-tools/kunit/start.rst | 13 +++++-------- tools/testing/kunit/kunit.py | 16 ++++++++++------ tools/testing/kunit/kunit_kernel.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-)Tested-by Brendan Higgins <[email protected]>I just realized that I forgot to test for something...
The following command fails:
./tools/testing/kunit/kunit.pyrun --timeout=60 --jobs=12 --defconfig[11:17:13] Building KUnit Kernel ...
[11:17:16] Starting KUnit Kernel ...
Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 142, in <module>main(sys.argv[1:]) File "tools/testing/kunit/kunit.py", line 135, in main result = run_tests(linux, request) File "tools/testing/kunit/kunit.py", line 67, in run_tests test_result = kunit_parser.parse_run_tests(kunit_output) File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 283, in parse_run_tests test_result = parse_test_result(list(isolate_kunit_output(kernel_output))) File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 54, in isolate_kunit_output for line in kernel_output: File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_kernel.py", line 146, in run_kernel with open(os.path.join(build_dir, 'test.log'), 'w') as f:Quoted 5 lines
File "
/usr/lib/python3.7/posixpath.py", line 80, in join
a =os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneTypeIt seems as though you assume that
build_diris always populated by the flag.Sorry for not checking the case. The 4th patch, "kunit: Place 'test.log' under the '
build_dir'" made the bug. I fixed the 4th patch and tested with below commands:
Quoted 6 lines
./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12 --defconfig --build_dir .kunit ./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12 --defconfigJust sent the 4th version patchset including the fix:
http://lkml.kernel.org/r/[email protected]
Also, removed the 'Reviewed-by' from the 4th patch and didn't add 'Tested-by' to the patchset.
Thanks,
SeongJae Park
Quoted 7 lines
I will consider adding some tests that can check such cases in the '
kunit_tools_test.py' later.Thanks,
SeongJae Park
Quoted 57 lines · SeongJae Park
Quoted 56 lines · SeongJae Park
Quoted 41 lines · Brendan Higgins
Quoted 14 lines · Brendan Higgins
Quoted 13 lines · SeongJae Park
This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.
Changes from v2 (https://lore.kernel.org/linux-kselftest/[email protected]/T/#t):
- Make 'build_dir' if not exists (missed from v3 by mistake)SeongJae Park (5):
docs/kunit/start: Use in-tree 'kunit_defconfig'
kunit: Remove duplicated defconfig creation
kunit: Create default config in '--build_dir'
kunit: Place 'test.log' under the 'build_dir'
kunit: Rename 'kunitconfig' to '.kunitconfig'Quoted 5 lines
Quoted 4 lines
Documentation/dev-tools/kunit/start.rst | 13 +++++-------- tools/testing/kunit/kunit.py | 16 ++++++++++------ tools/testing/kunit/kunit_kernel.py | 8 ++++---- 3 files changed, 19 insertions(+), 18 deletions(-)Tested-by Brendan Higgins <[email protected]>I just realized that I forgot to test for something...
The following command fails:
./tools/testing/kunit/kunit.pyrun --timeout=60 --jobs=12 --defconfig[11:17:13] Building KUnit Kernel ...
[11:17:16] Starting KUnit Kernel ...
Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 142, in <module>main(sys.argv[1:]) File "tools/testing/kunit/kunit.py", line 135, in main result = run_tests(linux, request) File "tools/testing/kunit/kunit.py", line 67, in run_tests test_result = kunit_parser.parse_run_tests(kunit_output) File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 283, in parse_run_tests test_result = parse_test_result(list(isolate_kunit_output(kernel_output))) File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_parser.py", line 54, in isolate_kunit_output for line in kernel_output: File "/usr/local/google/home/brendanhiggins/gbmc-linux/tools/testing/kunit/kunit_kernel.py", line 146, in run_kernel with open(os.path.join(build_dir, 'test.log'), 'w') as f:Quoted 5 lines
File "
/usr/lib/python3.7/posixpath.py", line 80, in join
a =os.fspath(a)
TypeError: expected str, bytes or os.PathLike object, not NoneTypeIt seems as though you assume that
build_diris always populated by the flag.Sorry for not checking the case. The 4th patch, "kunit: Place 'test.log' under the '
build_dir'" made the bug. I fixed the 4th patch and tested with below commands:./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12 --defconfig --build_dir .kunit ./tools/testing/kunit/kunit.py run --timeout=60 --jobs=12 --defconfig
Quoted 11 lines
Quoted 2 lines
Just sent the 4th version patchset including the fix:
http://lkml.kernel.org/r/[email protected]Also, removed the 'Reviewed-by' from the 4th patch and didn't add 'Tested-by' to the patchset.
Thanks,
SeongJae ParkQuoted 2 lines
I will consider adding some tests that can check such cases in the '
kunit_tools_test.py' later.
I just sent 5th version which includes this change and a fix:
https://lore.kernel.org/linux-kselftest/[email protected]
Thanks,
SeongJae Park
Quoted 4 lines
Quoted 4 lines
Thanks,
SeongJae Park