def _create_config(**kwargs): """ Helper function to create a config """ with create_tempdir() as tempdir: design_unit = Entity("tb_entity", file_name=str(Path(tempdir) / "file.vhd")) design_unit.generic_names = ["runner_cfg"] yield Configuration("name", design_unit, **kwargs)
def _read_test_results(self, expected, contents): """ Helper method to test the read_test_results function """ with create_tempdir() as path: file_name = Path(path) / "vunit_results" if contents is not None: with file_name.open("w") as fptr: fptr.write(contents) run = TestRun( simulator_if=None, config=None, elaborate_only=False, test_suite_name=None, test_cases=expected, ) results = run._read_test_results(file_name=file_name) # pylint: disable=protected-access self.assertEqual(results, expected) return results
def _test_exit_code( self, contents, expected, sim_ok=True, has_valid_exit_code=False, waschecked=False, ): """ Helper method to test the check_results function """ with create_tempdir() as path: file_name = join(path, "vunit_results") if contents is not None: with open(file_name, "w") as fptr: fptr.write(contents) sim_if = SimulatorInterface @staticmethod def func(): return has_valid_exit_code sim_if.has_valid_exit_code = func run = TestRun( simulator_if=sim_if, config=None, elaborate_only=False, test_suite_name=None, test_cases=expected, ) results = run._read_test_results( # pylint: disable=protected-access file_name=file_name ) self.assertEqual( run._check_results(results, sim_ok), # pylint: disable=protected-access (waschecked, expected), )