€•nEŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ)/translations/zh_CN/dev-tools/kunit/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ)/translations/zh_TW/dev-tools/kunit/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ)/translations/it_IT/dev-tools/kunit/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ)/translations/ja_JP/dev-tools/kunit/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ)/translations/ko_KR/dev-tools/kunit/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ)/translations/sp_SP/dev-tools/kunit/index”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒC/var/lib/git/docbuild/linux/Documentation/dev-tools/kunit/index.rst”h KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒ!KUnit - Linux Kernel Unit Testing”h]”hŒ!KUnit - Linux Kernel Unit Testing”…””}”(hh»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hh¶hžhhŸh³h KubhŒcompound”“”)”}”(hhh]”hŒtoctree”“”)”}”(hhh]”h}”(h]”h ]”h"]”h$]”h&]”hŒdev-tools/kunit/index”Œentries”]”(NŒdev-tools/kunit/start”†”NŒdev-tools/kunit/architecture”†”NŒdev-tools/kunit/run_wrapper”†”NŒdev-tools/kunit/run_manual”†”NŒdev-tools/kunit/usage”†”NŒdev-tools/kunit/api/index”†”NŒdev-tools/kunit/style”†”NŒdev-tools/kunit/faq”†”NŒdev-tools/kunit/running_tips”†”eŒ includefiles”]”(hÜhÞhàhâhähæhèhêhìeŒmaxdepth”KŒcaption”Œ Contents:”Œglob”‰Œhidden”‰Œ includehidden”‰Œnumbered”KŒ titlesonly”‰Œ rawentries”]”Œ rawcaption”hòuh1hÎhŸh³h KhhËubah}”(h]”h ]”Œtoctree-wrapper”ah"]”h$]”h&]”uh1hÉhh¶hžhhŸh³h NubhŒ paragraph”“”)”}”(hŒ7This section details the kernel unit testing framework.”h]”hŒ7This section details the kernel unit testing framework.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h Khh¶hžhubhµ)”}”(hhh]”(hº)”}”(hŒ Introduction”h]”hŒ Introduction”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjhžhhŸh³h Kubj)”}”(hX KUnit (Kernel unit testing framework) provides a common framework for unit tests within the Linux kernel. Using KUnit, you can define groups of test cases called test suites. The tests either run on kernel boot if built-in, or load as a module. KUnit automatically flags and reports failed test cases in the kernel log. The test results appear in :doc:`KTAP (Kernel - Test Anything Protocol) format`. It is inspired by JUnit, Python’s unittest.mock, and GoogleTest/GoogleMock (C++ unit testing framework).”h]”(hX[KUnit (Kernel unit testing framework) provides a common framework for unit tests within the Linux kernel. Using KUnit, you can define groups of test cases called test suites. The tests either run on kernel boot if built-in, or load as a module. KUnit automatically flags and reports failed test cases in the kernel log. The test results appear in ”…””}”(hj#hžhhŸNh Nubh)”}”(hŒE:doc:`KTAP (Kernel - Test Anything Protocol) format`”h]”hŒinline”“”)”}”(hj-h]”hŒ-KTAP (Kernel - Test Anything Protocol) format”…””}”(hj1hžhhŸNh Nubah}”(h]”h ]”(Œxref”Œstd”Œstd-doc”eh"]”h$]”h&]”uh1j/hj+ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”hÙŒ refdomain”j<Œreftype”Œdoc”Œ refexplicit”ˆŒrefwarn”ˆŒ reftarget”Œ/dev-tools/ktap”uh1hhŸh³h Khj#ubhŒl. It is inspired by JUnit, Python’s unittest.mock, and GoogleTest/GoogleMock (C++ unit testing framework).”…””}”(hj#hžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h Khjhžhubj)”}”(hXKUnit tests are part of the kernel, written in the C (programming) language, and test parts of the Kernel implementation (example: a C language function). Excluding build time, from invocation to completion, KUnit can run around 100 tests in less than 10 seconds. KUnit can test any kernel component, for example: file system, system calls, memory management, device drivers and so on.”h]”hXKUnit tests are part of the kernel, written in the C (programming) language, and test parts of the Kernel implementation (example: a C language function). Excluding build time, from invocation to completion, KUnit can run around 100 tests in less than 10 seconds. KUnit can test any kernel component, for example: file system, system calls, memory management, device drivers and so on.”…””}”(hjYhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h K#hjhžhubj)”}”(hŒµKUnit follows the white-box testing approach. The test has access to internal system functionality. KUnit runs in kernel space and is not restricted to things exposed to user-space.”h]”hŒµKUnit follows the white-box testing approach. The test has access to internal system functionality. KUnit runs in kernel space and is not restricted to things exposed to user-space.”…””}”(hjghžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h K*hjhžhubj)”}”(hXIn addition, KUnit has kunit_tool, a script (``tools/testing/kunit/kunit.py``) that configures the Linux kernel, runs KUnit tests under QEMU or UML (:doc:`User Mode Linux `), parses the test results and displays them in a user friendly manner.”h]”(hŒ-In addition, KUnit has kunit_tool, a script (”…””}”(hjuhžhhŸNh NubhŒliteral”“”)”}”(hŒ ``tools/testing/kunit/kunit.py``”h]”hŒtools/testing/kunit/kunit.py”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1j}hjuubhŒH) that configures the Linux kernel, runs KUnit tests under QEMU or UML (”…””}”(hjuhžhhŸNh Nubh)”}”(hŒ;:doc:`User Mode Linux `”h]”j0)”}”(hj“h]”hŒUser Mode Linux”…””}”(hj•hžhhŸNh Nubah}”(h]”h ]”(j;Œstd”Œstd-doc”eh"]”h$]”h&]”uh1j/hj‘ubah}”(h]”h ]”h"]”h$]”h&]”Œrefdoc”hÙŒ refdomain”jŸŒreftype”Œdoc”Œ refexplicit”ˆŒrefwarn”ˆjMŒ"/virt/uml/user_mode_linux_howto_v2”uh1hhŸh³h K.hjuubhŒG), parses the test results and displays them in a user friendly manner.”…””}”(hjuhžhhŸNh Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h K.hjhžhubhµ)”}”(hhh]”(hº)”}”(hŒFeatures”h]”hŒFeatures”…””}”(hj¾hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hj»hžhhŸh³h K5ubhŒ bullet_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ,Provides a framework for writing unit tests.”h]”j)”}”(hjÕh]”hŒ,Provides a framework for writing unit tests.”…””}”(hj×hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h K7hjÓubah}”(h]”h ]”h"]”h$]”h&]”uh1jÑhjÎhžhhŸh³h NubjÒ)”}”(hŒ&Runs tests on any kernel architecture.”h]”j)”}”(hjìh]”hŒ&Runs tests on any kernel architecture.”…””}”(hjîhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h K8hjêubah}”(h]”h ]”h"]”h$]”h&]”uh1jÑhjÎhžhhŸh³h NubjÒ)”}”(hŒRuns a test in milliseconds. ”h]”j)”}”(hŒRuns a test in milliseconds.”h]”hŒRuns a test in milliseconds.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jhŸh³h K9hjubah}”(h]”h ]”h"]”h$]”h&]”uh1jÑhjÎhžhhŸh³h Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1jÌhŸh³h K7hj»hžhubeh}”(h]”Œfeatures”ah ]”h"]”Œfeatures”ah$]”h&]”uh1h´hjhžhhŸh³h K5ubhµ)”}”(hhh]”(hº)”}”(hŒ Prerequisites”h]”hŒ Prerequisites”…””}”(hj,hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hj)hžhhŸh³h Khj=ubah}”(h]”h ]”h"]”h$]”h&]”uh1jÑhj:hžhhŸh³h NubjÒ)”}”(hŒhj)hžhubeh}”(h]”Œ prerequisites”ah ]”h"]”Œ prerequisites”ah$]”h&]”uh1h´hjhžhhŸh³h K