Closed renjipanicker closed 3 years ago
Great approach, I hadn't thought of doing it this way, and the structure is clean!
Can you add documentation to firmware/ventilator-controller-stm32/README.md
introducing/describing this new TestCoverage
target and how to use it correctly? I'm not sure how to get the lcov report, and after running the following command from within firmware/ventilator-controller-stm32
I don't see an html report:
./cmake.sh TestCoverage; cd cmake-build-testcoverage; make -j8; ./TestCoverage; cd ..
Additionally, when I ran this above command I got the following warning from CMake:
CMake Warning at cmake/CodeCoverage.cmake:173 (message):
Code coverage results with an optimised (non-Debug) build may be misleading
Call Stack (most recent call first):
CMakeLists.txt:46(include)
I do see that lines 50-51 of CMakeLists.txt are manually setting -O0
as a flag; perhaps we need to add a few lines before line 25 of CMakeLists.txt to set the compile options in a way that CMake understands, something like:
elseif ("${CMAKE_BUILD_TYPE}" STREQUAL "TestCoverage")
message(STATUS "No optimization, debug info included")
add_compile_options(-O0 -g)
If we do this, can we remove the set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0"); set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
lines? And can we use add_compile_options
for all the other compile flags currently set via set(CMAKE_CXX_FLAGS
, namely -fno-inline -fno-inline-small-functions -fno-default-inline
?
I'm running CMake version 3.16.3.
The instructions for generating the LCOV report work for me! As discussed in meeting, let's update the CMakeLists file to do some things (setting message, compile options) for the TestCatch2 and TestCoverage build targets in the CMAKE_BUILD_TYPE if-elseif ladder at the top of the file, this will be ready to merge.
Another thing I just thought of: it'd be great if you could update .github/workfllows/firmware.yml to run another job to generate the code coverage report HTML files and upload them as a build artifact; you can refer to https://github.com/pez-globo/pufferfish-software/blob/2f56b711fb95d136e33e101ccfa4f7b4ba0b653b/.github/workflows/firmware.yml#L55 for an example of how I'm already using the actions/upload-artifact
action to upload something as a build artifact.
The instructions for generating the LCOV report work for me!
Great!
As discussed in meeting, let's update the CMakeLists file to do some things (setting message, compile options) for the TestCatch2 and TestCoverage build targets in the CMAKE_BUILD_TYPE if-elseif ladder at the top of the file, this will be ready to merge.
This is done, I've just checked in the code.
Another thing I just thought of: it'd be great if you could update .github/workfllows/firmware.yml to run another job to generate the code coverage report HTML files and upload them as a build artifact; you can refer to
https://github.com/pez-globo/pufferfish-software/blob/2f56b711fb95d136e33e101ccfa4f7b4ba0b653b/.github/workflows/firmware.yml#L55 for an example of how I'm already using the
actions/upload-artifact
action to upload something as a build artifact.
Sounds like a great idea! I'll do it.
@renjipanicker I see there's still an open branch in the repo named "hotfix/cmake-seperate-lcov". Since this PR, with a branch named "hotfix/cmake-separate-lcov" has been merged and that branch has been deleted, is it safe to delete the branch which is still open?
@renjipanicker I see there's still an open branch in the repo named "hotfix/cmake-seperate-lcov". Since this PR, with a branch named "hotfix/cmake-separate-lcov" has been merged and that branch has been deleted, is it safe to delete the branch which is still open?
@ethanjli Yes, please go ahead and delete that branch. Thanks.
Closes #284
Moves all optimization from TestCatch2 to new target TestCoverage