GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.kernel.org — KUnit - Linux Kernel Unit Testing — The Linux Kernel documentation KUnit - Linux Kernel Unit Testing¶Contents: 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 KTAP (Kernel - Test Anything Protocol) format. 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 ( Features¶
Prerequisites¶
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.
Unit Testing Advantages¶
Read also What is the difference between a unit test and other kinds of tests?. How do I use it?¶You can find a step-by-step guide to writing and running KUnit tests in Getting Started Alternatively, feel free to look through the rest of the KUnit documentation, or to experiment with tools/testing/kunit/kunit.py and the example test under lib/kunit/kunit-example-test.c Happy testing! |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |