2019-12-03 18:28:56

by SeongJae Park

[permalink] [raw]
Subject: [PATCH v3 0/5] 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(-)

--
2.7.4


2019-12-03 18:29:36

by SeongJae Park

[permalink] [raw]
Subject: [PATCH v3 2/5] kunit: Remove duplicated defconfig creation

From: 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()'.

Signed-off-by: SeongJae Park <[email protected]>
Reviewed-by: Brendan Higgins <[email protected]>
---
tools/testing/kunit/kunit.py | 3 ---
1 file changed, 3 deletions(-)

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index efe06d6..f8f2695 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -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()
--
2.7.4

2019-12-03 18:29:36

by SeongJae Park

[permalink] [raw]
Subject: [PATCH v3 5/5] kunit: Rename 'kunitconfig' to '.kunitconfig'

From: 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.

Signed-off-by: SeongJae Park <[email protected]>
Reviewed-by: Brendan Higgins <[email protected]>
---
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(-)

diff --git a/Documentation/dev-tools/kunit/start.rst b/Documentation/dev-tools/kunit/start.rst
index 78a0aed..faa6fa9 100644
--- a/Documentation/dev-tools/kunit/start.rst
+++ b/Documentation/dev-tools/kunit/start.rst
@@ -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

diff --git a/tools/testing/kunit/kunit.py b/tools/testing/kunit/kunit.py
index 5b22241..257722f 100755
--- a/tools/testing/kunit/kunit.py
+++ b/tools/testing/kunit/kunit.py
@@ -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)
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 5bec97e..fca1933 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -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()
--
2.7.4

2019-12-03 23:12:09

by Brendan Higgins

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] Fix nits in the kunit

On Tue, Dec 3, 2019 at 10:08 AM SeongJae Park <[email protected]> wrote:
>
> 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(-)

Tested-by: Brendan Higgins <[email protected]>

Thanks!

2019-12-04 19:50:28

by Brendan Higgins

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] Fix nits in the kunit

On Tue, Dec 03, 2019 at 02:41:26PM -0800, Brendan Higgins wrote:
> On Tue, Dec 3, 2019 at 10:08 AM SeongJae Park <[email protected]> wrote:
> >
> > 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(-)
>
> 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.

2019-12-04 20:26:34

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] Fix nits in the kunit

On Wed, Dec 4, 2019 at 8:21 PM Brendan Higgins
<[email protected]> wrote:
>
> On Tue, Dec 03, 2019 at 02:41:26PM -0800, Brendan Higgins wrote:
> > On Tue, Dec 3, 2019 at 10:08 AM SeongJae Park <[email protected]> wrote:
> > >
> > > 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(-)
> >
> > 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.

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

Just 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

2019-12-04 20:30:18

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] Fix nits in the kunit

On Wed, Dec 4, 2019 at 9:25 PM SeongJae Park <[email protected]> wrote:
>
> On Wed, Dec 4, 2019 at 8:21 PM Brendan Higgins
> <[email protected]> wrote:
> >
> > On Tue, Dec 03, 2019 at 02:41:26PM -0800, Brendan Higgins wrote:
> > > On Tue, Dec 3, 2019 at 10:08 AM SeongJae Park <[email protected]> wrote:
> > > >
> > > > 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(-)
> > >
> > > 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.
>
> 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
>
> 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 Park

>
> I will consider adding some tests that can check such cases in the
> 'kunit_tools_test.py' later.
>
>
> Thanks,
> SeongJae Park

2019-12-05 09:45:54

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH v3 0/5] Fix nits in the kunit

On 04.12.19 21:28, SeongJae Park wrote:
> On Wed, Dec 4, 2019 at 9:25 PM SeongJae Park <[email protected]> wrote:
>> On Wed, Dec 4, 2019 at 8:21 PM Brendan Higgins
>> <[email protected]> wrote:
>>> On Tue, Dec 03, 2019 at 02:41:26PM -0800, Brendan Higgins wrote:
>>>> On Tue, Dec 3, 2019 at 10:08 AM SeongJae Park <[email protected]> wrote:
>>>>> 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(-)
>>>> 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.
>> 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
>>
>> 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 Park
>
>> 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

>>
>>
>> Thanks,
>> SeongJae Park