Skip to contentSkip to conversation

Fix nits in the kunit

PATCH Applied SeongJae Park 3 participants 23 messages Dec 1, 2019 – Dec 3, 2019

Subsystems (4)

v1 of 7 Applied Latest is v7 →

lore
Share & tools
lore
#0 lore raw

cover Fix nits in the kunit

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/6 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
index aeeddfa..78a0aed 100644
@@ -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
Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH 1/6] docs/kunit/start: Use in-tree 'kunit_defconfig'

Quoted 7 lines · SeongJae Park

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.

I agree; this probably makes more sense.

Quoted 1 line

Thanks!

#3 lore raw

PATCH 2/6 docs/kunit/start: Skip wrapper run command

In reply to SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -6
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as
 well as formatting the output.
 
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================
 The Python script is a thin wrapper around Kbuild as such, it needs to be
Signature · 1 line
2.7.4
#4 lore raw

Re: [PATCH 2/6] docs/kunit/start: Skip wrapper run command

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

Quoted 11 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 10 lines
Documentation/dev-tools/kunit/start.rst +0 -6
 well as formatting the output.
 
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

Note: we have tried to address this potential issue for new users in this patch under review:

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

Quoted 4 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

#5 lore raw

Re: [PATCH 2/6] docs/kunit/start: Skip wrapper run command

Quoted 56 lines · Brendan Higgins

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

Quoted 11 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 10 lines
Documentation/dev-tools/kunit/start.rst +0 -6
 well as formatting the output.
 
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

Quoted 7 lines

Note: we have tried to address this potential issue for new users in this patch under review:

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

I totally agree your way :)

Thanks,
SeongJae Park

Quoted 5 lines
Quoted 5 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

#6 lore raw

Re: [PATCH 2/6] docs/kunit/start: Skip wrapper run command

Quoted 62 lines · SeongJae Park
Quoted 59 lines · Brendan Higgins

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

Quoted 11 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 10 lines
Documentation/dev-tools/kunit/start.rst +0 -6
 well as formatting the output.
 
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

Note: we have tried to address this potential issue for new users in this patch under review:

Quoted 6 lines
Quoted 4 lines

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

I totally agree your way :)

For the reason, I removed this patch from the second version patchset[1].

[1] https://lore.kernel.org/linux-doc/[email protected]/

Thanks,
SeongJae Park

Quoted 10 lines

Thanks,
SeongJae Park

Quoted 5 lines
Quoted 5 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

#7 lore raw

Re: [PATCH 2/6] docs/kunit/start: Skip wrapper run command

In reply to Brendan Higgins
Quoted 23 lines · Brendan Higgins

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 6 lines
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

