Skip to contentSkip to conversation

Documentation: kunit: add tips for running KUnit

PATCH Superseded Daniel Latypov 2 participants 3 messages Apr 14, 2021

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Documentation: kunit: add tips for running KUnit

This is long overdue.

There are several things that aren't nailed down (in-tree .kunitconfig's), or partially broken (GCOV on UML), but having them documented, warts and all, is better than having nothing.

This covers a bunch of the more recent features
* kunit_filter_glob
* kunit.py run --kunitconfig
* slightly more detail on building tests as modules
* CONFIG_KUNIT_DEBUGFS

By my count, the only headline features now not mentioned are the KASAN integration and KernelCI json output support (kunit.py run --json).

And then it also discusses how to get code coverage reports under UML and non-UML since this is a question people have repeatedly asked.

Non-UML coverage collection is no different from normal, but we should probably explicitly call this out.

As for UML, I was able to get it working again with two small hacks.* E.g. with CONFIG_KUNIT=y && CONFIG_KUNIT_ALL_TESTS=y
Overall coverage rate:

    lines......: 15.1% (18294 of 120776 lines)
    functions..: 16.8% (1860 of 11050 functions)

Note: this doesn't document --alltests since this is not stable yet. Hopefully being run more frequently as part of KernelCI will help...

*Using gcc/gcov-6 and not using uml_abort() in os_dump_core(). I've documented these hacks in "Notes" but left TODOs for [email protected] who tracked down the runtime issue in GCC. To be clear: these are not issues specific to KUnit, but rather to UML.

---
v2 -> v3:
* Suggest --make_options=CC=/usr/bin/gcc-6 instead of manually editing kunit_kernel.py
* update instructions on how to remove uml_abort() call

v1 -> v2:
Fix typos, drop --alltests, changed wordiing on config fragments.

---
 Documentation/dev-tools/kunit/index.rst       |   1 +
 .../dev-tools/kunit/running_tips.rst          | 258 ++++++++++++++++++
 Documentation/dev-tools/kunit/start.rst       |   2 +
 3 files changed, 261 insertions(+)
 create mode 100644 Documentation/dev-tools/kunit/running_tips.rst
Documentation/dev-tools/kunit/index.rst +1 -0
index 848478838347..7f7cf8d2ab20 100644
@@ -14,6 +14,7 @@ KUnit - Unit Testing for the Linux Kernel
 	style
 	faq
 	tips
+	running_tips
 
 What is KUnit?
 ==============
Documentation/dev-tools/kunit/running_tips.rst new file +258 -0

258 lines not on this page · raw message

Documentation/dev-tools/kunit/start.rst +2 -0
index 0e65cabe08eb..aa56d7ca6bfb 100644
@@ -236,5 +236,7 @@ Next Steps
 ==========
 *   Check out the :doc:`tips` page for tips on
     writing idiomatic KUnit tests.
+*   Check out the :doc:`running_tips` page for tips on
+    how to make running KUnit tests easier.
 *   Optional: see the :doc:`usage` page for a more
     in-depth explanation of KUnit.

base-commit: de2fcb3e62013738f22bbb42cbd757d9a242574e

Signature · 1 line
2.31.1.295.g9ea45b61b8-goog
Reviewed-by on v3 1/1
#1 lore raw
Quoted 31 lines · Daniel Latypov

This is long overdue.

There are several things that aren't nailed down (in-tree .kunitconfig's), or partially broken (GCOV on UML), but having them documented, warts and all, is better than having nothing.

This covers a bunch of the more recent features
* kunit_filter_glob
* kunit.py run --kunitconfig
* slightly more detail on building tests as modules
* CONFIG_KUNIT_DEBUGFS

By my count, the only headline features now not mentioned are the KASAN integration and KernelCI json output support (kunit.py run --json).

And then it also discusses how to get code coverage reports under UML and non-UML since this is a question people have repeatedly asked.

Non-UML coverage collection is no different from normal, but we should probably explicitly call this out.

As for UML, I was able to get it working again with two small hacks.* E.g. with CONFIG_KUNIT=y && CONFIG_KUNIT_ALL_TESTS=y
Overall coverage rate:

    lines......: 15.1% (18294 of 120776 lines)
    functions..: 16.8% (1860 of 11050 functions)

Note: this doesn't document --alltests since this is not stable yet. Hopefully being run more frequently as part of KernelCI will help...

Quoted 7 lines

*Using gcc/gcov-6 and not using uml_abort() in os_dump_core(). I've documented these hacks in "Notes" but left TODOs for [email protected] who tracked down the runtime issue in GCC. To be clear: these are not issues specific to KUnit, but rather to UML.

---

I'm very happy with this now: all my issues with the previous versions are addressed. I'm particularly excited to have code coverage documented somewhere.

Assuming Brendan's happy with the TODOs being there, I think this is ready to go.

I also built this with Sphinx and gave it a quick look, and it all looks good there as well.

Therefore, this is:

Cheers,
-- David

#2 lore raw
Quoted 38 lines · David Gow
Quoted 36 lines · Daniel Latypov

This is long overdue.

There are several things that aren't nailed down (in-tree .kunitconfig's), or partially broken (GCOV on UML), but having them documented, warts and all, is better than having nothing.

This covers a bunch of the more recent features
* kunit_filter_glob
* kunit.py run --kunitconfig
* slightly more detail on building tests as modules
* CONFIG_KUNIT_DEBUGFS

By my count, the only headline features now not mentioned are the KASAN integration and KernelCI json output support (kunit.py run --json).

And then it also discusses how to get code coverage reports under UML and non-UML since this is a question people have repeatedly asked.

Non-UML coverage collection is no different from normal, but we should probably explicitly call this out.

As for UML, I was able to get it working again with two small hacks.* E.g. with CONFIG_KUNIT=y && CONFIG_KUNIT_ALL_TESTS=y
Overall coverage rate:

    lines......: 15.1% (18294 of 120776 lines)
    functions..: 16.8% (1860 of 11050 functions)

Note: this doesn't document --alltests since this is not stable yet. Hopefully being run more frequently as part of KernelCI will help...

*Using gcc/gcov-6 and not using uml_abort() in os_dump_core(). I've documented these hacks in "Notes" but left TODOs for [email protected] who tracked down the runtime issue in GCC. To be clear: these are not issues specific to KUnit, but rather to UML.

Quoted 6 lines
Quoted 2 lines

---

I'm very happy with this now: all my issues with the previous versions are addressed. I'm particularly excited to have code coverage documented somewhere.

I just realized I forgot to commit the updated wording you requested wrt uml_abort() in the patch itself.
Sending a v4 now.

Quoted 13 lines

Assuming Brendan's happy with the TODOs being there, I think this is ready to go.

I also built this with Sphinx and gave it a quick look, and it all looks good there as well.

Therefore, this is:

Cheers,
-- David