All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bagas Sanjaya <bagasdotme@gmail.com>
To: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com
Cc: Jonathan Corbet <corbet@lwn.net>,
	Brendan Higgins <brendan.higgins@linux.dev>,
	David Gow <davidgow@google.com>,
	Lukas Bulwahn <lukas.bulwahn@gmail.com>,
	Khalid Masum <khalid.masum.92@gmail.com>,
	Sadiya Kazi <sadiyakazi@google.com>,
	Bagas Sanjaya <bagasdotme@gmail.com>
Subject: [PATCH 4/7] Documentation: kunit: move introduction to its own document
Date: Sun, 23 Oct 2022 19:54:11 +0700	[thread overview]
Message-ID: <20221023125414.60961-5-bagasdotme@gmail.com> (raw)
In-Reply-To: <20221023125414.60961-1-bagasdotme@gmail.com>

Move KUnit introduction from table of contents index to its own page.

While at it, rewrite the intro.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
---
 Documentation/dev-tools/kunit/index.rst | 93 +------------------------
 Documentation/dev-tools/kunit/intro.rst | 61 ++++++++++++++++
 2 files changed, 62 insertions(+), 92 deletions(-)
 create mode 100644 Documentation/dev-tools/kunit/intro.rst

diff --git a/Documentation/dev-tools/kunit/index.rst b/Documentation/dev-tools/kunit/index.rst
index f5d13f1d37be1d..ad972602d91ad8 100644
--- a/Documentation/dev-tools/kunit/index.rst
+++ b/Documentation/dev-tools/kunit/index.rst
@@ -8,6 +8,7 @@ KUnit - Linux Kernel Unit Testing
 	:maxdepth: 2
 	:caption: Contents:
 
+	intro
 	start
 	architecture
 	run_wrapper
@@ -19,95 +20,3 @@ KUnit - Linux Kernel Unit Testing
 	tips
 	running_tips
 
