Getting KUnit

If you’re working on Linux 5.5+, you have KUnit. Otherwise, you’ll want to backport the patches, which should all begin with "kunit: ".

An option of last resort is to use the deprecated and incompatible kunit/alpha/master branch. See Deprecated below for more details.

Where are these versions?


KUnit can be found in Linux 5.5 and newer.

The KUnit code itself is primarily found in the lib/kunit directory.


This is where KUnit development was done prior to getting upstreamed, but all development on it has since ceased.

It has a couple of features that haven’t made their way in the upstream version of KUnit yet, namely:

  • Class mocking

  • Function mocking

  • Hardware/platform faking

  • Error recovery


Tests written against the kunit/alpha/master branch will not be directly compatible with the upstream version, however. You can set CONFIG_KUNIT_USE_UPSTREAM_NAMES=y to make it act a bit more like the upstream version, see this patch series for details.

The old, deprecated branch is stored in a Google-hosted gerrit instance.