1 .. SPDX-License-Identifier: GPL-2.0 2 3 ========================== 4 Frequently Asked Questions 5 ========================== 6 7 How is this different from Autotest, kselftest 8 ============================================== 9 KUnit is a unit testing framework. Autotest, k 10 not. 11 12 A `unit test <https://martinfowler.com/bliki/U 13 test a single unit of code in isolation and he 14 test should be the finest granularity of testi 15 code paths to be tested in the code under test 16 code under test is small and does not have any 17 the test's control like hardware. 18 19 There are no testing frameworks currently avai 20 require installing the kernel on a test machin 21 testing frameworks require tests to be written 22 kernel under test. This is true for Autotest, 23 disqualifying any of them from being considere 24 25 Does KUnit support running on architectures ot 26 ============================================== 27 28 Yes, mostly. 29 30 For the most part, the KUnit core framework (w 31 can compile to any architecture. It compiles l 32 kernel and runs when the kernel boots, or when 33 module is loaded. However, there is infrastru 34 (``tools/testing/kunit/kunit.py``) that might 35 (see :ref:`kunit-on-qemu`). 36 37 In short, yes, you can run KUnit on other arch 38 more work than using KUnit on UML. 39 40 For more information, see :ref:`kunit-on-non-u 41 42 .. _kinds-of-tests: 43 44 What is the difference between a unit test and 45 ============================================== 46 Most existing tests for the Linux kernel would 47 test, or an end-to-end test. 48 49 - A unit test is supposed to test a single uni 50 test should be the finest granularity of tes 51 possible code paths to be tested in the code 52 if the code under test is small and does not 53 outside of the test's control like hardware. 54 - An integration test tests the interaction be 55 usually just two or three. For example, some 56 test to test the interaction between a drive 57 test the interaction between the userspace l 58 the kernel itself. However, one of these tes 59 entire kernel along with hardware interactio 60 userspace. 61 - An end-to-end test usually tests the entire 62 code under test. For example, someone might 63 kernel by installing a production configurat 64 hardware with a production userspace and the 65 that depends on interactions between the har 66 67 KUnit is not working, what should I do? 68 ======================================= 69 70 Unfortunately, there are a number of things wh 71 things to try. 72 73 1. Run ``./tools/testing/kunit/kunit.py run`` 74 parameter. This might show details or error 75 parser. 76 2. Instead of running ``kunit.py run``, try ru 77 ``kunit.py build``, and ``kunit.py exec`` i 78 down where an issue is occurring. (If you t 79 can run it manually against ``stdin`` or a 80 3. Running the UML kernel directly can often r 81 ``kunit_tool`` ignores. This should be as s 82 after building the UML kernel (for example, 83 Note that UML has some unusual requirements 84 filesystem mounted), and has had issues in 85 the host has KASLR enabled. (On older host 86 ``setarch `uname -m` -R ./vmlinux`` to disa 87 4. Make sure the kernel .config has ``CONFIG_K 88 (e.g. ``CONFIG_KUNIT_EXAMPLE_TEST=y``). kun 89 around, so you can see what config was used 90 It also preserves any config changes you mi 91 enable/disable things with ``make ARCH=um m 92 re-run kunit_tool. 93 5. Try to run ``make ARCH=um defconfig`` befor 94 may help clean up any residual config items 95 6. Finally, try running KUnit outside UML. KUn 96 built into any kernel, or can be built as a 97 Doing so should allow you to determine if U 98 seeing. When tests are built-in, they will 99 modules will automatically execute associat 100 can be collected from ``/sys/kernel/debug/k 101 can be parsed with ``kunit.py parse``. For 102 103 If none of the above tricks help, you are alwa 104 kunit-dev@googlegroups.com.
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.