Okay, I was able to find a workaround.
I changed the following inside the main CMakeLists.txt inside my Wireshark 3.2.4 root directory and rebuild Wireshark:
Line 500 (add code coverage compiler flags; changed extension from *.c.gcno to *.gcno):
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
Line 750 (Added -lgcov for GCOV and LCOV integration):
set(WIRESHARK_LD_FLAGS
# See also CheckCLinkerFlag.cmake
-Wl,--as-needed
# -flto
# -fwhopr
# -fwhole-program
-lgcov
)
*.gcda and *.gcno file location in Ubuntu:
/*/build-ninja/plugins/epan/dissector_name/CMakeFiles/dissector_name.dir/
Evaluation commands:
local@vxu-1804: ~/*/build-ninja
lcov -c -d . -o coverage.lcov
mkdir lcov-output
genhtml -o lcov-output/ coverage.lcov
or with source error ignoration:
genhtml –ignore-errors source -o lcov-output/ coverage.lcov
Maybe this helps someone else.
Is this a good way, or is there a better/preferred way to do it?
Von: Wireshark-dev <wireshark-dev-bounces@xxxxxxxxxxxxx>
Im Auftrag von Peimann, Jannis
Gesendet: Montag, 27. Juli 2020 13:07
An: wireshark-dev@xxxxxxxxxxxxx
Betreff: [Wireshark-dev] Code Coverage Measurement of Wireshark - Outdated Instruction
Hello together,
I created a small Dissector that I want to test now.
Therefore I tried the Code Coverage Measurement from the Wireshark Wiki Page but ran into some issues.
At first I have seen, that this page was updated the last time in 2008. (wiki.wireshark.org/Development/CodeCoverage)
These steps are not valid anymore:
~/wireshark$ ./autogen.sh
~/wireshark$ ./configure CFLAGS=--coverage [options]
Starting with Wireshark 3.0.0, autotools is no longer supported, only cmake. – According to this thread: Missing autogen.sh in 3.0.0 (Ask Wireshark Thread)
Could someone please update that Wiki entry or/and explain to me how I can achieve this with CMake?
Unfortunately I am not able to create *.gcno files with CMake.
I guess some commands are different and I maybe have to change some CMake Configuration Files.
For your interest, I use Ubuntu.
GCC Version is 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
I tried this already but no *.gcno files were created:
make clean && make CFLAGS=--coverage LDFLAGS=--coverage
Thanks in advance for your help.
Best regards,
Jannis Peimann