Skip to contentSkip to conversation

Documentation: kunit: add tips.rst for small examples

PATCH In review Daniel Latypov 2 participants 2 messages Jan 26, 2021 – Feb 6, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Documentation: kunit: add tips.rst for small examples

./usage.rst contains fairly long examples and explanations of things like how to fake a class and how to use parameterized tests (and how you could do table-driven tests yourself).

It's not exactly necessary information, so we add a new page with more digestible tips like "use kunit_kzalloc() instead of kzalloc() so you don't have to worry about calling kfree() yourself" and the like.

Change start.rst to point users to this new page first and let them know that usage.rst is more of optional further reading.

---
 Documentation/dev-tools/kunit/index.rst |   2 +
 Documentation/dev-tools/kunit/start.rst |   4 +-
 Documentation/dev-tools/kunit/tips.rst  | 115 ++++++++++++++++++++++++
 3 files changed, 120 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/dev-tools/kunit/tips.rst
Documentation/dev-tools/kunit/index.rst +2 -0
index c234a3ab3c34..848478838347 100644
@@ -13,6 +13,7 @@ KUnit - Unit Testing for the Linux Kernel
 	api/index
 	style
 	faq
+	tips
 
 What is KUnit?
 ==============
@@ -88,6 +89,7 @@ How do I use it?
 ================
 
 *   :doc:`start` - for new users of KUnit
+*   :doc:`tips` - for short examples of best practices
 *   :doc:`usage` - for a more detailed explanation of KUnit features
 *   :doc:`api/index` - for the list of KUnit APIs used for testing
 *   :doc:`kunit-tool` - for more information on the kunit_tool helper script
Documentation/dev-tools/kunit/start.rst +3 -1
index 454f307813ea..c09e2747c958 100644
@@ -233,5 +233,7 @@ Congrats! You just wrote your first KUnit test!
 
 Next Steps
 ==========
-*   Check out the :doc:`usage` page for a more
+*   Check out the :doc:`tips` page for tips on
+    writing idiomatic KUnit tests.
+*   Optional: see the :doc:`usage` page for a more
     in-depth explanation of KUnit.
Documentation/dev-tools/kunit/tips.rst new file +115 -0

115 lines not on this page · raw message

base-commit: 6ee1d745b7c9fd573fba142a2efdad76a9f1cb04

Signature · 1 line
2.30.0.280.ga3ce27912f-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Daniel Latypov

./usage.rst contains fairly long examples and explanations of things like how to fake a class and how to use parameterized tests (and how you could do table-driven tests yourself).

Quoted 8 lines

It's not exactly necessary information, so we add a new page with more digestible tips like "use kunit_kzalloc() instead of kzalloc() so you don't have to worry about calling kfree() yourself" and the like.

Change start.rst to point users to this new page first and let them know that usage.rst is more of optional further reading.