I definitely agree that having a non-working command here is doing more harm than good. Whether we just get rid of it, or change it to use the --defconfig option is a matter of taste. (Personally, I think there's some value in having a one-line "run the tests" command at the top of the Getting Started page, but it definitely needs to be one that works.)

So, overall, I think this is definitely an improvement, but that we do need to choose whether to take this approach (deleting this command) or the --defconfig approach as in:
https://lore.kernel.org/linux-kselftest/[email protected]/

Quoted 13 lines
Quoted 13 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as
 well as formatting the output.
 
Quoted 13 lines

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 8 lines
Documentation/dev-tools/kunit/start.rst +0 -6
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

I generally think we want to keep the "Getting Started" guide focused on the goal (running/writing tests), rather than too much detail on the implementation (the wrapper itself).
How about renaming what's currently the "KUnit Wrapper" section to "Running tests" or similar, and moving the kunitconfig part under that?

The "Creating a kunitconfig" part could equally be "configuring which tests to run" or something, which may speak more to motivating

As for some sort of tie-in, perhaps rewording the opening sentence to say "The easiest way to run tests is to use the kunit_tool script", and link to the page kunit_tool page in the patch below?

Quoted 8 lines

Note: we have tried to address this potential issue for new users in this patch under review:

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

As above, my slight preference is for adding the --defconfig option over removing the section entirely.

Quoted 4 lines
Quoted 4 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

Quoted 68 lines · Brendan Higgins

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

Quoted 11 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 10 lines
Documentation/dev-tools/kunit/start.rst +0 -6
 well as formatting the output.
 
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

Note: we have tried to address this potential issue for new users in this patch under review:

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

Quoted 4 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

#8 lore raw

Re: [PATCH 2/6] docs/kunit/start: Skip wrapper run command

Quoted 87 lines · David Gow
Quoted 23 lines · Brendan Higgins

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 6 lines
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

I definitely agree that having a non-working command here is doing more harm than good. Whether we just get rid of it, or change it to use the --defconfig option is a matter of taste. (Personally, I think there's some value in having a one-line "run the tests" command at the top of the Getting Started page, but it definitely needs to be one that works.)

So, overall, I think this is definitely an improvement, but that we do need to choose whether to take this approach (deleting this command) or the --defconfig approach as in:
https://lore.kernel.org/linux-kselftest/[email protected]/

Quoted 13 lines
Quoted 13 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as
 well as formatting the output.
 
Quoted 13 lines

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 8 lines
Documentation/dev-tools/kunit/start.rst +0 -6
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

I generally think we want to keep the "Getting Started" guide focused on the goal (running/writing tests), rather than too much detail on the implementation (the wrapper itself).
How about renaming what's currently the "KUnit Wrapper" section to "Running tests" or similar, and moving the kunitconfig part under that?

The "Creating a kunitconfig" part could equally be "configuring which tests to run" or something, which may speak more to motivating

As for some sort of tie-in, perhaps rewording the opening sentence to say "The easiest way to run tests is to use the kunit_tool script", and link to the page kunit_tool page in the patch below?

Quoted 4 lines

Note: we have tried to address this potential issue for new users in this patch under review:

Quoted 7 lines
Quoted 4 lines

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

As above, my slight preference is for adding the --defconfig option over removing the section entirely.

Agree, I would also prefer to do explain about '--defconfig' option.

Thanks,
SeongJae Park

Quoted 75 lines
Quoted 5 lines
Quoted 5 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

Quoted 68 lines · Brendan Higgins

+David Gow - David has lots of good opinions on our documentation.

Quoted 19 lines · SeongJae Park

From: SeongJae Park <[email protected]>

The kunit 'Getting Started' document first shows the wrapper running command. However, a new user who simply following the command might encounter a failure like below:

    $ ./tools/testing/kunit/kunit.py run
    Traceback (most recent call last):
      File "./tools/testing/kunit/kunit.py", line 140, in <module>
        main(sys.argv[1:])
      File "./tools/testing/kunit/kunit.py", line 126, in main
        linux = kunit_kernel.LinuxSourceTree()
      File "/home/sjpark/linux/tools/testing/kunit/kunit_kernel.py", line 85, in __init__
        self._kconfig.read_from_file(KUNITCONFIG_PATH)
      File "/home/sjpark/linux/tools/testing/kunit/kunit_config.py", line 65, in read_from_file
        with open(path, 'r') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'kunitconfig'
Quoted 3 lines

Though the reason of the failure ('kunitconfig') is explained in its next section, it would be better to reduce any failure that user might encounter. This commit removes the example command for the reason.

Seems reasonable.

Quoted 11 lines
---
 Documentation/dev-tools/kunit/start.rst | 6 ------
 1 file changed, 6 deletions(-)
Documentation/dev-tools/kunit/start.rst +0 -0
index 78a0aed..e25978d 100644
@@ -15,12 +15,6 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as

Documentation/dev-tools/kunit/start.rst Included with KUnit is a simple Python wrapper that helps format the output to · line 19

Quoted 10 lines
Documentation/dev-tools/kunit/start.rst +0 -6
 well as formatting the output.
 
-The wrapper can be run with:
-
-.. code-block:: bash
-
-   ./tools/testing/kunit/kunit.py run
-
 Creating a kunitconfig
 ======================

I think maybe we should demote this section so that this is a subsection under KUnit Wrapper. Might also want to add a tie-in explaining why we are talking about kunitconfig here? Right now this kind of reads as a non sequitur.

Note: we have tried to address this potential issue for new users in this patch under review:

https://patchwork.kernel.org/patch/11252953/

I don't feel strongly whether we do it your way or my way. What do other people think?

Quoted 4 lines
Documentation/dev-tools/kunit/start.rst +0 -1
 The Python script is a thin wrapper around Kbuild as such, it needs to be
--

2.7.4

#9 lore raw

PATCH 3/6 kunit: Remove duplicated defconfig creation

In reply to SeongJae Park

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

---
 tools/testing/kunit/kunit.py | 3 ---
 1 file changed, 3 deletions(-)
tools/testing/kunit/kunit.py +0 -3
index efe06d6..f8f2695 100755
@@ -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
#11 lore raw

PATCH 4/6 kunit: Create default config in 'build_dir'

In reply to 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.

---
 tools/testing/kunit/kunit.py | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/kunit/kunit.py +5 -0
index f8f2695..1746330 100755
@@ -114,6 +114,11 @@ def main(argv, linux=None):
 	cli_args = parser.parse_args(argv)
 
 	if cli_args.subcommand == 'run':
+		if 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()
 
Signature · 1 line
2.7.4
#12 lore raw

Re: [PATCH 4/6] kunit: Create default config in 'build_dir'

Quoted 17 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.

---
 tools/testing/kunit/kunit.py | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/kunit/kunit.py +0 -0
index f8f2695..1746330 100755

tools/testing/kunit/kunit.py def main(argv, linux=None): · line 118

Quoted 5 lines
tools/testing/kunit/kunit.py +2 -0
@@ -114,6 +114,11 @@ def main(argv, linux=None):
        cli_args = parser.parse_args(argv)
 
        if cli_args.subcommand == 'run':
+               if cli_args.build_dir:
+                       kunit_kernel.KUNITCONFIG_PATH = os.path.join(

If you are going to modify the value of KUNITCONFIG_PATH can you rename the variable to make it lower_snake_case? UPPER_SNAKE_CASE in Python is usually (at least in this directory) used to indicate the variable is a constant.

Quoted 9 lines
tools/testing/kunit/kunit.py +3 -1
+                               cli_args.build_dir,
+                               kunit_kernel.KUNITCONFIG_PATH)
+
                if cli_args.defconfig:
                        create_default_kunitconfig()
 
--

2.7.4

#13 lore raw

Re: [PATCH 4/6] kunit: Create default config in 'build_dir'

Quoted 21 lines · Brendan Higgins
Quoted 19 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.

---
 tools/testing/kunit/kunit.py | 5 +++++
 1 file changed, 5 insertions(+)
tools/testing/kunit/kunit.py +0 -0
index f8f2695..1746330 100755
@@ -114,6 +114,11 @@ def main(argv, linux=None):
        cli_args = parser.parse_args(argv)
 
Quoted 8 lines

tools/testing/kunit/kunit.py def main(argv, linux=None): · line 118

Quoted 3 lines
tools/testing/kunit/kunit.py +2 -0
        if cli_args.subcommand == 'run':
+               if cli_args.build_dir:
+                       kunit_kernel.KUNITCONFIG_PATH = os.path.join(

If you are going to modify the value of KUNITCONFIG_PATH can you rename the variable to make it lower_snake_case? UPPER_SNAKE_CASE in Python is usually (at least in this directory) used to indicate the variable is a constant.

Changed as you suggested in the second version patchset[1].

[1] https://lore.kernel.org/linux-doc/[email protected]/

Thanks,
SeongJae Park

Quoted 10 lines
Quoted 10 lines
tools/testing/kunit/kunit.py +3 -1
+                               cli_args.build_dir,
+                               kunit_kernel.KUNITCONFIG_PATH)
+
                if cli_args.defconfig:
                        create_default_kunitconfig()
 
--

2.7.4

#14 lore raw

PATCH 5/6 kunit: Place 'test.log' under the 'build_dir'

In reply to SeongJae Park

From: 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
index bf38768..b640939 100644
@@ -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
Reviewed-by on v1 5/6
#15 lore raw

Re: [PATCH 5/6] kunit: Place 'test.log' under the 'build_dir'

Quoted 7 lines · SeongJae Park

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

Good idea!

Quoted 2 lines

Thanks!

#16 lore raw

PATCH 6/6 kunit: Rename 'kunitconfig' to '.kunitconfig'

In reply to SeongJae Park

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.

---
 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
index e25978d..f2e585e 100644
@@ -15,18 +15,16 @@ Included with KUnit is a simple Python wrapper that helps format the output to
 easily use and read KUnit output. It handles building and running the kernel, as
 well as formatting the output.
 
-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
 ---------------------
@@ -141,7 +139,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
index 1746330..309d6e3 100755
@@ -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
index b640939..507364d 100644
@@ -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
#17 lore raw
In reply to SeongJae Park
Quoted 13 lines · SeongJae Park

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)

I applied your patchset to torvalds/master, ran the command:

tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit

and got the error:

Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 140, in <module>

    main(sys.argv[1:])

File "tools/testing/kunit/kunit.py", line 123, in main
create_default_kunitconfig()
File "tools/testing/kunit/kunit.py", line 36, in create_default_kunitconfig
kunit_kernel.KUNITCONFIG_PATH)
File "/usr/lib/python3.7/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig'

