def simulate( self, output_path, # pylint: disable=too-many-arguments library_name, entity_name, architecture_name, config, elaborate_only): """ Run a test bench """ sim_output_path = abspath(join(output_path, self.name)) common_file_name = join(sim_output_path, "common.tcl") batch_file_name = join(sim_output_path, "batch.tcl") gui_file_name = join(sim_output_path, "gui.tcl") write_file( common_file_name, self._create_common_script(library_name, entity_name, architecture_name, config)) write_file(gui_file_name, self._create_gui_script(common_file_name)) write_file(batch_file_name, self._create_batch_script(common_file_name, elaborate_only)) if self._gui: gui_path = join(sim_output_path, "gui") renew_path(gui_path) return self._run_batch_file(gui_file_name, gui=True, cwd=gui_path) else: return self._run_batch_file(batch_file_name, gui=False, cwd=dirname(self._library_cfg))
def setUp(self): self.output_path = join(dirname(__file__), "test_simulator_interface__out") renew_path(self.output_path) self.project = Project() self.cwd = os.getcwd() os.chdir(self.output_path)
def setUp(self): self.output_path = str( Path(__file__).parent / "test_ghdl_interface_out") renew_path(self.output_path) self.project = Project() self.cwd = os.getcwd() os.chdir(self.output_path)
def simulate(self, output_path, # pylint: disable=too-many-arguments library_name, entity_name, architecture_name, config, elaborate_only): """ Run a test bench """ sim_output_path = abspath(join(output_path, self.name)) common_file_name = join(sim_output_path, "common.tcl") batch_file_name = join(sim_output_path, "batch.tcl") gui_file_name = join(sim_output_path, "gui.tcl") write_file(common_file_name, self._create_common_script(library_name, entity_name, architecture_name, config)) write_file(gui_file_name, self._create_gui_script(common_file_name)) write_file(batch_file_name, self._create_batch_script(common_file_name, elaborate_only)) if self._gui: gui_path = join(sim_output_path, "gui") renew_path(gui_path) return self._run_batch_file(gui_file_name, gui=True, cwd=gui_path) else: return self._run_batch_file(batch_file_name, gui=False, cwd=dirname(self._library_cfg))
def setUp(self): self.output_path = str( Path(__file__).parent / "test_simulator_interface__out") renew_path(self.output_path) self.project = Project() self.cwd = getcwd() chdir(self.output_path)
def setUp(self): self.tmp_path = join(dirname(__file__), "test_ui_tmp") renew_path(self.tmp_path) self.cwd = os.getcwd() os.chdir(self.tmp_path) self._output_path = join(self.tmp_path, 'output') self._preprocessed_path = join(self._output_path, "preprocessed")
def setUp(self): self.tmp_path = str(Path(__file__).parent / "test_ui_tmp") renew_path(self.tmp_path) self.cwd = getcwd() chdir(self.tmp_path) self._output_path = str(Path(self.tmp_path) / "output") self._preprocessed_path = str(Path(self._output_path) / "preprocessed")
def _create_output_path(self, clean): """ Create or re-create the output path if necessary """ if clean: ostools.renew_path(self._output_path) elif not exists(self._output_path): os.makedirs(self._output_path) ostools.renew_path(self._preprocessed_path)
def _run_test_suite(self, test_suite, write_stdout, num_tests, output_path, output_file_name): """ Run the actual test suite """ color_output_file_name = join(output_path, "output_with_color.txt") output_file = None color_output_file = None start_time = ostools.get_time() results = self._fail_suite(test_suite) try: ostools.renew_path(output_path) output_file = wrap(open(output_file_name, "w"), use_color=False) if write_stdout: self._local.output = Tee([self._stdout_ansi, output_file]) else: color_output_file = open(color_output_file_name, "w") self._local.output = Tee([color_output_file, output_file]) results = test_suite.run(output_path) except KeyboardInterrupt: raise except: # pylint: disable=bare-except if self._dont_catch_exceptions: raise with self._stdout_lock(): traceback.print_exc() finally: self._local.output = self._stdout for fptr in [output_file, color_output_file]: if fptr is None: continue fptr.flush() fptr.close() any_not_passed = any(value != PASSED for value in results.values()) with self._stdout_lock(): if (color_output_file is not None) and ( any_not_passed or self._is_verbose) and not self._is_quiet: self._print_output(color_output_file_name) self._add_results(test_suite, results, start_time, num_tests, output_file_name) if self._fail_fast and any_not_passed: self._abort = True
def _run_test_suite(self, test_suite, write_stdout, num_tests): """ Run the actual test suite """ start_time = ostools.get_time() output_path = join(self._output_path, test_suite.name) output_file_name = join(output_path, "output.txt") try: # If we could not clean output path, fail all tests ostools.renew_path(output_path) output_file = open(output_file_name, "w") except KeyboardInterrupt: raise except: # pylint: disable=bare-except results = self._fail_suite(test_suite) with self._lock: traceback.print_exc() self._add_results(test_suite, results, start_time, num_tests) return try: if write_stdout: stdout = LogColorOverlay( stream=self._stdout, printer=self._printer, vhdl_report_parser_callback=self.vhdl_report_parser_callback) self._local.output = TeeToFile([stdout, output_file]) else: self._local.output = TeeToFile([output_file]) results = test_suite.run(output_path) except KeyboardInterrupt: raise except: # pylint: disable=bare-except traceback.print_exc() results = self._fail_suite(test_suite) finally: self._local.output = self._stdout output_file.flush() output_file.close() any_not_passed = any(value != PASSED for value in results.values()) with self._lock: if (not write_stdout) and (any_not_passed or self._verbose): stdout = LogColorOverlay( stream=sys.stdout, printer=self._printer, vhdl_report_parser_callback=self.vhdl_report_parser_callback) self._print_output(output_file_name, stdout) self._add_results(test_suite, results, start_time, num_tests)
def _run_test_suite(self, test_suite, write_stdout, num_tests, output_path, output_file_name): """ Run the actual test suite """ start_time = ostools.get_time() try: # If we could not clean output path, fail all tests ostools.renew_path(output_path) output_file = open(output_file_name, "w") except KeyboardInterrupt: raise except: # pylint: disable=bare-except results = self._fail_suite(test_suite) with self._lock: # pylint: disable=not-context-manager traceback.print_exc() self._add_results(test_suite, results, start_time, num_tests, output_file_name) return try: if write_stdout: self._local.output = TeeToFile([self._stdout, output_file]) else: self._local.output = TeeToFile([output_file]) results = test_suite.run(output_path) except KeyboardInterrupt: raise except: # pylint: disable=bare-except if self._dont_catch_exceptions: raise traceback.print_exc() results = self._fail_suite(test_suite) finally: self._local.output = self._stdout output_file.flush() output_file.close() any_not_passed = any(value != PASSED for value in results.values()) with self._lock: # pylint: disable=not-context-manager if (not write_stdout) and ( any_not_passed or self._is_verbose) and not self._is_quiet: self._print_output(output_file_name) self._add_results(test_suite, results, start_time, num_tests, output_file_name)
def test_copies_modelsim_ini_file_from_install(self): installed_path = join(self.output_path, "prefix") modelsim_ini = join(self.output_path, "modelsim", "modelsim.ini") installed_modelsim_ini = join(self.output_path, "modelsim.ini") user_modelsim_ini = join(self.output_path, "my_modelsim.ini") renew_path(installed_path) with open(installed_modelsim_ini, "w") as fptr: fptr.write("installed") with open(user_modelsim_ini, "w") as fptr: fptr.write("user") ModelSimInterface(prefix=join(self.output_path, "prefix"), modelsim_ini=modelsim_ini, persistent=False) with open(modelsim_ini, "r") as fptr: self.assertEqual(fptr.read(), "installed")
def __init__(self, path, new=False): """ Create database in path - path is a directory - new create new database """ self._path = path if new: renew_path(path) elif not exists(path): os.makedirs(path) # Map keys to nodes indexes self._keys_to_nodes = self._discover_nodes() if not self._keys_to_nodes: self._next_node = 0 else: self._next_node = max(self._keys_to_nodes.values()) + 1
def __init__(self, path, new=False): """ Create database in path - path is a directory - new create new database """ self._path = path if new: renew_path(path) elif not Path(path).exists(): os.makedirs(path) # Map keys to nodes indexes self._keys_to_nodes = self._discover_nodes() if not self._keys_to_nodes: self._next_node = 0 else: self._next_node = max(self._keys_to_nodes.values()) + 1
def simulate(self, output_path, test_suite_name, config, elaborate_only): """ Run a test bench """ common_file_name = join(output_path, "common.tcl") batch_file_name = join(output_path, "batch.tcl") gui_file_name = join(output_path, "gui.tcl") write_file(common_file_name, self._create_common_script(config)) write_file(gui_file_name, self._create_gui_script(common_file_name, config)) write_file(batch_file_name, self._create_batch_script(common_file_name, elaborate_only)) if self._gui: gui_path = join(output_path, "gui") renew_path(gui_path) return self._run_batch_file(gui_file_name, gui=True, cwd=gui_path) return self._run_batch_file(batch_file_name, gui=False, cwd=dirname(self._library_cfg))
def simulate(self, output_path, test_suite_name, config, elaborate_only): """ Run a test bench """ script_path = join(output_path, self.name) common_file_name = join(script_path, "common.tcl") batch_file_name = join(script_path, "batch.tcl") gui_file_name = join(script_path, "gui.tcl") write_file(common_file_name, self._create_common_script(config, output_path)) write_file(gui_file_name, self._create_gui_script(common_file_name, config)) write_file(batch_file_name, self._create_batch_script(common_file_name, elaborate_only)) if self._gui: gui_path = join(script_path, "gui") renew_path(gui_path) return self._run_batch_file(gui_file_name, gui=True, cwd=gui_path) return self._run_batch_file(batch_file_name, gui=False, cwd=dirname(self._library_cfg))
def setUp(self): self.test_path = join(dirname(__file__), "test_modelsim_out") self.output_path = join(self.test_path, "modelsim") self.prefix_path = join(self.test_path, "prefix", "bin") renew_path(self.test_path) renew_path(self.output_path) renew_path(self.prefix_path) installed_modelsim_ini = join(self.prefix_path, "..", "modelsim.ini") write_file(installed_modelsim_ini, "[Library]") self.project = Project() self.cwd = os.getcwd() os.chdir(self.test_path)
def setUp(self): self.test_path = str(Path(__file__).parent / "test_modelsim_out") self.output_path = str(Path(self.test_path) / "modelsim") self.prefix_path = str(Path(self.test_path) / "prefix" / "bin") renew_path(self.test_path) renew_path(self.output_path) renew_path(self.prefix_path) installed_modelsim_ini = str(Path(self.prefix_path) / ".." / "modelsim.ini") write_file(installed_modelsim_ini, "[Library]") self.project = Project() self.cwd = os.getcwd() os.chdir(self.test_path)
def setUp(self): self.output_path = join(dirname(__file__), "test_verilog_preprocessor_out") renew_path(self.output_path)
def setUp(self): self.tmp_dir = join(dirname(__file__), "test_ostools_tmp") renew_path(self.tmp_dir)
def setUp(self): self.output_path = join(dirname(__file__), "test_database_out") renew_path(self.output_path)
def setUp(self): self.tmp_dir = str(Path(__file__).parent / "test_ostools_tmp") renew_path(self.tmp_dir)
def setUp(self): self.cfg = TestConfiguration() self.output_path = out() renew_path(self.output_path)
def setUp(self): self.output_path = join(dirname(__file__), "test_verilog_preprocessor_out") renew_path(self.output_path) self.cwd = os.getcwd() os.chdir(self.output_path)
def setUp(self): self.output_path = join(dirname(__file__), "test_activehdl_out") renew_path(self.output_path) self.project = Project() self.cwd = os.getcwd() os.chdir(self.output_path)
def setUp(self): self._tests = [] self.output_path = join(dirname(__file__), "test_runner_out") renew_path(self.output_path) self.report = TestReport() self.runner = TestRunner(self.report, self.output_path)
def setUp(self): self.simulator_if = 'simulator_if' self.configuration = TestConfiguration() self.test_scanner = TestScanner(self.simulator_if, self.configuration) self.output_path = join(dirname(__file__), "test_scanner_out") renew_path(self.output_path)
def setUp(self): self.output_path = str( Path(__file__).parent / "test_verilog_preprocessor_out") renew_path(self.output_path) self.cwd = os.getcwd() os.chdir(self.output_path)
def setUp(self): self._tests = [] self.output_path = join(dirname(__file__), "test_runner_out") renew_path(self.output_path)
def setUp(self): self.output_path = join(dirname(__file__), "test_modelsim_out") renew_path(self.output_path) self.project = Project() self.cwd = os.getcwd() os.chdir(self.output_path)
def setUp(self): self.simulator_if = 'simulator_if' self.output_path = out() renew_path(self.output_path)
def _run_test_suite(self, test_suite, write_stdout, num_tests, output_path, output_file_name): """ Run the actual test suite """ color_output_file_name = join(output_path, "output_with_color.txt") output_file = None color_output_file = None start_time = ostools.get_time() results = self._fail_suite(test_suite) try: ostools.renew_path(output_path) output_file = wrap(open(output_file_name, "a+"), use_color=False) output_file.seek(0) output_file.truncate() if write_stdout: self._local.output = Tee([self._stdout_ansi, output_file]) else: color_output_file = open(color_output_file_name, "w") self._local.output = Tee([color_output_file, output_file]) def read_output(): """ Called to read the contents of the output file on demand """ output_file.flush() prev = output_file.tell() output_file.seek(0) contents = output_file.read() output_file.seek(prev) return contents results = test_suite.run(output_path=output_path, read_output=read_output) except KeyboardInterrupt: self._add_skipped_tests(test_suite, results, start_time, num_tests, output_file_name) raise KeyboardInterrupt except: # pylint: disable=bare-except if self._dont_catch_exceptions: raise with self._stdout_lock(): traceback.print_exc() finally: self._local.output = self._stdout for fptr in [output_file, color_output_file]: if fptr is None: continue fptr.flush() fptr.close() any_not_passed = any(value != PASSED for value in results.values()) with self._stdout_lock(): if (color_output_file is not None) and (any_not_passed or self._is_verbose) and not self._is_quiet: self._print_output(color_output_file_name) self._add_results(test_suite, results, start_time, num_tests, output_file_name) if self._fail_fast and any_not_passed: self._abort = True