linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v2 00/14] kunit: introduce KUnit, the Linux kernel unit testing framework
@ 2018-10-23 23:57 Brendan Higgins
  2018-10-23 23:57 ` [RFC v2 01/14] kunit: test: add KUnit test runner core Brendan Higgins
                   ` (17 more replies)
  0 siblings, 18 replies; 30+ messages in thread
From: Brendan Higgins @ 2018-10-23 23:57 UTC (permalink / raw)
  To: gregkh, keescook, mcgrof, shuah
  Cc: joel, mpe, joe, brakmo, rostedt, Tim.Bird, khilman, julia.lawall,
	linux-kselftest, kunit-dev, linux-kernel, jdike, richard,
	linux-um, daniel, dri-devel, robh, dan.j.williams, linux-nvdimm,
	kieran.bingham, Brendan Higgins

This patch set proposes KUnit, a lightweight unit testing and mocking
framework for the Linux kernel.

Unlike Autotest and kselftest, KUnit is a true unit testing framework;
it does not require installing the kernel on a test machine or in a VM
and does not require tests to be written in userspace running on a host
kernel. Additionally, KUnit is fast: From invocation to completion KUnit
can run several dozen tests in under a second. Currently, the entire
KUnit test suite for KUnit runs in under a second from the initial
invocation (build time excluded).

KUnit is heavily inspired by JUnit, Python's unittest.mock, and
Googletest/Googlemock for C++. KUnit provides facilities for defining
unit test cases, grouping related test cases into test suites, providing
common infrastructure for running tests, mocking, spying, and much more.

## What's so special about unit testing?

A unit test is supposed to test a single unit of code in isolation,
hence the name. There should be no dependencies outside the control of
the test; this means no external dependencies, which makes tests orders
of magnitudes faster. Likewise, since there are no external dependencies,
there are no hoops to jump through to run the tests. Additionally, this
makes unit tests deterministic: a failing unit test always indicates a
problem. Finally, because unit tests necessarily have finer granularity,
they are able to test all code paths easily solving the classic problem
of difficulty in exercising error handling code.

## Is KUnit trying to replace other testing frameworks for the kernel?

No. Most existing tests for the Linux kernel are end-to-end tests, which
have their place. A well tested system has lots of unit tests, a
reasonable number of integration tests, and some end-to-end tests. KUnit
is just trying to address the unit test space which is currently not
being addressed.

## More information on KUnit

There is a bunch of documentation near the end of this patch set that
describes how to use KUnit and best practices for writing unit tests.
For convenience I am hosting the compiled docs here:
https://google.github.io/kunit-docs/third_party/kernel/docs/

## Changes Since Last Version

 - Updated patchset to apply cleanly on 4.19.
 - Stripped down patchset to focus on just the core features (I dropped
   mocking, spying, and the MMIO stuff for now; you can find these
   patches here: https://kunit-review.googlesource.com/c/linux/+/1132),
   as suggested by Rob.
 - Cleaned up some of the commit messages and tweaked commit order a
   bit based on suggestions.

-- 
2.19.1.568.g152ad8e336-goog


^ permalink raw reply	[flat|nested] 30+ messages in thread

end of thread, other threads:[~2018-11-30  0:59 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-23 23:57 [RFC v2 00/14] kunit: introduce KUnit, the Linux kernel unit testing framework Brendan Higgins
2018-10-23 23:57 ` [RFC v2 01/14] kunit: test: add KUnit test runner core Brendan Higgins
2018-11-02 18:44   ` Shuah Khan
2018-11-07  1:28     ` Brendan Higgins
2018-11-07 20:02       ` Shuah Khan
2018-10-23 23:57 ` [RFC v2 02/14] kunit: test: add test resource management API Brendan Higgins
2018-10-23 23:57 ` [RFC v2 03/14] kunit: test: add string_stream a std::stream like string builder Brendan Higgins
2018-10-23 23:57 ` [RFC v2 04/14] kunit: test: add test_stream a std::stream like logger Brendan Higgins
2018-10-23 23:57 ` [RFC v2 05/14] kunit: test: add the concept of expectations Brendan Higgins
2018-10-23 23:57 ` [RFC v2 06/14] arch: um: enable running kunit from User Mode Linux Brendan Higgins
2018-10-23 23:57 ` [RFC v2 07/14] kunit: test: add initial tests Brendan Higgins
2018-10-23 23:57 ` [RFC v2 08/14] arch: um: add shim to trap to allow installing a fault catcher for tests Brendan Higgins
2018-10-23 23:57 ` [RFC v2 09/14] kunit: test: add the concept of assertions Brendan Higgins
2018-10-23 23:57 ` [RFC v2 10/14] kunit: add Python libraries for handing KUnit config and kernel Brendan Higgins
2018-10-23 23:57 ` [RFC v2 11/14] kunit: add KUnit wrapper script and simple output parser Brendan Higgins
2018-10-23 23:57 ` [RFC v2 12/14] kunit.py: improve output from python wrapper Brendan Higgins
2018-10-23 23:57 ` [RFC v2 13/14] Documentation: kunit: add documentation for KUnit Brendan Higgins
2018-10-23 23:57 ` [RFC v2 14/14] MAINTAINERS: add entry for KUnit the unit testing framework Brendan Higgins
2018-10-24  9:14 ` [RFC v2 00/14] kunit: introduce KUnit, the Linux kernel " Daniel Vetter
2018-10-25 21:25   ` Brendan Higgins
2018-10-25 17:40 ` Shuah Khan
2018-11-02 18:23 ` Shuah Khan
2018-11-07  1:17   ` Brendan Higgins
2018-11-07 17:46     ` Frank Rowand
2018-11-13 10:10       ` Brendan Higgins
2018-11-24  5:15 ` Knut Omang
2018-11-27  1:41   ` Brendan Higgins
2018-11-28 19:54     ` Knut Omang
2018-11-28 20:50       ` shuah
2018-11-30  0:59         ` Luis Chamberlain

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).