It seems that it expects the build_dir to already exist; however, I don't think this is clear from the error message. Would you mind addressing that here?

Cheers!

#18 lore raw
Quoted 37 lines · Brendan Higgins
Quoted 13 lines · SeongJae Park

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)

I applied your patchset to torvalds/master, ran the command:

tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit

and got the error:

Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 140, in <module>

    main(sys.argv[1:])

File "tools/testing/kunit/kunit.py", line 123, in main
create_default_kunitconfig()
File "tools/testing/kunit/kunit.py", line 36, in create_default_kunitconfig
kunit_kernel.KUNITCONFIG_PATH)
File "/usr/lib/python3.7/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig'

Quoted 3 lines

It seems that it expects the build_dir to already exist; however, I don't think this is clear from the error message. Would you mind addressing that here?

Thank you for sharing this. I will take a look!

Thanks,
SeongJae Park

Quoted 2 lines

Cheers!

#19 lore raw

You're right, the error was due to the assumption of the existence of the build_dir. The "kunit: Create default config in '--build_dir'" patch made the bug. I fixed it in the second version patchset[1].

[1] https://lore.kernel.org/linux-doc/[email protected]/

Thanks,
SeongJae Park

Quoted 51 lines · SeongJae Park
Quoted 37 lines · Brendan Higgins
Quoted 13 lines · SeongJae Park

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)

