• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python test_configuration.create_scope函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中vunit.test_configuration.create_scope函数的典型用法代码示例。如果您正苦于以下问题:Python create_scope函数的具体用法?Python create_scope怎么用?Python create_scope使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了create_scope函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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"])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:31,代码来源:test_test_scanner.py


示例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"))])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:28,代码来源:test_test_configuration.py


示例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))
开发者ID:gitter-badger,项目名称:vunit,代码行数:60,代码来源:test_scanner.py


示例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"})])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:16,代码来源:test_test_configuration.py


示例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())
开发者ID:darwinbeing,项目名称:vunit,代码行数:7,代码来源:ui.py


示例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
开发者ID:darwinbeing,项目名称:vunit,代码行数:26,代码来源:test_scanner.py


示例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)])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:17,代码来源:test_test_configuration.py


示例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"])])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:17,代码来源:test_test_configuration.py


示例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)])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:22,代码来源:test_test_configuration.py


示例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)])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:13,代码来源:test_test_configuration.py


示例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())
开发者ID:darwinbeing,项目名称:vunit,代码行数:15,代码来源:ui.py


示例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())
开发者ID:darwinbeing,项目名称:vunit,代码行数:15,代码来源:ui.py


示例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])
开发者ID:KevinKes,项目名称:vunit,代码行数:16,代码来源:test_test_scanner.py


示例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)])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:18,代码来源:test_test_configuration.py


示例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"))])
开发者ID:KevinKes,项目名称:vunit,代码行数:22,代码来源:test_test_scanner.py


示例16: disable_ieee_warnings

 def disable_ieee_warnings(self):
     """
     Globally disable ieee warnings
     """
     self._configuration.disable_ieee_warnings(scope=create_scope())
开发者ID:varunnagpaal,项目名称:vunit,代码行数:5,代码来源:ui.py


示例17: set_pli

 def set_pli(self, value):
     """
     Globally set pli
     """
     self._configuration.set_pli(value, scope=create_scope())
开发者ID:varunnagpaal,项目名称:vunit,代码行数:5,代码来源:ui.py


示例18: set_sim_option

 def set_sim_option(self, name, value):
     """
     Globally set simulation option
     """
     self._configuration.set_sim_option(name, value, scope=create_scope())
开发者ID:varunnagpaal,项目名称:vunit,代码行数:5,代码来源:ui.py


示例19: set_generic

 def set_generic(self, name, value):
     """
     Globally set generic
     """
     self._configuration.set_generic(name.lower(), value, scope=create_scope())
开发者ID:varunnagpaal,项目名称:vunit,代码行数:5,代码来源:ui.py


示例20: test_more_specific_configurations

 def test_more_specific_configurations(self):
     self.cfg.set_generic("name", "value", scope=create_scope("lib", "entity3"))
     self.cfg.set_generic("name", "value", scope=create_scope("lib", "entity", "test"))
     self.cfg.disable_ieee_warnings(scope=create_scope("lib", "entity_ieee", "test"))
     self.cfg.add_config(name="name", generics=dict(), scope=create_scope("lib", "entity2", "test"))
     self.cfg.set_sim_option("vsim_extra_args", "", scope=create_scope("lib", "entity4", "test"))
     self.assertEqual(self.cfg.more_specific_configurations(create_scope("lib", "entity")),
                      [create_scope("lib", "entity", "test")])
     self.assertEqual(self.cfg.more_specific_configurations(create_scope("lib", "entity2")),
                      [create_scope("lib", "entity2", "test")])
     self.assertEqual(self.cfg.more_specific_configurations(create_scope("lib", "entity3")),
                      [])
     self.assertEqual(self.cfg.more_specific_configurations(create_scope("lib", "entity4")),
                      [create_scope("lib", "entity4", "test")])
     self.assertEqual(self.cfg.more_specific_configurations(create_scope("lib", "entity_ieee")),
                      [create_scope("lib", "entity_ieee", "test")])
开发者ID:varunnagpaal,项目名称:vunit,代码行数:16,代码来源:test_test_configuration.py



注:本文中的vunit.test_configuration.create_scope函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python vhdl_parser.VHDLDesignFile类代码示例发布时间:2022-05-26
下一篇:
Python project.Project类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap