Skip to content

Commit

Permalink
Merge pull request VUnit#488 from dbhi/feat-sim-check
Browse files Browse the repository at this point in the history
Add method simulator_check to test/common.py
  • Loading branch information
kraigher authored Apr 25, 2019
2 parents 3a3a6a8 + 1c199fb commit 9ae0ae0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions vunit/ghdl_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ def determine_backend(cls, prefix):
print("=============================" + ("=" * 60))
raise AssertionError("No known GHDL back-end could be detected from running 'ghdl --version'")

@classmethod
def supports_vhpi(cls):
"""
Return if the simulator supports VHPI
"""
return cls.determine_backend(cls.find_prefix_from_path()) != "mcode"

def _has_output_flag(self):
"""
Returns if backend supports output flag
Expand Down
9 changes: 8 additions & 1 deletion vunit/simulator_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from vunit.color_printer import NO_COLOR_PRINTER


class SimulatorInterface(object):
class SimulatorInterface(object): # pylint: disable=too-many-public-methods
"""
Generic simulator interface
"""
Expand Down Expand Up @@ -145,6 +145,13 @@ def has_valid_exit_code():
"""
return False

@staticmethod
def supports_vhpi():
"""
Return if the simulator supports VHPI
"""
return False

def merge_coverage(self, file_name, args): # pylint: disable=unused-argument, no-self-use
"""
Hook for simulator interface to creating coverage reports
Expand Down
10 changes: 10 additions & 0 deletions vunit/test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ def simulator_is(*names):
return SIMULATOR_FACTORY.select_simulator().name in names


def simulator_check(func):
"""
Check some method of the selected simulator
"""
simif = SIMULATOR_FACTORY.select_simulator()
if simif is None:
return False
return func(simif)


def check_report(report_file, tests=None):
"""
Check an XML report_file for the exact occurrence of specific test results
Expand Down

0 comments on commit 9ae0ae0

Please sign in to comment.