I applied your patchset to torvalds/master, ran the command:

tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit

and got the error:

Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 140, in <module>

    main(sys.argv[1:])

File "tools/testing/kunit/kunit.py", line 123, in main
create_default_kunitconfig()
File "tools/testing/kunit/kunit.py", line 36, in create_default_kunitconfig
kunit_kernel.KUNITCONFIG_PATH)
File "/usr/lib/python3.7/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig'

Quoted 3 lines

It seems that it expects the build_dir to already exist; however, I don't think this is clear from the error message. Would you mind addressing that here?

Thank you for sharing this. I will take a look!

Thanks,
SeongJae Park

Quoted 2 lines

Cheers!

#20 lore raw
Quoted 6 lines · SeongJae Park

You're right, the error was due to the assumption of the existence of the build_dir. The "kunit: Create default config in '--build_dir'" patch made the bug. I fixed it in the second version patchset[1].

[1] https://lore.kernel.org/linux-doc/[email protected]/

After trying your new patches, I am still getting the "FileNotFoundError" when the given build_dir has not been created.

Quoted 55 lines

Thanks,
SeongJae Park

Quoted 51 lines · SeongJae Park
Quoted 37 lines · Brendan Higgins
Quoted 13 lines · SeongJae Park

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)

I applied your patchset to torvalds/master, ran the command:

tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit

and got the error:

Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 140, in <module>

    main(sys.argv[1:])

File "tools/testing/kunit/kunit.py", line 123, in main
create_default_kunitconfig()
File "tools/testing/kunit/kunit.py", line 36, in create_default_kunitconfig
kunit_kernel.KUNITCONFIG_PATH)
File "/usr/lib/python3.7/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig'

Quoted 3 lines

