Skip to content

Commit

Permalink
sanitycheck: support coverage with unit tests
Browse files Browse the repository at this point in the history
Fix setting coverage for unit tests and link against gcov when coverage
is enabled.

Fixes zephyrproject-rtos#24674

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information
nashif authored and hakehuang committed Jun 20, 2020
1 parent 315e54c commit ec19eb1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions scripts/sanity_chk/sanitylib.py
Original file line number Diff line number Diff line change
Expand Up @@ -1854,6 +1854,8 @@ def setup_handler(self):
elif instance.testcase.type == "unit":
instance.handler = BinaryHandler(instance, "unit")
instance.handler.binary = os.path.join(instance.build_dir, "testbinary")
if self.coverage:
args.append("COVERAGE=1")
elif instance.platform.type == "native":
handler = BinaryHandler(instance, "native")

Expand Down
4 changes: 4 additions & 0 deletions subsys/testsuite/unittest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ if(COVERAGE)
-fprofile-arcs
-ftest-coverage
)

target_link_libraries(testbinary PRIVATE
-lgcov
)
endif()

if(LIBS)
Expand Down

0 comments on commit ec19eb1

Please sign in to comment.