-This section details the kernel unit testing framework.
-
-Introduction
-============
-
-KUnit (Kernel unit testing framework) provides a common framework for
-unit tests within the Linux kernel. Using KUnit, you can define groups
-of test cases called test suites. The tests either run on kernel boot
-if built-in, or load as a module. KUnit automatically flags and reports
-failed test cases in the kernel log. The test results appear in
-:doc:`KTAP (Kernel - Test Anything Protocol) format</dev-tools/ktap>`.
-It is inspired by JUnit, Python’s unittest.mock, and GoogleTest/GoogleMock
-(C++ unit testing framework).
-
-KUnit tests are part of the kernel, written in the C (programming)
-language, and test parts of the Kernel implementation (example: a C
-language function). Excluding build time, from invocation to
-completion, KUnit can run around 100 tests in less than 10 seconds.
-KUnit can test any kernel component, for example: file system, system
-calls, memory management, device drivers and so on.
-
-KUnit follows the white-box testing approach. The test has access to
-internal system functionality. KUnit runs in kernel space and is not
-restricted to things exposed to user-space.
-
-In addition, KUnit has kunit_tool, a script (``tools/testing/kunit/kunit.py``)
-that configures the Linux kernel, runs KUnit tests under QEMU or UML
-(:doc:`User Mode Linux </virt/uml/user_mode_linux_howto_v2>`),
-parses the test results and
-displays them in a user friendly manner.
-
-Features
---------
-
-- Provides a framework for writing unit tests.
-- Runs tests on any kernel architecture.
-- Runs a test in milliseconds.
-
-Prerequisites
--------------
-
-- Any Linux kernel compatible hardware.
-- For Kernel under test, Linux kernel version 5.5 or greater.
-
-Unit Testing
-============
-
-A unit test tests a single unit of code in isolation. A unit test is the finest
-granularity of testing and allows all possible code paths to be tested in the
-code under test. This is possible if the code under test is small and does not
-have any external dependencies outside of the test's control like hardware.
-
-
-Write Unit Tests
-----------------
-
-To write good unit tests, there is a simple but powerful pattern:
-Arrange-Act-Assert. This is a great way to structure test cases and
-defines an order of operations.
-
-- Arrange inputs and targets: At the start of the test, arrange the data
-  that allows a function to work. Example: initialize a statement or
-  object.
-- Act on the target behavior: Call your function/code under test.
-- Assert expected outcome: Verify that the result (or resulting state) is as
-  expected.
-
-Unit Testing Advantages
------------------------
-
-- Increases testing speed and development in the long run.
-- Detects bugs at initial stage and therefore decreases bug fix cost
-  compared to acceptance testing.
-- Improves code quality.
-- Encourages writing testable code.
-
-Read also :ref:`kinds-of-tests`.
-
-How do I use it?
-================
-
-*   Documentation/dev-tools/kunit/start.rst - for KUnit new users.
-*   Documentation/dev-tools/kunit/architecture.rst - KUnit architecture.
-*   Documentation/dev-tools/kunit/run_wrapper.rst - run kunit_tool.
-*   Documentation/dev-tools/kunit/run_manual.rst - run tests without kunit_tool.
-*   Documentation/dev-tools/kunit/usage.rst - write tests.
-*   Documentation/dev-tools/kunit/tips.rst - best practices with
-    examples.
-*   Documentation/dev-tools/kunit/api/index.rst - KUnit APIs
-    used for testing.
-*   Documentation/dev-tools/kunit/faq.rst - KUnit common questions and
-    answers.
diff --git a/Documentation/dev-tools/kunit/intro.rst b/Documentation/dev-tools/kunit/intro.rst
new file mode 100644
index 00000000000000..6061aaa0e905ab
--- /dev/null
+++ b/Documentation/dev-tools/kunit/intro.rst
@@ -0,0 +1,61 @@
+Introduction to KUnit
+=====================
+
+KUnit (Kernel unit testing framework) provides a common framework for
+unit tests within the Linux kernel. Using KUnit, you can write test
+suites for your kernel code. As with other kernel features, the
+tests can be either built into the kernel image or as loadable modules.
+It automatically flags and reports
+failed test cases in the kernel log. The test results appear in
+:doc:`KTAP (Kernel - Test Anything Protocol) format</dev-tools/ktap>`.
+It is inspired by JUnit, Python’s unittest.mock, and GoogleTest/GoogleMock
+(C++ unit testing framework).
+
+KUnit tests are kernel code, written in the C, that tests particular kernel
+functionality. KUnit can run around
+100 tests in less than 10 seconds.
+KUnit can test any kernel component, such as file system, system
+calls, memory management, device drivers and so on.
+
+KUnit follows the white-box testing approach. The test has access to
+kernel internal. It runs in kernel space and thus not restricted to things
+exposed to user-space.
+
+In addition, KUnit has a script (``tools/testing/kunit/kunit.py``)
+that configures the kernel, runs the tests under QEMU or UML
+(:doc:`User Mode Linux </virt/uml/user_mode_linux_howto_v2>`),
+parses the test results and displays them in a user friendly manner.
+The rest of KUnit documentation will refer to this script as kunit_tool.
+
+Features
+--------
+
+- Provides a framework for writing unit tests.
+- Runs tests on any kernel architecture.
+- Runs a test in milliseconds.
+
+Prerequisites
+-------------
+
+- Linux kernel 5.5 or later is required to test using KUnit.
+
+Unit testing
+------------
+
+A unit test tests a particular code in isolation. It is the finest
+granularity of testing and allows all possible code paths to be tested in the
+code under test. This is possible if the code under test is small and does not
+depend on external factors (like hardware).
+
+Next steps
+----------
+
+If you haven't write the test before, see
+Documentation/dev-tools/kunit/start.rst for tutorial on writing your first
+test. An in-depth explanation of writing test is described in
+Documentation/dev-tools/kunit/usage.rst. For information on running tests,
+see Documentation/dev-tools/kunit/run_wrapper.rst and
+Documentation/dev-tools/kunit/run_manual.rst.
+
+The KUnit infrastructure is explained in
+Documentation/dev-tools/kunit/architecture.rst.
-- 
An old man doll... just what I always wanted! - Clara


  parent reply	other threads:[~2022-10-23 12:57 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-23 12:54 [PATCH 0/7] KUnit documentation rewording Bagas Sanjaya
2022-10-23 12:54 ` [PATCH 1/7] Documentation: kunit: rewrite "Writing Your First Test" section Bagas Sanjaya
2022-10-23 12:54 ` [PATCH 2/7] Documentation: kunit: align instruction code blocks Bagas Sanjaya
2022-10-23 12:54 ` [PATCH 3/7] Documentation: kunit: rewrite the rest of "Getting Started" documentation Bagas Sanjaya
2022-11-11 19:46   ` Daniel Latypov
2022-10-23 12:54 ` Bagas Sanjaya [this message]
2022-10-23 12:54 ` [PATCH 5/7] Documentation: kunit: rewrite "Running tests with kunit_tool" Bagas Sanjaya
2022-10-23 12:54 ` [PATCH 6/7] Documentation: kunit: rewrite "Run Tests without kunit_tool" Bagas Sanjaya
2022-10-23 12:54 ` [PATCH 7/7] Documentation: kunit: rewrite usage Bagas Sanjaya
2022-10-23 13:08   ` Bagas Sanjaya
2022-10-23 12:54 ` [PATCH 7/7] Documentation: kunit: rewrite "Writing tests" Bagas Sanjaya

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221023125414.60961-5-bagasdotme@gmail.com \
    --to=bagasdotme@gmail.com \
    --cc=brendan.higgins@linux.dev \
    --cc=corbet@lwn.net \
    --cc=davidgow@google.com \
    --cc=khalid.masum.92@gmail.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    --cc=sadiyakazi@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.