Skip to content

Commit

Permalink
support GHDL in example 'coverage'
Browse files Browse the repository at this point in the history
  • Loading branch information
eine committed Jan 25, 2020
1 parent 8ecaaf1 commit 3e16fc5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
22 changes: 16 additions & 6 deletions examples/vhdl/coverage/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,32 @@
# Copyright (c) 2014-2020, Lars Asplund lars.anders.asplund@gmail.com

from pathlib import Path
from os import getcwd
from vunit import VUnit


def post_run(results):
results.merge_coverage(file_name="coverage_data")

from subprocess import call

VU = VUnit.from_argv()

LIB = VU.add_library("lib")
LIB.add_source_files(Path(__file__).parent / "*.vhd")

LIB.set_sim_option("enable_coverage", True)

LIB.set_compile_option("rivierapro.vcom_flags", ["-coverage", "bs"])
LIB.set_compile_option("rivierapro.vlog_flags", ["-coverage", "bs"])
LIB.set_compile_option("modelsim.vcom_flags", ["+cover=bs"])
LIB.set_compile_option("modelsim.vlog_flags", ["+cover=bs"])
LIB.set_sim_option("enable_coverage", True)
LIB.set_compile_option("ghdl.flags", ["-g", "-O2", "-fprofile-arcs", "-ftest-coverage"])
LIB.set_sim_option("ghdl.elab_flags", ["-Wl,-lgcov", "-Wl,--coverage"])


def post_run(results):
if VU.get_simulator_name() != "ghdl":
results.merge_coverage(file_name="coverage_data")
try:
call(["gcovr", "-r", getcwd()])
except Exception:
pass


VU.main(post_run=post_run)
7 changes: 7 additions & 0 deletions tests/acceptance/test_external_run_scripts.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ def test_vhdl_third_party_integration_example_project(self):
def test_vhdl_check_example_project(self):
self.check(join(ROOT, "examples", "vhdl", "check", "run.py"))

@unittest.skipIf(
simulator_check(lambda simclass: not simclass.supports_coverage()),
"This simulator/backend does not support coverage",
)
def test_vhdl_coverage_example_project(self):
self.check(join(ROOT, "examples", "vhdl", "coverage", "run.py"))

def test_vhdl_generate_tests_example_project(self):
self.check(join(ROOT, "examples", "vhdl", "generate_tests", "run.py"))
check_report(
Expand Down

0 comments on commit 3e16fc5

Please sign in to comment.