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 #24674

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
  • Loading branch information
nashif committed Apr 29, 2020
1 parent 1ed6a38 commit 051602f
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 051602f

Please sign in to comment.