Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kunit: add coverage_uml.config to enable GCOV on UML

Now that kunit.py's --kunitconfig is repeatable, let's create a file to
hold the various options needed to enable coverage under UML.

This can be used like so:
$ ./tools/testing/kunit/kunit.py run \
--kunitconfig=tools/testing/kunit/configs/all_tests_uml.config \
--kunitconfig=tools/testing/kunit/configs/coverage_uml.config \
--make_options=CC=/usr/bin/gcc-6

which on my system is enough to get coverage working [1].

This is still a clunky command, but far better than before.

[1] at the time of this commit, I get:
Overall coverage rate:
lines......: 11.6% (34112 of 295033 lines)
functions..: 15.3% (3721 of 24368 functions)

Signed-off-by: Daniel Latypov <dlatypov@google.com>
Reviewed-by: David Gow <davidgow@google.com>
Reviewed-by: Brendan Higgins <brendanhiggins@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Daniel Latypov and committed by
Shuah Khan
1d202d14 8a7c6f85

+12 -2
+1 -2
Documentation/dev-tools/kunit/running_tips.rst
··· 123 123 .. code-block:: bash 124 124 125 125 # Append coverage options to the current config 126 - $ echo -e "CONFIG_DEBUG_KERNEL=y\nCONFIG_DEBUG_INFO=y\nCONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y\nCONFIG_GCOV=y" >> .kunit/.kunitconfig 127 - $ ./tools/testing/kunit/kunit.py run 126 + $ ./tools/testing/kunit/kunit.py run --kunitconfig=.kunit/ --kunitconfig=tools/testing/kunit/configs/coverage_uml.config 128 127 # Extract the coverage information from the build dir (.kunit/) 129 128 $ lcov -t "my_kunit_tests" -o coverage.info -c -d .kunit/ 130 129
+11
tools/testing/kunit/configs/coverage_uml.config
··· 1 + # This config fragment enables coverage on UML, which is different from the 2 + # normal gcov used in other arches (no debugfs). 3 + # Example usage: 4 + # ./tools/testing/kunit/kunit.py run \ 5 + # --kunitconfig=tools/testing/kunit/configs/all_tests_uml.config \ 6 + # --kunitconfig=tools/testing/kunit/configs/coverage_uml.config 7 + 8 + CONFIG_DEBUG_KERNEL=y 9 + CONFIG_DEBUG_INFO=y 10 + CONFIG_DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT=y 11 + CONFIG_GCOV=y