本文整理汇总了Python中vunit.test_configuration.create_scope函数的典型用法代码示例。如果您正苦于以下问题:Python create_scope函数的具体用法?Python create_scope怎么用?Python create_scope使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了create_scope函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_warning_on_configuration_of_non_existent_test
def test_warning_on_configuration_of_non_existent_test(self, mock_logger):
project = ProjectStub()
lib = project.add_library("lib")
ent = lib.add_entity("tb_entity",
generic_names=["runner_cfg", "name"])
ent.set_contents('if run("Test")')
test_scope = create_scope("lib", "tb_entity", "Test")
self.configuration.set_generic("name", "value",
scope=test_scope)
test_1_scope = create_scope("lib", "tb_entity", "No test 1")
self.configuration.add_config(scope=test_1_scope,
name="",
generics=dict())
test_2_scope = create_scope("lib", "tb_entity", "No test 2")
self.configuration.set_generic("name", "value",
scope=test_2_scope)
tests = self.test_scanner.from_project(project)
warning_calls = mock_logger.warning.call_args_list
self.assertEqual(len(warning_calls), 2)
call_args0 = warning_calls[0][0]
call_args1 = warning_calls[1][0]
self.assertIn(dotjoin(*test_1_scope), call_args0)
self.assertIn(dotjoin(*test_2_scope), call_args1)
self.assert_has_tests(tests,
["lib.tb_entity.Test"])
示例2: test_add_config
def test_add_config(self):
for value in range(1, 3):
self.cfg.add_config(scope=create_scope("lib", "tb_entity"),
name="value=%i" % value,
generics=dict(value=value,
global_value="local value"))
self.cfg.add_config(scope=create_scope("lib", "tb_entity", "configured test"),
name="specific_test_config",
generics=dict())
# Local value should take precedence
self.cfg.set_generic("global_value", "global value")
self.assertEqual(self.cfg.get_configurations(create_scope("lib", "tb_entity")),
[cfg("value=1",
generics={"value": 1, "global_value": "local value"}),
cfg("value=2",
generics={"value": 2, "global_value": "local value"})])
self.assertEqual(self.cfg.get_configurations(create_scope("lib", "tb_entity", "test")),
[cfg("value=1",
generics={"value": 1, "global_value": "local value"}),
cfg("value=2",
generics={"value": 2, "global_value": "local value"})])
self.assertEqual(self.cfg.get_configurations(create_scope("lib", "tb_entity", "configured test")),
[cfg("specific_test_config", dict(global_value="global value"))])
示例3: _create_tests_from_unit
def _create_tests_from_unit(self, test_list, entity, architecture_name, verilog=False):
"""
Derive test cases from an unit
"""
has_runner_cfg = verilog or ("runner_cfg" in entity.generic_names)
pragmas, run_strings = self._parse(entity, architecture_name, verilog)
should_run_in_same_sim = "run_all_in_same_sim" in pragmas
def create_test_bench(config):
"""
Helper function to create a test bench
"""
fail_on_warning = "fail_on_warning" in pragmas
return self._create_test_bench(entity, architecture_name, config, fail_on_warning, verilog)
def create_name(config, run_string=None):
"""
Helper function to create a test name
"""
return create_test_name(entity, architecture_name, config.name, run_string)
self._warn_on_individual_configuration(create_scope(entity.library_name, entity.name),
run_strings,
should_run_in_same_sim)
if len(run_strings) == 0 or not has_runner_cfg:
scope = create_scope(entity.library_name, entity.name)
configurations = self._cfg.get_configurations(scope)
for config in configurations:
test_list.add_test(
IndependentSimTestCase(
name=create_name(config),
test_case=None,
test_bench=create_test_bench(config),
has_runner_cfg=has_runner_cfg,
pre_config=config.pre_config,
post_check=config.post_check))
elif should_run_in_same_sim:
scope = create_scope(entity.library_name, entity.name)
configurations = self._cfg.get_configurations(scope)
for config in configurations:
test_list.add_suite(
SameSimTestSuite(name=create_name(config),
test_cases=run_strings,
test_bench=create_test_bench(config),
pre_config=config.pre_config,
post_check=config.post_check))
else:
for run_string in run_strings:
scope = create_scope(entity.library_name, entity.name, run_string)
configurations = self._cfg.get_configurations(scope)
for config in configurations:
test_list.add_test(
IndependentSimTestCase(
name=create_name(config, run_string),
test_case=run_string,
test_bench=create_test_bench(config),
has_runner_cfg=has_runner_cfg,
pre_config=config.pre_config,
post_check=config.post_check))
示例4: test_set_generic
def test_set_generic(self):
scope = create_scope("lib", "tb_entity")
self.assertEqual(self.cfg.get_configurations(scope),
[cfg()])
self.cfg.set_generic("global_generic", "global", scope=create_scope())
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(generics={"global_generic": "global"})])
self.cfg.set_generic("global_generic", "library", scope=create_scope("lib"))
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(generics={"global_generic": "library"})])
self.cfg.set_generic("global_generic", "entity", scope=create_scope("lib", "tb_entity"))
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(generics={"global_generic": "entity"})])
示例5: set_pli
def set_pli(self, value):
"""
Globally Set pli
:param value: A list of PLI object file names
"""
self._configuration.set_pli(value, scope=create_scope())
示例6: _parse
def _parse(self, entity, architecture_name, verilog):
"""
Parse file for run strings and pragmas
"""
scope = create_scope(entity.library_name, entity.name)
other_file = self._cfg.file_to_scan_for_tests(scope)
if other_file is not None:
file_name = other_file
verilog = file_type_of(other_file) == "verilog"
elif verilog:
file_name = entity.file_name
else:
file_name = entity.architecture_names[architecture_name]
code = ostools.read_file(file_name)
pragmas = self.find_pragmas(code, file_name)
# @TODO use presence of runner_cfg as tb_filter instead of tb_*
has_runner_cfg = verilog or ("runner_cfg" in entity.generic_names)
if has_runner_cfg:
run_strings = self.find_run_strings(code, file_name, verilog)
else:
run_strings = []
return pragmas, run_strings
示例7: test_sim_options
def test_sim_options(self):
scope = create_scope("lib", "entity")
sim_options = {"vsim_extra_args": "-voptargs=+acc"}
for name, value in sim_options.items():
self.cfg.set_sim_option(name=name,
value=value,
scope=scope)
self.assertEqual(self.cfg.get_configurations(create_scope("lib")),
[cfg()])
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(sim_options=sim_options)])
self.assertEqual(self.cfg.get_configurations(create_scope("lib", "entity", "test")),
[cfg(sim_options=sim_options)])
示例8: test_set_pli
def test_set_pli(self):
scope = create_scope("lib", "tb_entity")
self.assertEqual(self.cfg.get_configurations(scope),
[cfg("")])
self.cfg.set_pli(["libglobal.so"], scope=create_scope())
self.cfg.set_pli(["libfoo.so"], scope=create_scope("lib2"))
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(pli=["libglobal.so"])])
self.cfg.set_pli(["libfoo.so"], scope=create_scope("lib"))
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(pli=["libfoo.so"])])
self.cfg.set_pli(["libfoo2.so"], scope=create_scope("lib", "tb_entity"))
self.assertEqual(self.cfg.get_configurations(scope),
[cfg(pli=["libfoo2.so"])])
示例9: test_disable_ieee_warnings
def test_disable_ieee_warnings(self):
lib_scope = create_scope("lib")
ent_scope = create_scope("lib", "entity")
self.assertEqual(self.cfg.get_configurations(lib_scope),
[cfg(disable_ieee_warnings=False)])
self.assertEqual(self.cfg.get_configurations(ent_scope),
[cfg(disable_ieee_warnings=False)])
self.cfg.disable_ieee_warnings(ent_scope)
self.assertEqual(self.cfg.get_configurations(lib_scope),
[cfg(disable_ieee_warnings=False)])
self.assertEqual(self.cfg.get_configurations(ent_scope),
[cfg(disable_ieee_warnings=True)])
self.cfg.disable_ieee_warnings(lib_scope)
self.assertEqual(self.cfg.get_configurations(lib_scope),
[cfg(disable_ieee_warnings=True)])
self.assertEqual(self.cfg.get_configurations(ent_scope),
[cfg(disable_ieee_warnings=True)])
示例10: test_config_with_pre_config
def test_config_with_pre_config(self):
scope = create_scope("lib", "entity")
def pre_config():
return True
self.cfg.add_config(name="name",
generics=dict(),
pre_config=pre_config,
scope=scope)
self.assertEqual(self.cfg.get_configurations(scope),
[cfg("name", pre_config=pre_config)])
示例11: set_parameter
def set_parameter(self, name, value):
"""
Globally set value of parameter
:param name: The name of the parameter
:param value: The value of the parameter
:example:
.. code-block:: python
prj.set_parameter("data_width", 16)
"""
self._configuration.set_generic(name, value, scope=create_scope())
示例12: set_sim_option
def set_sim_option(self, name, value):
"""
Globally set simulation option
:param name: |simulation_options|
:param value: The value of the simulation option
:example:
.. code-block:: python
prj.set_sim_option("ghdl.flags", ["--no-vital-checks"])
"""
self._configuration.set_sim_option(name, value, scope=create_scope())
示例13: helper
def helper(config_name, suffix):
"""
Add config with name and check that the test has the given suffix
"""
project = ProjectStub()
lib = project.add_library("lib")
lib.add_entity("tb_entity",
generic_names=["runner_cfg"])
self.configuration = TestConfiguration()
self.test_scanner = TestScanner(self.simulator_if, self.configuration)
self.configuration.add_config(scope=create_scope("lib", "tb_entity"),
name=config_name,
generics=dict())
tests = self.test_scanner.from_project(project)
self.assert_has_tests(tests,
["lib.tb_entity" + suffix])
示例14: test_no_post_check_when_elaborate_only
def test_no_post_check_when_elaborate_only(self):
self.cfg = TestConfiguration(elaborate_only=True)
scope = create_scope("lib", "entity")
def pre_config():
return True
def post_check():
return True
self.cfg.add_config(name="name",
generics=dict(),
pre_config=pre_config,
post_check=post_check,
scope=scope)
self.assertEqual(self.cfg.get_configurations(scope),
[cfg("name", pre_config=pre_config, elaborate_only=True)])
示例15: test_warning_on_configuration_of_individual_test_with_same_sim
def test_warning_on_configuration_of_individual_test_with_same_sim(self, mock_logger):
project = ProjectStub()
lib = project.add_library("lib")
lib.add_entity("tb_entity",
generic_names=["runner_cfg"],
contents='''\
if run("Test 1")
if run("Test 2")
-- vunit_pragma run_all_in_same_sim
''')
test_scope = create_scope("lib", "tb_entity", "Test 1")
self.configuration.set_generic("name", "value", scope=test_scope)
tests = self.test_scanner.from_project(project)
warning_calls = mock_logger.warning.call_args_list
self.assertEqual(len(warning_calls), 1)
call_args = warning_calls[0][0]
self.assertIn(1, call_args)
self.assertIn("lib.tb_entity", call_args)
self.assert_has_tests(tests,
[("lib.tb_entity", ("lib.tb_entity.Test 1", "lib.tb_entity.Test 2"))])