mocking.rst: add start of write-up on mocking + function redirection

Note: this isn't so much about mocking as it is about redirecting
function calls (potentially to a mock). But will
probably be more memorable and match more what people search for.

In [1], a doc was presented on stream but couldn't be made publicly

This is the start of the process of making it available.

Unlike that doc, this page has a different audience and is intended to
also try and give a basic feel for what mocking is and why you
would/would not want to use it.

This first patch includes the description of fakes vs mocks and a
skeleton for the rest (the doc's overview of the different kinds of
approaches to adding indirection).


Change-Id: I54899388cc2ca07b1ba5d41dc7add4363cab2223
Signed-off-by: Daniel Latypov <>
2 files changed
tree: 4b359dc7708d46256f04fc6025c5e96653d4eb59
  1. development/
  2. statics/
  3. third_party/
  4. usage/
  5. .gitignore
  10. index.rst
  12. Makefile
  13. mocking.rst
  14. press.rst

KUnit Documentation

KUnit is a lightweight unit testing and mocking framework for the Linux kernel. These tests are able to be run locally on a developer’s workstation without a VM or special hardware.

KUnit is heavily inspired by JUnit, Python’s unittest.mock, and Googletest/Googlemock for C++. KUnit defines a way to mock out C style classes and functions and create expectations on methods called within the code under test.

This is a repository to host the source for the KUnit documentation.

NOTE: There is an important distinction between KUnit‘s documentation source and it’s documentation site. As a project meant primarily to serve the development of the Linux kernel, a significant portion of our code and documentation reside in the Linux kernel codebase. Consequently, the documentation that does not live in the Linux kernel follows many of the conventions of the Linux kernel. One of these conventions is that we use Sphinx for all of our documentation. Thus, because Sphinx requires documentation to be compiled from its source files, we must have a repository for all the Sphinx source files and a separate repository for all of the generated output files to actually host the site. This is the repository for the source.

Where is the code?

How to build documentation

Documentation can be built by running:

make html

How to update the documentation

Our documentation is hosted at The documentation may be updated by building the documentation as described above, and then:


You can copy the files over without committing and pushing the files with:

./ --no-commit