From 1c95e12b0dd2b4902a289328e8e54fde6eed0623 Mon Sep 17 00:00:00 2001 From: Dave Wallace Date: Wed, 21 Jun 2023 23:14:38 -0400 Subject: tests docs: fix lcov code coverage report generation - Updated/rebased version of https://gerrit.fd.io/r/c/vpp/+/34199 Type: test Change-Id: I43913ecfd11a4578bdb10c4be76253fe38d57976 Signed-off-by: Nathan Skrzypczak Signed-off-by: Dave Wallace --- docs/developer/build-run-debug/code_coverage.rst | 45 ++++++++++++++++++++++++ docs/developer/build-run-debug/index.rst | 1 + docs/developer/extras/index.rst | 1 - docs/developer/extras/lcov.rst | 1 - docs/spelling_wordlist.txt | 1 - 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 docs/developer/build-run-debug/code_coverage.rst delete mode 120000 docs/developer/extras/lcov.rst (limited to 'docs') diff --git a/docs/developer/build-run-debug/code_coverage.rst b/docs/developer/build-run-debug/code_coverage.rst new file mode 100644 index 00000000000..efe750cda21 --- /dev/null +++ b/docs/developer/build-run-debug/code_coverage.rst @@ -0,0 +1,45 @@ +.. _lcov_code_coverage: + +Code coverage with lcov +======================= + +Prerequisites +------------- + +Ensure required packages are installed: + +:: + + $ make install-deps + +The Linux gcov and lcov tools can be fussy about gcc / g++ compiler +versions. As of this writing, Ubuntu 22.04 gcov / lcov works with +the latest gcc version (``11.3.0``). + +Generate coverage for a test case +--------------------------------- + +As a first run, in order to generate the coverage report of +a specific plugin or test, run for example + +:: + + $ make test-cov TEST=fib + +Then open the file ``.build-root/test-coverage/html/index.html`` in a Chrome browser. + +Improving test coverage +----------------------- + +When doing modifications on the test cases, you can run + +:: + + # This will run the test & report the result in the coverage data + $ make test-cov-build TEST=fib + + # This will generate the html report with the current coverage data + $ make test-cov-post + + # To reset the coverage data use + $ make test-cov-prep diff --git a/docs/developer/build-run-debug/index.rst b/docs/developer/build-run-debug/index.rst index f8bfeab0bf8..c99615ffcf5 100644 --- a/docs/developer/build-run-debug/index.rst +++ b/docs/developer/build-run-debug/index.rst @@ -12,3 +12,4 @@ Build, Run & Debug testing_vpp gdb_examples cross_compile_macos + code_coverage diff --git a/docs/developer/extras/index.rst b/docs/developer/extras/index.rst index a0f2d9b876a..2ee96be768e 100644 --- a/docs/developer/extras/index.rst +++ b/docs/developer/extras/index.rst @@ -7,7 +7,6 @@ VPP extra tools .. toctree:: :maxdepth: 2 - lcov snap strongswan vpp_config diff --git a/docs/developer/extras/lcov.rst b/docs/developer/extras/lcov.rst deleted file mode 120000 index 9f8de245ea6..00000000000 --- a/docs/developer/extras/lcov.rst +++ /dev/null @@ -1 +0,0 @@ -../../../extras/lcov/README.rst \ No newline at end of file diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 80db33a354e..d28c6df56ca 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -397,7 +397,6 @@ Gerrit gethostbyname gettingsources gettingstarted -ggcov gid Gigabit GigE -- cgit 1.2.3-korg