| ============= |
| 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 :ref:`alpha-master` below for more details. |
| |
| .. _download-links: |
| |
| Where are these versions? |
| ========================= |
| |
| Upstream |
| -------- |
| |
| KUnit can be found in Linux 5.5 and newer. |
| |
| - Code: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/ |
| - `Usage <../third_party/kernel/docs/usage.html>`__ - for a more detailed explanation of KUnit features |
| - `API <../third_party/kernel/docs/api>`__ - for the list of KUnit APIs used for testing |
| |
| The KUnit code itself is primarily found in the `lib/kunit <https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/lib/kunit>`__ |
| directory. |
| |
| .. _alpha-master: |
| |
| Deprecated |
| ---------- |
| |
| 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 |
| |
| .. note:: |
| 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 |
| <https://kunit-review.googlesource.com/c/linux/+/4029/>`_ for details. |
| |
| The old, deprecated branch is stored in a Google-hosted gerrit instance. |
| |
| - Code: https://kunit.googlesource.com/linux/+/kunit/alpha/master. |
| - `Usage <../third_party/stable_kernel/docs/usage.html>`__ - for a more detailed explanation of KUnit features |
| - `API <../third_party/stable_kernel/docs/api>`__ - for the list of KUnit APIs used for testing |
| - kunitconfig file: https://kunit.googlesource.com/kunitconfig/+/refs/heads/kunit/alpha/master/kunitconfig |