def test_adds_tb_path_generic(self): design_unit = Entity('tb_entity_with_tb_path') design_unit.generic_names = ["runner_cfg"] config = Configuration('name', design_unit) design_unit_tb_path = Entity('tb_entity_without_tb_path') design_unit_tb_path.generic_names = ["runner_cfg", "tb_path"] config_tb_path = Configuration('name', design_unit_tb_path) self.assertEqual(config_tb_path.generics["tb_path"], (out() + "/").replace("\\", "/")) self.assertNotIn("tb_path", config.generics)
def test_adds_tb_path_generic(self, tempdir): design_unit_tb_path = Entity('tb_entity_without_tb_path', file_name=join(tempdir, "file.vhd")) design_unit_tb_path.generic_names = ["runner_cfg", "tb_path"] config_tb_path = Configuration('name', design_unit_tb_path) self.assertEqual(config_tb_path.generics["tb_path"], (tempdir + "/").replace("\\", "/"))
def test_tb_filter_requires_runner_cfg(self, tempdir): design_unit = Entity('tb_entity', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] self.assertTrue(tb_filter(design_unit)) design_unit = Entity('tb_entity', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = [] self.assertFalse(tb_filter(design_unit)) design_unit = Module('tb_module', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] self.assertTrue(tb_filter(design_unit)) design_unit = Module('tb_module', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = [] self.assertFalse(tb_filter(design_unit))
def test_error_on_setting_illegal_value_sim_option(self): design_unit = Entity('tb_entity') design_unit.generic_names = ["runner_cfg"] config = Configuration('name', design_unit) self.assertRaises(ValueError, config.set_sim_option, "vhdl_assert_stop_level", "illegal")
def test_tb_filter_requires_runner_cfg(self): design_unit = Entity('tb_entity') design_unit.generic_names = ["runner_cfg"] self.assertTrue(tb_filter(design_unit)) design_unit = Entity('tb_entity') design_unit.generic_names = [] self.assertFalse(tb_filter(design_unit)) design_unit = Module('tb_module') design_unit.generic_names = ["runner_cfg"] self.assertTrue(tb_filter(design_unit)) design_unit = Module('tb_module') design_unit.generic_names = [] self.assertFalse(tb_filter(design_unit))
def test_error_on_setting_unknown_sim_option(self): design_unit = Entity('tb_entity') design_unit.generic_names = ["runner_cfg"] config = Configuration('name', design_unit) self.assertRaises(ValueError, config.set_sim_option, "name123", "value123")
def test_elaborate_e_project(self): design_unit = Entity('tb_entity', file_name=join("tempdir", "file.vhd")) design_unit.original_file_name = join("tempdir", "other_path", "original_file.vhd") design_unit.generic_names = ["runner_cfg", "tb_path"] config = Configuration("name", design_unit, sim_options={"ghdl.elab_e": True}) simif = GHDLInterface(prefix="prefix", output_path="") simif._vhdl_standard = VHDL.standard("2008") # pylint: disable=protected-access simif._project = Project() # pylint: disable=protected-access simif._project.add_library("lib", "lib_path") # pylint: disable=protected-access self.assertEqual( simif._get_command(config, join('output_path', 'ghdl'), True), # pylint: disable=protected-access [ join('prefix', 'ghdl'), '-e', '--std=08', '--work=lib', '--workdir=lib_path', '-Plib_path', '-o', join('output_path', 'ghdl', 'tb_entity-arch'), 'tb_entity', 'arch' ] )
def test_adds_tb_path_generic(self, tempdir): design_unit_tb_path = Entity('tb_entity_without_tb_path', file_name=join(tempdir, "file.vhd")) tb_path = join(tempdir, "other_path") design_unit_tb_path.original_file_name = join(tb_path, "original_file.vhd") design_unit_tb_path.generic_names = ["runner_cfg", "tb_path"] config_tb_path = Configuration('name', design_unit_tb_path) self.assertEqual(config_tb_path.generics["tb_path"], (tb_path + "/").replace("\\", "/"))
def test_sim_option_is_not_mutated(self): design_unit = Entity('tb_entity') design_unit.generic_names = ["runner_cfg"] config = Configuration('name', design_unit) options = ["--foo"] config.set_sim_option("ghdl.sim_flags", options) options[0] = "--bar" self.assertEqual(config.sim_options["ghdl.sim_flags"], ["--foo"])
def _create_config(**kwargs): """ Helper function to create a config """ with create_tempdir() as tempdir: design_unit = Entity('tb_entity', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] yield Configuration('name', design_unit, **kwargs)
def _create_config(**kwargs): """ Helper function to create a config """ with create_tempdir() as tempdir: design_unit = Entity('tb_entity', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] yield Configuration('name', design_unit, **kwargs)
def test_adds_tb_path_generic(self, tempdir): design_unit_tb_path = Entity("tb_entity_without_tb_path", file_name=join(tempdir, "file.vhd")) tb_path = join(tempdir, "other_path") design_unit_tb_path.original_file_name = join(tb_path, "original_file.vhd") design_unit_tb_path.generic_names = ["runner_cfg", "tb_path"] config_tb_path = Configuration("name", design_unit_tb_path) self.assertEqual(config_tb_path.generics["tb_path"], (tb_path + "/").replace("\\", "/"))
def test_error_on_setting_unknown_sim_option(self, mock_logger): design_unit = Entity('tb_entity') design_unit.generic_names = ["runner_cfg"] config = Configuration('name', design_unit) self.assertRaises(ValueError, config.set_sim_option, "name123", "value123") error_calls = mock_logger.error.call_args_list self.assertEqual(len(error_calls), 1) call_args = error_calls[0][0] self.assertIn("name123", call_args)
def test_tb_filter_requires_runner_cfg(self, tempdir): design_unit = Entity('tb_entity', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] self.assertTrue(tb_filter(design_unit)) design_unit = Entity('tb_entity', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = [] self.assertFalse(tb_filter(design_unit)) design_unit = Module('tb_module', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] self.assertTrue(tb_filter(design_unit)) design_unit = Module('tb_module', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = [] self.assertFalse(tb_filter(design_unit))
def test_warning_on_setting_missing_generic(self, mock_logger): design_unit = Entity('tb_entity') design_unit.generic_names = ["runner_cfg"] config = Configuration('name', design_unit) config.set_generic("name123", "value123") warning_calls = mock_logger.warning.call_args_list self.assertEqual(len(warning_calls), 1) call_args = warning_calls[0][0] self.assertIn("lib", call_args) self.assertIn("tb_entity", call_args) self.assertIn("name123", call_args) self.assertIn("value123", call_args)
def test_tb_filter_warning_on_runner_cfg_but_not_matching_tb_pattern(self): design_unit = Entity('entity_ok_but_warning') design_unit.generic_names = ["runner_cfg"] with mock.patch("vunit.test_bench_list.LOGGER", autospec=True) as logger: self.assertTrue(tb_filter(design_unit)) logger.warning.assert_has_calls([ mock.call( '%s %s has runner_cfg %s but the file name and the %s name does not match regex %s\n' 'in file %s', 'Entity', 'entity_ok_but_warning', 'generic', 'entity', '^(tb_.*)|(.*_tb)$', design_unit.file_name) ])
def test_tb_filter_warning_on_runner_cfg_but_not_matching_tb_pattern(self, tempdir): design_unit = Entity('entity_ok_but_warning', file_name=join(tempdir, "file.vhd")) design_unit.generic_names = ["runner_cfg"] with mock.patch("vunit.test_bench_list.LOGGER", autospec=True) as logger: self.assertTrue(tb_filter(design_unit)) logger.warning.assert_has_calls([ mock.call('%s %s has runner_cfg %s but the file name and the %s name does not match regex %s\n' 'in file %s', 'Entity', 'entity_ok_but_warning', 'generic', 'entity', '^(tb_.*)|(.*_tb)$', design_unit.file_name)])
def test_tb_filter_warning_on_runner_cfg_but_not_matching_tb_pattern(self, tempdir): design_unit = Entity( "entity_ok_but_warning", file_name=join(tempdir, "file.vhd") ) design_unit.generic_names = ["runner_cfg"] with mock.patch("vunit.test_bench_list.LOGGER", autospec=True) as logger: self.assertTrue(tb_filter(design_unit)) logger.warning.assert_has_calls( [ mock.call( "%s %s has runner_cfg %s but the file name and the %s name does not match regex %s\n" "in file %s", "Entity", "entity_ok_but_warning", "generic", "entity", "^(tb_.*)|(.*_tb)$", design_unit.file_name, ) ] )