Esempio n. 1
0
    def _main(self):
        """
        Base vunit main function without performing exit
        """
        if self._list_only:
            return self._main_list_only()

        if self._compile_only:
            return self._main_compile_only()

        simulator_if = self._create_simulator_if()
        test_cases = self._create_tests(simulator_if)

        self._compile(simulator_if)

        start_time = ostools.get_time()
        report = TestReport(printer=self._printer)
        try:
            self._run_test(test_cases, report)
            simulator_if.post_process(self._simulator_factory.simulator_output_path)
        except KeyboardInterrupt:
            print()
            LOGGER.debug("_main: Caught Ctrl-C shutting down")
        finally:
            del test_cases
            del simulator_if

        report.set_real_total_time(ostools.get_time() - start_time)
        self._post_process(report)

        return report.all_ok()
Esempio n. 2
0
    def _main(self):
        """
        Base vunit main function without performing exit
        """
        if self._list_only:
            return self._main_list_only()

        if self._list_files_only:
            return self._main_list_files_only()

        if self._compile_only:
            return self._main_compile_only()

        simulator_if = self._create_simulator_if()
        test_cases = self._create_tests(simulator_if)

        self._compile(simulator_if)

        start_time = ostools.get_time()
        report = TestReport(printer=self._printer)
        try:
            self._run_test(test_cases, report)
            simulator_if.post_process(self._simulator_factory.simulator_output_path)
        except KeyboardInterrupt:
            print()
            LOGGER.debug("_main: Caught Ctrl-C shutting down")
        finally:
            del test_cases
            del simulator_if

        report.set_real_total_time(ostools.get_time() - start_time)
        self._post_process(report)

        return report.all_ok()
def run_with_compile_errors(ui, args, vhdl_standard):
    def match(name, patterns):
        return reduce(
            lambda found_match, pattern: found_match | fnmatch(name, pattern),
            patterns,
            False,
        )

    # Run all tests in isolation to handle failure to compile
    args.minimal = True
    original_test_patterns = args.test_patterns
    test_report = TestReport()
    n_tests = 0
    testbenches = (ui.library("vhdl_2008").get_test_benches() +
                   ui.library("vhdl_2019").get_test_benches())
    total_start_time = ostools.get_time()
    for tb in testbenches:
        tests = tb.get_tests()
        if not tests:
            test_names = ["all"]
        else:
            test_names = [test.name for test in tests]

        for test_name in test_names:
            full_test_name = "%s.%s.%s" % (tb.library.name, tb.name, test_name)
            if not match(full_test_name, original_test_patterns):
                continue

            test_start_time = ostools.get_time()
            n_tests += 1
            args.test_patterns = [full_test_name]
            ui = VUnit.from_args(args, vhdl_standard=vhdl_standard)
            vhdl_2008 = ui.add_library("vhdl_2008")
            vhdl_2019 = ui.add_library("vhdl_2019")
            vhdl_2008.add_source_files(join(root, "vhdl_2008", "*.vhd"))
            vhdl_2019.add_source_files(join(root, "vhdl_2019", "*.vhd"))

            try:
                ui.main()
            except SystemExit as ex:
                tb_time = ostools.get_time() - test_start_time
                if ex.code == 0:
                    test_report.add_result(full_test_name, PASSED, tb_time,
                                           None)
                else:
                    test_report.add_result(full_test_name, FAILED, tb_time,
                                           None)

    print("\nCompliance test completed:\n")
    test_report.set_expected_num_tests(n_tests)
    test_report.set_real_total_time(ostools.get_time() - total_start_time)
    test_report.print_str()