€•ÓŒ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”Œ0/translations/zh_CN/dev-tools/kunit/running_tips”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)�”}”(hhh]”hŒChinese (Traditional)”…”�”}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/zh_TW/dev-tools/kunit/running_tips”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒItalian”…”�”}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/it_IT/dev-tools/kunit/running_tips”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒJapanese”…”�”}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/ja_JP/dev-tools/kunit/running_tips”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒKorean”…”�”}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/ko_KR/dev-tools/kunit/running_tips”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒPortuguese (Brazilian)”…”�”}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/pt_BR/dev-tools/kunit/running_tips”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)�”}”(hhh]”hŒSpanish”…”�”}”hh–sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ0/translations/sp_SP/dev-tools/kunit/running_tips”Œ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³ŒJ/var/lib/git/docbuild/linux/Documentation/dev-tools/kunit/running_tips.rst”h´KubhŒsection”“”)�”}”(hhh]”(hŒtitle”“”)�”}”(hŒTips For Running KUnit Tests”h]”hŒTips For Running KUnit Tests”…”�”}”(hhÏh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÊh²hh³hÇh´KubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ%Using ``kunit.py run`` ("kunit tool")”h]”(hŒUsing ”…”�”}”(hhàh²hh³Nh´NubhŒliteral”“”)�”}”(hŒ``kunit.py run``”h]”hŒ kunit.py run”…”�”}”(hhêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhhàubhŒ (“kunit toolâ€�)”…”�”}”(hhàh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1hÍhhÝh²hh³hÇh´KubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRunning from any directory”h]”hŒRunning from any directory”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´K ubhŒ paragraph”“”)�”}”(hŒ/It can be handy to create a bash function like:”h]”hŒ/It can be handy to create a bash function like:”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K hjh²hubhŒ literal_block”“”)�”}”(hŒofunction run_kunit() { ( cd "$(git rev-parse --show-toplevel)" && ./tools/testing/kunit/kunit.py run "$@" ) }”h]”hŒofunction run_kunit() { ( cd "$(git rev-parse --show-toplevel)" && ./tools/testing/kunit/kunit.py run "$@" ) }”…”�”}”hj%sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆŒforce”‰Œlanguage”Œbash”Œhighlight_args”}”uh1j#h³hÇh´Khjh²hubhŒnote”“”)�”}”(hŒ€Early versions of ``kunit.py`` (before 5.6) didn't work unless run from the kernel root, hence the use of a subshell and ``cd``.”h]”j)�”}”(hŒ€Early versions of ``kunit.py`` (before 5.6) didn't work unless run from the kernel root, hence the use of a subshell and ``cd``.”h]”(hŒEarly versions of ”…”�”}”(hj>h²hh³Nh´Nubhé)�”}”(hŒ ``kunit.py``”h]”hŒkunit.py”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj>ubhŒ] (before 5.6) didn’t work unless run from the kernel root, hence the use of a subshell and ”…”�”}”(hj>h²hh³Nh´Nubhé)�”}”(hŒ``cd``”h]”hŒcd”…”�”}”(hjXh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj>ubhŒ.”…”�”}”(hj>h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khj:ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hjh²hh³hÇh´Nubeh}”(h]”Œrunning-from-any-directory”ah ]”h"]”Œrunning from any directory”ah$]”h&]”uh1hÈhhÝh²hh³hÇh´K ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRunning a subset of tests”h]”hŒRunning a subset of tests”…”�”}”(hj�h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj~h²hh³hÇh´Kubj)�”}”(hŒq``kunit.py run`` accepts an optional glob argument to filter tests. The format is ``"[.test_glob]"``.”h]”(hé)�”}”(hŒ``kunit.py run``”h]”hŒ kunit.py run”…”�”}”(hj“h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj�ubhŒB accepts an optional glob argument to filter tests. The format is ”…”�”}”(hj�h²hh³Nh´Nubhé)�”}”(hŒ``"[.test_glob]"``”h]”hŒ"[.test_glob]"”…”�”}”(hj¥h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj�ubhŒ.”…”�”}”(hj�h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khj~h²hubj)�”}”(hŒ?Say that we wanted to run the sysctl tests, we could do so via:”h]”hŒ?Say that we wanted to run the sysctl tests, we could do so via:”…”�”}”(hj½h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Khj~h²hubj$)�”}”(hŒy$ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > .kunit/.kunitconfig $ ./tools/testing/kunit/kunit.py run 'sysctl*'”h]”hŒy$ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > .kunit/.kunitconfig $ ./tools/testing/kunit/kunit.py run 'sysctl*'”…”�”}”hjËsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´K!hj~h²hubj)�”}”(hŒ1We can filter down to just the "write" tests via:”h]”hŒ5We can filter down to just the “writeâ€� tests via:”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K&hj~h²hubj$)�”}”(hŒ�$ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > .kunit/.kunitconfig $ ./tools/testing/kunit/kunit.py run 'sysctl*.*write*'”h]”hŒ�$ echo -e 'CONFIG_KUNIT=y\nCONFIG_KUNIT_ALL_TESTS=y' > .kunit/.kunitconfig $ ./tools/testing/kunit/kunit.py run 'sysctl*.*write*'”…”�”}”hjésbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´K(hj~h²hubj)�”}”(hŒ¢We're paying the cost of building more tests than we need this way, but it's easier than fiddling with ``.kunitconfig`` files or commenting out ``kunit_suite``'s.”h]”(hŒkWe’re paying the cost of building more tests than we need this way, but it’s easier than fiddling with ”…”�”}”(hjùh²hh³Nh´Nubhé)�”}”(hŒ``.kunitconfig``”h]”hŒ .kunitconfig”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjùubhŒ files or commenting out ”…”�”}”(hjùh²hh³Nh´Nubhé)�”}”(hŒ``kunit_suite``”h]”hŒ kunit_suite”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjùubhŒ’s.”…”�”}”(hjùh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K-hj~h²hubj)�”}”(hŒ\However, if we wanted to define a set of tests in a less ad hoc way, the next tip is useful.”h]”hŒ\However, if we wanted to define a set of tests in a less ad hoc way, the next tip is useful.”…”�”}”(hj+h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K1hj~h²hubeh}”(h]”Œrunning-a-subset-of-tests”ah ]”h"]”Œrunning a subset of tests”ah$]”h&]”uh1hÈhhÝh²hh³hÇh´KubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒDefining a set of tests”h]”hŒDefining a set of tests”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjAh²hh³hÇh´K5ubj)�”}”(hX``kunit.py run`` (along with ``build``, and ``config``) supports a ``--kunitconfig`` flag. So if you have a set of tests that you want to run on a regular basis (especially if they have other dependencies), you can create a specific ``.kunitconfig`` for them.”h]”(hé)�”}”(hŒ``kunit.py run``”h]”hŒ kunit.py run”…”�”}”(hjVh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjRubhŒ (along with ”…”�”}”(hjRh²hh³Nh´Nubhé)�”}”(hŒ ``build``”h]”hŒbuild”…”�”}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjRubhŒ, and ”…”�”}”(hjRh²hh³Nh´Nubhé)�”}”(hŒ ``config``”h]”hŒconfig”…”�”}”(hjzh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjRubhŒ ) supports a ”…”�”}”(hjRh²hh³Nh´Nubhé)�”}”(hŒ``--kunitconfig``”h]”hŒ --kunitconfig”…”�”}”(hjŒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjRubhŒ• flag. So if you have a set of tests that you want to run on a regular basis (especially if they have other dependencies), you can create a specific ”…”�”}”(hjRh²hh³Nh´Nubhé)�”}”(hŒ``.kunitconfig``”h]”hŒ .kunitconfig”…”�”}”(hjžh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjRubhŒ for them.”…”�”}”(hjRh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K7hjAh²hubj)�”}”(hŒ!E.g. kunit has one for its tests:”h]”hŒ!E.g. kunit has one for its tests:”…”�”}”(hj¶h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KhjAh²hubj)�”}”(hŒzAlternatively, if you're following the convention of naming your file ``.kunitconfig``, you can just pass in the dir, e.g.”h]”(hŒHAlternatively, if you’re following the convention of naming your file ”…”�”}”(hjÔh²hh³Nh´Nubhé)�”}”(hŒ``.kunitconfig``”h]”hŒ .kunitconfig”…”�”}”(hjÜh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjÔubhŒ$, you can just pass in the dir, e.g.”…”�”}”(hjÔh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KBhjAh²hubj$)�”}”(hŒ<$ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit”h]”hŒ<$ ./tools/testing/kunit/kunit.py run --kunitconfig=lib/kunit”…”�”}”hjôsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´KEhjAh²hubj9)�”}”(hX This is a relatively new feature (5.12+) so we don't have any conventions yet about on what files should be checked in versus just kept around locally. It's up to you and your maintainer to decide if a config is useful enough to submit (and therefore have to maintain).”h]”j)�”}”(hX This is a relatively new feature (5.12+) so we don't have any conventions yet about on what files should be checked in versus just kept around locally. It's up to you and your maintainer to decide if a config is useful enough to submit (and therefore have to maintain).”h]”hXThis is a relatively new feature (5.12+) so we don’t have any conventions yet about on what files should be checked in versus just kept around locally. It’s up to you and your maintainer to decide if a config is useful enough to submit (and therefore have to maintain).”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KJhjubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hjAh²hh³hÇh´Nubj9)�”}”(hXôHaving ``.kunitconfig`` fragments in a parent and child directory is iffy. There's discussion about adding an "import" statement in these files to make it possible to have a top-level config run tests from all child directories. But that would mean ``.kunitconfig`` files are no longer just simple .config fragments. One alternative would be to have kunit tool recursively combine configs automagically, but tests could theoretically depend on incompatible options, so handling that would be tricky.”h]”(j)�”}”(hX<Having ``.kunitconfig`` fragments in a parent and child directory is iffy. There's discussion about adding an "import" statement in these files to make it possible to have a top-level config run tests from all child directories. But that would mean ``.kunitconfig`` files are no longer just simple .config fragments.”h]”(hŒHaving ”…”�”}”(hj h²hh³Nh´Nubhé)�”}”(hŒ``.kunitconfig``”h]”hŒ .kunitconfig”…”�”}”(hj(h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj ubhŒè fragments in a parent and child directory is iffy. There’s discussion about adding an “importâ€� statement in these files to make it possible to have a top-level config run tests from all child directories. But that would mean ”…”�”}”(hj h²hh³Nh´Nubhé)�”}”(hŒ``.kunitconfig``”h]”hŒ .kunitconfig”…”�”}”(hj:h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj ubhŒ3 files are no longer just simple .config fragments.”…”�”}”(hj h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KPhjubj)�”}”(hŒ¶One alternative would be to have kunit tool recursively combine configs automagically, but tests could theoretically depend on incompatible options, so handling that would be tricky.”h]”hŒ¶One alternative would be to have kunit tool recursively combine configs automagically, but tests could theoretically depend on incompatible options, so handling that would be tricky.”…”�”}”(hjRh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KVhjubeh}”(h]”h ]”h"]”h$]”h&]”uh1j8hjAh²hh³hÇh´Nubeh}”(h]”Œdefining-a-set-of-tests”ah ]”h"]”Œdefining a set of tests”ah$]”h&]”uh1hÈhhÝh²hh³hÇh´K5ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ%Setting kernel commandline parameters”h]”hŒ%Setting kernel commandline parameters”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjnh²hh³hÇh´K[ubj)�”}”(hŒFYou can use ``--kernel_args`` to pass arbitrary kernel arguments, e.g.”h]”(hŒ You can use ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ``--kernel_args``”h]”hŒ --kernel_args”…”�”}”(hj‡h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒ) to pass arbitrary kernel arguments, e.g.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K]hjnh²hubj$)�”}”(hŒV$ ./tools/testing/kunit/kunit.py run --kernel_args=param=42 --kernel_args=param2=false”h]”hŒV$ ./tools/testing/kunit/kunit.py run --kernel_args=param=42 --kernel_args=param2=false”…”�”}”hjŸsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´K_hjnh²hubeh}”(h]”Œ%setting-kernel-commandline-parameters”ah ]”h"]”Œ%setting kernel commandline parameters”ah$]”h&]”uh1hÈhhÝh²hh³hÇh´K[ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ*Generating code coverage reports under UML”h]”hŒ*Generating code coverage reports under UML”…”�”}”(hjºh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj·h²hh³hÇh´Keubj9)�”}”(hŒ¥TODO(brendanhiggins@google.com): There are various issues with UML and versions of gcc 7 and up. You're likely to run into missing ``.gcda`` files or compile errors.”h]”j)�”}”(hŒ¥TODO(brendanhiggins@google.com): There are various issues with UML and versions of gcc 7 and up. You're likely to run into missing ``.gcda`` files or compile errors.”h]”(hŒTODO(”…”�”}”(hjÌh²hh³Nh´NubhŒ reference”“”)�”}”(hŒbrendanhiggins@google.com”h]”hŒbrendanhiggins@google.com”…”�”}”(hjÖh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”Œrefuri”Œ mailto:brendanhiggins@google.com”uh1jÔhjÌubhŒg): There are various issues with UML and versions of gcc 7 and up. You’re likely to run into missing ”…”�”}”(hjÌh²hh³Nh´Nubhé)�”}”(hŒ ``.gcda``”h]”hŒ.gcda”…”�”}”(hjêh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjÌubhŒ files or compile errors.”…”�”}”(hjÌh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KhhjÈubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj·h²hh³hÇh´Nubj)�”}”(hŒThis is different from the "normal" way of getting coverage information that is documented in Documentation/dev-tools/gcov.rst.”h]”hŒƒThis is different from the “normalâ€� way of getting coverage information that is documented in Documentation/dev-tools/gcov.rst.”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Klhj·h²hubj)�”}”(hŒGInstead of enabling ``CONFIG_GCOV_KERNEL=y``, we can set these options:”h]”(hŒInstead of enabling ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ``CONFIG_GCOV_KERNEL=y``”h]”hŒCONFIG_GCOV_KERNEL=y”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒ, we can set these options:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kohj·h²hubj$)�”}”(hŒcCONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_GCOV=y”h]”hŒcCONFIG_DEBUG_KERNEL=y CONFIG_DEBUG_INFO=y CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y CONFIG_GCOV=y”…”�”}”hj6sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œnone”j6}”uh1j#h³hÇh´Kqhj·h²hubj)�”}”(hŒ>Putting it together into a copy-pastable sequence of commands:”h]”hŒ>Putting it together into a copy-pastable sequence of commands:”…”�”}”(hjFh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kyhj·h²hubj$)�”}”(hXÍ# Append coverage options to the current config $ ./tools/testing/kunit/kunit.py run --kunitconfig=.kunit/ --kunitconfig=tools/testing/kunit/configs/coverage_uml.config # Extract the coverage information from the build dir (.kunit/) $ lcov -t "my_kunit_tests" -o coverage.info -c -d .kunit/ # From here on, it's the same process as with CONFIG_GCOV_KERNEL=y # E.g. can generate an HTML report in a tmp dir like so: $ genhtml -o /tmp/coverage_html coverage.info”h]”hXÍ# Append coverage options to the current config $ ./tools/testing/kunit/kunit.py run --kunitconfig=.kunit/ --kunitconfig=tools/testing/kunit/configs/coverage_uml.config # Extract the coverage information from the build dir (.kunit/) $ lcov -t "my_kunit_tests" -o coverage.info -c -d .kunit/ # From here on, it's the same process as with CONFIG_GCOV_KERNEL=y # E.g. can generate an HTML report in a tmp dir like so: $ genhtml -o /tmp/coverage_html coverage.info”…”�”}”hjTsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´K{hj·h²hubj)�”}”(hŒGIf your installed version of gcc doesn't work, you can tweak the steps:”h]”hŒIIf your installed version of gcc doesn’t work, you can tweak the steps:”…”�”}”(hjdh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K‡hj·h²hubj$)�”}”(hŒ›$ ./tools/testing/kunit/kunit.py run --make_options=CC=/usr/bin/gcc-6 $ lcov -t "my_kunit_tests" -o coverage.info -c -d .kunit/ --gcov-tool=/usr/bin/gcov-6”h]”hŒ›$ ./tools/testing/kunit/kunit.py run --make_options=CC=/usr/bin/gcc-6 $ lcov -t "my_kunit_tests" -o coverage.info -c -d .kunit/ --gcov-tool=/usr/bin/gcov-6”…”�”}”hjrsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´K‰hj·h²hubj)�”}”(hŒ6Alternatively, LLVM-based toolchains can also be used:”h]”hŒ6Alternatively, LLVM-based toolchains can also be used:”…”�”}”(hj‚h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KŽhj·h²hubj$)�”}”(hX# Build with LLVM and append coverage options to the current config $ ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --kunitconfig=.kunit/ --kunitconfig=tools/testing/kunit/configs/coverage_uml.config $ llvm-profdata merge -sparse default.profraw -o default.profdata $ llvm-cov export --format=lcov .kunit/vmlinux -instr-profile default.profdata > coverage.info # The coverage.info file is in lcov-compatible format and it can be used to e.g. generate HTML report $ genhtml -o /tmp/coverage_html coverage.info”h]”hX# Build with LLVM and append coverage options to the current config $ ./tools/testing/kunit/kunit.py run --make_options LLVM=1 --kunitconfig=.kunit/ --kunitconfig=tools/testing/kunit/configs/coverage_uml.config $ llvm-profdata merge -sparse default.profraw -o default.profdata $ llvm-cov export --format=lcov .kunit/vmlinux -instr-profile default.profdata > coverage.info # The coverage.info file is in lcov-compatible format and it can be used to e.g. generate HTML report $ genhtml -o /tmp/coverage_html coverage.info”…”�”}”hj�sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´K�hj·h²hubeh}”(h]”Œ*generating-code-coverage-reports-under-uml”ah ]”h"]”Œ*generating code coverage reports under uml”ah$]”h&]”uh1hÈhhÝh²hh³hÇh´Keubeh}”(h]”Œusing-kunit-py-run-kunit-tool”ah ]”h"]”Œ!using kunit.py run ("kunit tool")”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´KubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRunning tests manually”h]”hŒRunning tests manually”…”�”}”(hj³h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj°h²hh³hÇh´K›ubj)�”}”(hŒ Running tests without using ``kunit.py run`` is also an important use case. Currently it's your only option if you want to test on architectures other than UML.”h]”(hŒRunning tests without using ”…”�”}”(hjÁh²hh³Nh´Nubhé)�”}”(hŒ``kunit.py run``”h]”hŒ kunit.py run”…”�”}”(hjÉh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjÁubhŒv is also an important use case. Currently it’s your only option if you want to test on architectures other than UML.”…”�”}”(hjÁh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K�hj°h²hubj)�”}”(hŒ²As running the tests under UML is fairly straightforward (configure and compile the kernel, run the ``./linux`` binary), this section will focus on testing non-UML architectures.”h]”(hŒdAs running the tests under UML is fairly straightforward (configure and compile the kernel, run the ”…”�”}”(hjáh²hh³Nh´Nubhé)�”}”(hŒ ``./linux``”h]”hŒ./linux”…”�”}”(hjéh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjáubhŒC binary), this section will focus on testing non-UML architectures.”…”�”}”(hjáh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K¡hj°h²hubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRunning built-in tests”h]”hŒRunning built-in tests”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´K§ubj)�”}”(hŒÈWhen setting tests to ``=y``, the tests will run as part of boot and print results to dmesg in TAP format. So you just need to add your tests to your ``.config``, build and boot your kernel as normal.”h]”(hŒWhen setting tests to ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ``=y``”h]”hŒ=y”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒz, the tests will run as part of boot and print results to dmesg in TAP format. So you just need to add your tests to your ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ ``.config``”h]”hŒ.config”…”�”}”(hj,h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒ', build and boot your kernel as normal.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K©hjh²hubj)�”}”(hŒ"So if we compiled our kernel with:”h]”hŒ"So if we compiled our kernel with:”…”�”}”(hjDh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K­hjh²hubj$)�”}”(hŒ*CONFIG_KUNIT=y CONFIG_KUNIT_EXAMPLE_TEST=y”h]”hŒ*CONFIG_KUNIT=y CONFIG_KUNIT_EXAMPLE_TEST=y”…”�”}”hjRsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œnone”j6}”uh1j#h³hÇh´K¯hjh²hubj)�”}”(hŒJThen we'd see output like this in dmesg signaling the test ran and passed:”h]”hŒLThen we’d see output like this in dmesg signaling the test ran and passed:”…”�”}”(hjbh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K´hjh²hubj$)�”}”(hŒ‰TAP version 14 1..1 # Subtest: example 1..1 # example_simple_test: initializing ok 1 - example_simple_test ok 1 - example”h]”hŒ‰TAP version 14 1..1 # Subtest: example 1..1 # example_simple_test: initializing ok 1 - example_simple_test ok 1 - example”…”�”}”hjpsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œnone”j6}”uh1j#h³hÇh´K¶hjh²hubeh}”(h]”Œrunning-built-in-tests”ah ]”h"]”Œrunning built-in tests”ah$]”h&]”uh1hÈhj°h²hh³hÇh´K§ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRunning tests as modules”h]”hŒRunning tests as modules”…”�”}”(hj‹h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjˆh²hh³hÇh´KÁubj)�”}”(hŒ?Depending on the tests, you can build them as loadable modules.”h]”hŒ?Depending on the tests, you can build them as loadable modules.”…”�”}”(hj™h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KÃhjˆh²hubj)�”}”(hŒ:For example, we'd change the config options from before to”h]”hŒkunit_test`` will not exist.”h]”j)�”}”(hXJYou can set ``CONFIG_KUNIT=m`` as well, however, some features will not work and thus some tests might break. Ideally tests would specify they depend on ``KUNIT=y`` in their ``Kconfig``'s, but this is an edge case most test authors won't think about. As of 5.13, the only difference is that ``current->kunit_test`` will not exist.”h]”(hŒ You can set ”…”�”}”(hjEh²hh³Nh´Nubhé)�”}”(hŒ``CONFIG_KUNIT=m``”h]”hŒCONFIG_KUNIT=m”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjEubhŒ{ as well, however, some features will not work and thus some tests might break. Ideally tests would specify they depend on ”…”�”}”(hjEh²hh³Nh´Nubhé)�”}”(hŒ ``KUNIT=y``”h]”hŒKUNIT=y”…”�”}”(hj_h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjEubhŒ in their ”…”�”}”(hjEh²hh³Nh´Nubhé)�”}”(hŒ ``Kconfig``”h]”hŒKconfig”…”�”}”(hjqh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjEubhŒn’s, but this is an edge case most test authors won’t think about. As of 5.13, the only difference is that ”…”�”}”(hjEh²hh³Nh´Nubhé)�”}”(hŒ``current->kunit_test``”h]”hŒcurrent->kunit_test”…”�”}”(hjƒh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjEubhŒ will not exist.”…”�”}”(hjEh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´KÙhjAubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hjˆh²hh³hÇh´Nubeh}”(h]”Œrunning-tests-as-modules”ah ]”h"]”Œrunning tests as modules”ah$]”h&]”uh1hÈhj°h²hh³hÇh´KÁubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒPretty-printing results”h]”hŒPretty-printing results”…”�”}”(hj¬h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj©h²hh³hÇh´Káubj)�”}”(hŒ‹You can use ``kunit.py parse`` to parse dmesg for test output and print out results in the same familiar format that ``kunit.py run`` does.”h]”(hŒ You can use ”…”�”}”(hjºh²hh³Nh´Nubhé)�”}”(hŒ``kunit.py parse``”h]”hŒkunit.py parse”…”�”}”(hjÂh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjºubhŒW to parse dmesg for test output and print out results in the same familiar format that ”…”�”}”(hjºh²hh³Nh´Nubhé)�”}”(hŒ``kunit.py run``”h]”hŒ kunit.py run”…”�”}”(hjÔh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjºubhŒ does.”…”�”}”(hjºh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kãhj©h²hubj$)�”}”(hŒ5$ ./tools/testing/kunit/kunit.py parse /var/log/dmesg”h]”hŒ5$ ./tools/testing/kunit/kunit.py parse /var/log/dmesg”…”�”}”hjìsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´Kæhj©h²hubeh}”(h]”Œpretty-printing-results”ah ]”h"]”Œpretty-printing results”ah$]”h&]”uh1hÈhj°h²hh³hÇh´KáubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRetrieving per suite results”h]”hŒRetrieving per suite results”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjh²hh³hÇh´Kìubj)�”}”(hŒRegardless of how you're running your tests, you can enable ``CONFIG_KUNIT_DEBUGFS`` to expose per-suite TAP-formatted results:”h]”(hŒ>Regardless of how you’re running your tests, you can enable ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ``CONFIG_KUNIT_DEBUGFS``”h]”hŒCONFIG_KUNIT_DEBUGFS”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒ+ to expose per-suite TAP-formatted results:”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Kîhjh²hubj$)�”}”(hŒACONFIG_KUNIT=y CONFIG_KUNIT_EXAMPLE_TEST=m CONFIG_KUNIT_DEBUGFS=y”h]”hŒACONFIG_KUNIT=y CONFIG_KUNIT_EXAMPLE_TEST=m CONFIG_KUNIT_DEBUGFS=y”…”�”}”hj5sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œnone”j6}”uh1j#h³hÇh´Kñhjh²hubj)�”}”(hŒzThe results for each suite will be exposed under ``/sys/kernel/debug/kunit//results``. So using our example config:”h]”(hŒ1The results for each suite will be exposed under ”…”�”}”(hjEh²hh³Nh´Nubhé)�”}”(hŒ+``/sys/kernel/debug/kunit//results``”h]”hŒ'/sys/kernel/debug/kunit//results”…”�”}”(hjMh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjEubhŒ. So using our example config:”…”�”}”(hjEh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´K÷hjh²hubj$)�”}”(hXA$ modprobe kunit-example-test > /dev/null $ cat /sys/kernel/debug/kunit/example/results ... ... # After removing the module, the corresponding files will go away $ modprobe -r kunit-example-test $ cat /sys/kernel/debug/kunit/example/results /sys/kernel/debug/kunit/example/results: No such file or directory”h]”hXA$ modprobe kunit-example-test > /dev/null $ cat /sys/kernel/debug/kunit/example/results ... ... # After removing the module, the corresponding files will go away $ modprobe -r kunit-example-test $ cat /sys/kernel/debug/kunit/example/results /sys/kernel/debug/kunit/example/results: No such file or directory”…”�”}”hjesbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´Kûhjh²hubeh}”(h]”Œretrieving-per-suite-results”ah ]”h"]”Œretrieving per suite results”ah$]”h&]”uh1hÈhj°h²hh³hÇh´KìubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ Generating code coverage reports”h]”hŒ Generating code coverage reports”…”�”}”(hj€h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj}h²hh³hÇh´Mubj)�”}”(hŒCSee Documentation/dev-tools/gcov.rst for details on how to do this.”h]”hŒCSee Documentation/dev-tools/gcov.rst for details on how to do this.”…”�”}”(hjŽh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M hj}h²hubj)�”}”(hŒÁThe only vaguely KUnit-specific advice here is that you probably want to build your tests as modules. That way you can isolate the coverage from tests from other code executed during boot, e.g.”h]”hŒÁThe only vaguely KUnit-specific advice here is that you probably want to build your tests as modules. That way you can isolate the coverage from tests from other code executed during boot, e.g.”…”�”}”(hjœh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M hj}h²hubj$)�”}”(hŒx# Reset coverage counters before running the test. $ echo 0 > /sys/kernel/debug/gcov/reset $ modprobe kunit-example-test”h]”hŒx# Reset coverage counters before running the test. $ echo 0 > /sys/kernel/debug/gcov/reset $ modprobe kunit-example-test”…”�”}”hjªsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´Mhj}h²hubeh}”(h]”Œ generating-code-coverage-reports”ah ]”h"]”Œ generating code coverage reports”ah$]”h&]”uh1hÈhj°h²hh³hÇh´Mubeh}”(h]”Œrunning-tests-manually”ah ]”h"]”Œrunning tests manually”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´K›ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒTest Attributes and Filtering”h]”hŒTest Attributes and Filtering”…”�”}”(hjÍh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÊh²hh³hÇh´Mubj)�”}”(hŒ°Test suites and cases can be marked with test attributes, such as speed of test. These attributes will later be printed in test output and can be used to filter test execution.”h]”hŒ°Test suites and cases can be marked with test attributes, such as speed of test. These attributes will later be printed in test output and can be used to filter test execution.”…”�”}”(hjÛh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MhjÊh²hubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒMarking Test Attributes”h]”hŒMarking Test Attributes”…”�”}”(hjìh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjéh²hh³hÇh´Mubj)�”}”(hŒeTests are marked with an attribute by including a ``kunit_attributes`` object in the test definition.”h]”(hŒ2Tests are marked with an attribute by including a ”…”�”}”(hjúh²hh³Nh´Nubhé)�”}”(hŒ``kunit_attributes``”h]”hŒkunit_attributes”…”�”}”(hjh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjúubhŒ object in the test definition.”…”�”}”(hjúh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M hjéh²hubj)�”}”(hŒ‘Test cases can be marked using the ``KUNIT_CASE_ATTR(test_name, attributes)`` macro to define the test case instead of ``KUNIT_CASE(test_name)``.”h]”(hŒ#Test cases can be marked using the ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ*``KUNIT_CASE_ATTR(test_name, attributes)``”h]”hŒ&KUNIT_CASE_ATTR(test_name, attributes)”…”�”}”(hj"h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒ* macro to define the test case instead of ”…”�”}”(hjh²hh³Nh´Nubhé)�”}”(hŒ``KUNIT_CASE(test_name)``”h]”hŒKUNIT_CASE(test_name)”…”�”}”(hj4h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjubhŒ.”…”�”}”(hjh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M#hjéh²hubj$)�”}”(hŒÅstatic const struct kunit_attributes example_attr = { .speed = KUNIT_VERY_SLOW, }; static struct kunit_case example_test_cases[] = { KUNIT_CASE_ATTR(example_test, example_attr), };”h]”hŒÅstatic const struct kunit_attributes example_attr = { .speed = KUNIT_VERY_SLOW, }; static struct kunit_case example_test_cases[] = { KUNIT_CASE_ATTR(example_test, example_attr), };”…”�”}”hjLsbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œc”j6}”uh1j#h³hÇh´M&hjéh²hubj9)�”}”(hŒ–To mark a test case as slow, you can also use ``KUNIT_CASE_SLOW(test_name)``. This is a helpful macro as the slow attribute is the most commonly used.”h]”j)�”}”(hŒ–To mark a test case as slow, you can also use ``KUNIT_CASE_SLOW(test_name)``. This is a helpful macro as the slow attribute is the most commonly used.”h]”(hŒ.To mark a test case as slow, you can also use ”…”�”}”(hj`h²hh³Nh´Nubhé)�”}”(hŒ``KUNIT_CASE_SLOW(test_name)``”h]”hŒKUNIT_CASE_SLOW(test_name)”…”�”}”(hjhh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj`ubhŒJ. This is a helpful macro as the slow attribute is the most commonly used.”…”�”}”(hj`h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M1hj\ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hjéh²hh³hÇh´Nubj)�”}”(hŒ`Test suites can be marked with an attribute by setting the "attr" field in the suite definition.”h]”hŒdTest suites can be marked with an attribute by setting the “attrâ€� field in the suite definition.”…”�”}”(hj†h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M4hjéh²hubj$)�”}”(hŒºstatic const struct kunit_attributes example_attr = { .speed = KUNIT_VERY_SLOW, }; static struct kunit_suite example_test_suite = { ..., .attr = example_attr, };”h]”hŒºstatic const struct kunit_attributes example_attr = { .speed = KUNIT_VERY_SLOW, }; static struct kunit_suite example_test_suite = { ..., .attr = example_attr, };”…”�”}”hj”sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4jZj6}”uh1j#h³hÇh´M7hjéh²hubj9)�”}”(hXANot all attributes need to be set in a ``kunit_attributes`` object. Unset attributes will remain uninitialized and act as though the attribute is set to 0 or NULL. Thus, if an attribute is set to 0, it is treated as unset. These unset attributes will not be reported and may act as a default value for filtering purposes.”h]”j)�”}”(hXANot all attributes need to be set in a ``kunit_attributes`` object. Unset attributes will remain uninitialized and act as though the attribute is set to 0 or NULL. Thus, if an attribute is set to 0, it is treated as unset. These unset attributes will not be reported and may act as a default value for filtering purposes.”h]”(hŒ'Not all attributes need to be set in a ”…”�”}”(hj§h²hh³Nh´Nubhé)�”}”(hŒ``kunit_attributes``”h]”hŒkunit_attributes”…”�”}”(hj¯h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj§ubhX object. Unset attributes will remain uninitialized and act as though the attribute is set to 0 or NULL. Thus, if an attribute is set to 0, it is treated as unset. These unset attributes will not be reported and may act as a default value for filtering purposes.”…”�”}”(hj§h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MChj£ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hjéh²hh³hÇh´Nubeh}”(h]”Œmarking-test-attributes”ah ]”h"]”Œmarking test attributes”ah$]”h&]”uh1hÈhjÊh²hh³hÇh´MubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒReporting Attributes”h]”hŒReporting Attributes”…”�”}”(hjØh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhjÕh²hh³hÇh´MJubj)�”}”(hX]When a user runs tests, attributes will be present in the raw kernel output (in KTAP format). Note that attributes will be hidden by default in kunit.py output for all passing tests but the raw kernel output can be accessed using the ``--raw_output`` flag. This is an example of how test attributes for test cases will be formatted in kernel output:”h]”(hŒêWhen a user runs tests, attributes will be present in the raw kernel output (in KTAP format). Note that attributes will be hidden by default in kunit.py output for all passing tests but the raw kernel output can be accessed using the ”…”�”}”(hjæh²hh³Nh´Nubhé)�”}”(hŒ``--raw_output``”h]”hŒ --raw_output”…”�”}”(hjîh²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjæubhŒc flag. This is an example of how test attributes for test cases will be formatted in kernel output:”…”�”}”(hjæh²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MLhjÕh²hubj$)�”}”(hŒ,# example_test.speed: slow ok 1 example_test”h]”hŒ,# example_test.speed: slow ok 1 example_test”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œnone”j6}”uh1j#h³hÇh´MRhjÕh²hubj)�”}”(hŒ]This is an example of how test attributes for test suites will be formatted in kernel output:”h]”hŒ]This is an example of how test attributes for test suites will be formatted in kernel output:”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MWhjÕh²hubj$)�”}”(hŒj KTAP version 2 # Subtest: example_suite # module: kunit_example_test 1..3 ... ok 1 example_suite”h]”hŒj KTAP version 2 # Subtest: example_suite # module: kunit_example_test 1..3 ... ok 1 example_suite”…”�”}”hj$ sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œnone”j6}”uh1j#h³hÇh´MZhjÕh²hubj)�”}”(hŒ‰Additionally, users can output a full attribute report of tests with their attributes, using the command line flag ``--list_tests_attr``:”h]”(hŒsAdditionally, users can output a full attribute report of tests with their attributes, using the command line flag ”…”�”}”(hj4 h²hh³Nh´Nubhé)�”}”(hŒ``--list_tests_attr``”h]”hŒ--list_tests_attr”…”�”}”(hj< h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj4 ubhŒ:”…”�”}”(hj4 h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MchjÕh²hubj$)�”}”(hŒ(kunit.py run "example" --list_tests_attr”h]”hŒ(kunit.py run "example" --list_tests_attr”…”�”}”hjT sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´MfhjÕh²hubj9)�”}”(hŒrThis report can be accessed when running KUnit manually by passing in the module_param ``kunit.action=list_attr``.”h]”j)�”}”(hŒrThis report can be accessed when running KUnit manually by passing in the module_param ``kunit.action=list_attr``.”h]”(hŒWThis report can be accessed when running KUnit manually by passing in the module_param ”…”�”}”(hjh h²hh³Nh´Nubhé)�”}”(hŒ``kunit.action=list_attr``”h]”hŒkunit.action=list_attr”…”�”}”(hjp h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjh ubhŒ.”…”�”}”(hjh h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Mkhjd ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hjÕh²hh³hÇh´Nubeh}”(h]”Œreporting-attributes”ah ]”h"]”Œreporting attributes”ah$]”h&]”uh1hÈhjÊh²hh³hÇh´MJubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒ Filtering”h]”hŒ Filtering”…”�”}”(hj™ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj– h²hh³hÇh´Moubj)�”}”(hŒbUsers can filter tests using the ``--filter`` command line flag when running tests. As an example:”h]”(hŒ!Users can filter tests using the ”…”�”}”(hj§ h²hh³Nh´Nubhé)�”}”(hŒ ``--filter``”h]”hŒ--filter”…”�”}”(hj¯ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj§ ubhŒ5 command line flag when running tests. As an example:”…”�”}”(hj§ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Mqhj– h²hubj$)�”}”(hŒ kunit.py run --filter speed=slow”h]”hŒ kunit.py run --filter speed=slow”…”�”}”hjÇ sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´Mthj– h²hubj)�”}”(hŒcYou can also use the following operations on filters: "<", ">", "<=", ">=", "!=", and "=". Example:”h]”hŒ{You can also use the following operations on filters: “<â€�, “>â€�, “<=â€�, “>=â€�, “!=â€�, and “=â€�. Example:”…”�”}”(hj× h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´Myhj– h²hubj$)�”}”(hŒ"kunit.py run --filter "speed>slow"”h]”hŒ"kunit.py run --filter "speed>slow"”…”�”}”hjå sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´M|hj– h²hubj)�”}”(hŒ¶This example will run all tests with speeds faster than slow. Note that the characters < and > are often interpreted by the shell, so they may need to be quoted or escaped, as above.”h]”hŒ¶This example will run all tests with speeds faster than slow. Note that the characters < and > are often interpreted by the shell, so they may need to be quoted or escaped, as above.”…”�”}”(hjõ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M€hj– h²hubj)�”}”(hŒbAdditionally, you can use multiple filters at once. Simply separate filters using commas. Example:”h]”hŒbAdditionally, you can use multiple filters at once. Simply separate filters using commas. Example:”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M„hj– h²hubj$)�”}”(hŒ=kunit.py run --filter "speed>slow, module=kunit_example_test"”h]”hŒ=kunit.py run --filter "speed>slow, module=kunit_example_test"”…”�”}”hj sbah}”(h]”h ]”h"]”h$]”h&]”hÅhÆj3‰j4Œbash”j6}”uh1j#h³hÇh´M‡hj– h²hubj9)�”}”(hŒ•You can use this filtering feature when running KUnit manually by passing the filter as a module param: ``kunit.filter="speed>slow, speed<=normal"``.”h]”j)�”}”(hŒ•You can use this filtering feature when running KUnit manually by passing the filter as a module param: ``kunit.filter="speed>slow, speed<=normal"``.”h]”(hŒhYou can use this filtering feature when running KUnit manually by passing the filter as a module param: ”…”�”}”(hj% h²hh³Nh´Nubhé)�”}”(hŒ,``kunit.filter="speed>slow, speed<=normal"``”h]”hŒ(kunit.filter="speed>slow, speed<=normal"”…”�”}”(hj- h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj% ubhŒ.”…”�”}”(hj% h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MŒhj! ubah}”(h]”h ]”h"]”h$]”h&]”uh1j8hj– h²hh³hÇh´Nubj)�”}”(hX7Filtered tests will not run or show up in the test output. You can use the ``--filter_action=skip`` flag to skip filtered tests instead. These tests will be shown in the test output in the test but will not run. To use this feature when running KUnit manually, use the module param ``kunit.filter_action=skip``.”h]”(hŒKFiltered tests will not run or show up in the test output. You can use the ”…”�”}”(hjK h²hh³Nh´Nubhé)�”}”(hŒ``--filter_action=skip``”h]”hŒ--filter_action=skip”…”�”}”(hjS h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjK ubhŒ· flag to skip filtered tests instead. These tests will be shown in the test output in the test but will not run. To use this feature when running KUnit manually, use the module param ”…”�”}”(hjK h²hh³Nh´Nubhé)�”}”(hŒ``kunit.filter_action=skip``”h]”hŒkunit.filter_action=skip”…”�”}”(hje h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhjK ubhŒ.”…”�”}”(hjK h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M�hj– h²hubeh}”(h]”Œ filtering”ah ]”h"]”Œ filtering”ah$]”h&]”uh1hÈhjÊh²hh³hÇh´MoubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒRules of Filtering Procedure”h]”hŒRules of Filtering Procedure”…”�”}”(hjˆ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj… h²hh³hÇh´M•ubj)�”}”(hŒŸSince both suites and test cases can have attributes, there may be conflicts between attributes during filtering. The process of filtering follows these rules:”h]”hŒŸSince both suites and test cases can have attributes, there may be conflicts between attributes during filtering. The process of filtering follows these rules:”…”�”}”(hj– h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M—hj… h²hubhŒ bullet_list”“”)�”}”(hhh]”(hŒ list_item”“”)�”}”(hŒ/Filtering always operates at a per-test level. ”h]”j)�”}”(hŒ.Filtering always operates at a per-test level.”h]”hŒ.Filtering always operates at a per-test level.”…”�”}”(hj¯ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M›hj« ubah}”(h]”h ]”h"]”h$]”h&]”uh1j© hj¦ h²hh³hÇh´Nubjª )�”}”(hŒFIf a test has an attribute set, then the test's value is filtered on. ”h]”j)�”}”(hŒEIf a test has an attribute set, then the test's value is filtered on.”h]”hŒGIf a test has an attribute set, then the test’s value is filtered on.”…”�”}”(hjÇ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M�hjà ubah}”(h]”h ]”h"]”h$]”h&]”uh1j© hj¦ h²hh³hÇh´Nubjª )�”}”(hŒ6Otherwise, the value falls back to the suite's value. ”h]”j)�”}”(hŒ5Otherwise, the value falls back to the suite's value.”h]”hŒ7Otherwise, the value falls back to the suite’s value.”…”�”}”(hjß h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´MŸhjÛ ubah}”(h]”h ]”h"]”h$]”h&]”uh1j© hj¦ h²hh³hÇh´Nubjª )�”}”(hŒOIf neither are set, the attribute has a global "default" value, which is used. ”h]”j)�”}”(hŒNIf neither are set, the attribute has a global "default" value, which is used.”h]”hŒRIf neither are set, the attribute has a global “defaultâ€� value, which is used.”…”�”}”(hj÷ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M¡hjó ubah}”(h]”h ]”h"]”h$]”h&]”uh1j© hj¦ h²hh³hÇh´Nubeh}”(h]”h ]”h"]”h$]”h&]”Œbullet”Œ-”uh1j¤ h³hÇh´M›hj… h²hubeh}”(h]”Œrules-of-filtering-procedure”ah ]”h"]”Œrules of filtering procedure”ah$]”h&]”uh1hÈhjÊh²hh³hÇh´M•ubhÉ)�”}”(hhh]”(hÎ)�”}”(hŒList of Current Attributes”h]”hŒList of Current Attributes”…”�”}”(hj h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÍhj h²hh³hÇh´M¤ubj)�”}”(hŒ ``speed``”h]”hé)�”}”(hj. h]”hŒspeed”…”�”}”(hj0 h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj, ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M¦hj h²hubj)�”}”(hŒXThis attribute indicates the speed of a test's execution (how slow or fast the test is).”h]”hŒZThis attribute indicates the speed of a test’s execution (how slow or fast the test is).”…”�”}”(hjC h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M¨hj h²hubj)�”}”(hXaThis attribute is saved as an enum with the following categories: "normal", "slow", or "very_slow". The assumed default speed for tests is "normal". This indicates that the test takes a relatively trivial amount of time (less than 1 second), regardless of the machine it is running on. Any test slower than this could be marked as "slow" or "very_slow".”h]”hXyThis attribute is saved as an enum with the following categories: “normalâ€�, “slowâ€�, or “very_slowâ€�. The assumed default speed for tests is “normalâ€�. This indicates that the test takes a relatively trivial amount of time (less than 1 second), regardless of the machine it is running on. Any test slower than this could be marked as “slowâ€� or “very_slowâ€�.”…”�”}”(hjQ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M«hj h²hubj)�”}”(hŒfThe macro ``KUNIT_CASE_SLOW(test_name)`` can be easily used to set the speed of a test case to "slow".”h]”(hŒ The macro ”…”�”}”(hj_ h²hh³Nh´Nubhé)�”}”(hŒ``KUNIT_CASE_SLOW(test_name)``”h]”hŒKUNIT_CASE_SLOW(test_name)”…”�”}”(hjg h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj_ ubhŒB can be easily used to set the speed of a test case to “slowâ€�.”…”�”}”(hj_ h²hh³Nh´Nubeh}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M±hj h²hubj)�”}”(hŒ ``module``”h]”hé)�”}”(hj� h]”hŒmodule”…”�”}”(hjƒ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M´hj h²hubj)�”}”(hŒIThis attribute indicates the name of the module associated with the test.”h]”hŒIThis attribute indicates the name of the module associated with the test.”…”�”}”(hj– h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M¶hj h²hubj)�”}”(hŒ�This attribute is automatically saved as a string and is printed for each suite. Tests can also be filtered using this attribute.”h]”hŒ�This attribute is automatically saved as a string and is printed for each suite. Tests can also be filtered using this attribute.”…”�”}”(hj¤ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M¸hj h²hubj)�”}”(hŒ ``is_init``”h]”hé)�”}”(hj´ h]”hŒis_init”…”�”}”(hj¶ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hèhj² ubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M»hj h²hubj)�”}”(hŒFThis attribute indicates whether the test uses init data or functions.”h]”hŒFThis attribute indicates whether the test uses init data or functions.”…”�”}”(hjÉ h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M½hj h²hubj)�”}”(hŒgThis attribute is automatically saved as a boolean and tests can also be filtered using this attribute.”h]”hŒgThis attribute is automatically saved as a boolean and tests can also be filtered using this attribute.”…”�”}”(hj× h²hh³Nh´Nubah}”(h]”h ]”h"]”h$]”h&]”uh1jh³hÇh´M¿hj h²hubeh}”(h]”Œlist-of-current-attributes”ah ]”h"]”Œlist of current attributes”ah$]”h&]”uh1hÈhjÊh²hh³hÇh´M¤ubeh}”(h]”Œtest-attributes-and-filtering”ah ]”h"]”Œtest attributes and filtering”ah$]”h&]”uh1hÈhhÊh²hh³hÇh´Mubeh}”(h]”Œtips-for-running-kunit-tests”ah ]”h"]”Œtips for running kunit tests”ah$]”h&]”uh1hÈhhh²hh³hÇh´Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”hÇuh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)�”}”(hÍNŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”j Œerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”hÇŒ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jú j÷ j­jªj{jxj>j;jkjhj´j±j¥j¢jÇjÄj…j‚j¦j£jjþjzjwj¿j¼jò jï jÒjÏj“ j� j‚ j j j jê jç uŒ nametypes”}”(jú ‰j­‰j{‰j>‰jk‰j´‰j¥‰jljj…‰j¦‰j‰jz‰j¿‰jò ‰jÒ‰j“ ‰j‚ ‰j ‰jê ‰uh}”(j÷ hÊjªhÝjxjj;j~jhjAj±jnj¢j·jÄj°j‚jj£jˆjþj©jwjj¼j}jï jÊjÏjéj� jÕj j– j j… jç j uŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nh²hub.