It seems that it expects the build_dir to already exist; however, I don't think this is clear from the error message. Would you mind addressing that here?

Thank you for sharing this. I will take a look!

Thanks,
SeongJae Park

Quoted 2 lines

Cheers!

#21 lore raw
Quoted 11 lines · Brendan Higgins
Quoted 6 lines · SeongJae Park

You're right, the error was due to the assumption of the existence of the build_dir. The "kunit: Create default config in '--build_dir'" patch made the bug. I fixed it in the second version patchset[1].

[1] https://lore.kernel.org/linux-doc/[email protected]/

After trying your new patches, I am still getting the "FileNotFoundError" when the given build_dir has not been created.

Sorry, apparently my mistake... Sent v3 fixing it:
https://lore.kernel.org/linux-kselftest/[email protected]/T/#t

Thanks,
SeongJae Park

Quoted 56 lines
Quoted 56 lines

Thanks,
SeongJae Park

Quoted 51 lines · SeongJae Park
Quoted 37 lines · Brendan Higgins
Quoted 13 lines · SeongJae Park

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)

I applied your patchset to torvalds/master, ran the command:

tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit

and got the error:

Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 140, in <module>

    main(sys.argv[1:])

File "tools/testing/kunit/kunit.py", line 123, in main
create_default_kunitconfig()
File "tools/testing/kunit/kunit.py", line 36, in create_default_kunitconfig
kunit_kernel.KUNITCONFIG_PATH)
File "/usr/lib/python3.7/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig'

Quoted 3 lines

It seems that it expects the build_dir to already exist; however, I don't think this is clear from the error message. Would you mind addressing that here?

Thank you for sharing this. I will take a look!

Thanks,
SeongJae Park

Quoted 2 lines

Cheers!

#22 lore raw
Quoted 10 lines · SeongJae Park
Quoted 7 lines · Brendan Higgins
Quoted 5 lines · SeongJae Park

You're right, the error was due to the assumption of the existence of the build_dir. The "kunit: Create default config in '--build_dir'" patch made the bug. I fixed it in the second version patchset[1].

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

[1] https://lore.kernel.org/linux-doc/[email protected]/

After trying your new patches, I am still getting the "FileNotFoundError" when the given build_dir has not been created.

Sorry, apparently my mistake... Sent v3 fixing it:
https://lore.kernel.org/linux-kselftest/[email protected]/T/#t

Awesome, looks like that works now!

Thanks for taking care of this!

Quoted 60 lines

Thanks,
SeongJae Park

Quoted 56 lines
Quoted 56 lines

Thanks,
SeongJae Park

Quoted 51 lines · SeongJae Park
Quoted 37 lines · Brendan Higgins
Quoted 13 lines · SeongJae Park

From: SeongJae Park <[email protected]>

This patchset contains trivial fixes for the kunit documentations and the wrapper python scripts.

SeongJae Park (6):
docs/kunit/start: Use in-tree 'kunit_defconfig'
docs/kunit/start: Skip wrapper run command
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 | 19 +++++--------------
 tools/testing/kunit/kunit.py            | 10 ++++++----
 tools/testing/kunit/kunit_kernel.py     |  6 +++---
 3 files changed, 14 insertions(+), 21 deletions(-)

I applied your patchset to torvalds/master, ran the command:

tools/testing/kunit/kunit.py run --timeout=60 --jobs=8 --defconfig --build_dir=.kunit

and got the error:

Traceback (most recent call last):
File "tools/testing/kunit/kunit.py", line 140, in <module>

    main(sys.argv[1:])

File "tools/testing/kunit/kunit.py", line 123, in main
create_default_kunitconfig()
File "tools/testing/kunit/kunit.py", line 36, in create_default_kunitconfig
kunit_kernel.KUNITCONFIG_PATH)
File "/usr/lib/python3.7/shutil.py", line 121, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '.kunit/.kunitconfig'

Quoted 3 lines

It seems that it expects the build_dir to already exist; however, I don't think this is clear from the error message. Would you mind addressing that here?

Thank you for sharing this. I will take a look!

Thanks,
SeongJae Park

Quoted 2 lines

Cheers!