def testReporter(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis reporter
     self.assertTrue(
         callable(project.get_reporter())
     )
示例#2
0
 def test_reporter(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis reporter
     self.assertTrue(
         callable(project.get_reporter())
     )
示例#3
0
 def test_preprocessor(self):
     """Invalid preprocessors should not be executed on files."""
     project = Project()
     project.load_project(self.project_path)
     files = project.get_files()
     preprocessors = list(
         filter(
             lambda x: os.path.exists(x.preprocessor), files
         )
     )
     self.assertTrue(len(preprocessors) > 0)
     project.run_preprocessors()
     regex = re.compile('library ieee;')
     for libname in self.project_structure.keys():
         files = self.project_structure[libname]
         for path in files:
             path = os.path.join(self.root, libname, path)
             with open(path, 'r') as f:
                 data = f.readlines()
                 match = regex.match(data[0])
                 self.assertIsNotNone(
                     match,
                     msg='File {0} was not correctly preserved.'.format(
                         path
                     )
                 )
 def testSynthesisToolName(self):
     project = Project()
     project.load_project(self.project_path)
     # Check synthesis tool name
     self.assertEqual(
         self.synthesis_tool_name,
         project.get_synthesis_tool_name()
     )
示例#5
0
 def test_project_constraints(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the project constraints
     self.assertEqual(
         self.project_constraints,
         [os.path.basename(c.path) for c in project.get_constraints()],
     )
 def testGenerics(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis generics
     self.assertDictEqual(
         self.project_generics,
         project.get_generics(),
     )
示例#7
0
 def test_synthesis_tool_name(self):
     project = Project()
     project.load_project(self.project_path)
     # Check synthesis tool name
     self.assertEqual(
         self.synthesis_tool_name,
         project.get_synthesis_tool_name()
     )
示例#8
0
 def test_simulation_Tool_name(self):
     project = Project()
     project.load_project(self.project_path)
     # Check simulation tool name
     self.assertEqual(
         self.simulation_tool_name,
         project.get_simulation_tool_name()
     )
示例#9
0
 def test_project_part(self):
     project = Project()
     project.load_project(self.project_path)
     # Check project part
     self.assertEqual(
         self.project_part,
         project.get_fpga_part()
     )
示例#10
0
 def test_simulation_directory(self):
     project = Project()
     project.load_project(self.project_path)
     abs_path = os.path.join(
         os.path.abspath(self.root),
         self.simulation_directory
     )
     self.assertEqual(project.get_simulation_directory(), abs_path)
 def testSimulationToolName(self):
     project = Project()
     project.load_project(self.project_path)
     # Check simulation tool name
     self.assertEqual(
         self.simulation_tool_name,
         project.get_simulation_tool_name()
     )
 def testProjectPart(self):
     project = Project()
     project.load_project(self.project_path)
     # Check project part
     self.assertEqual(
         self.project_part,
         project.get_fpga_part()
     )
示例#13
0
 def test_generics(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis generics
     self.assertDictEqual(
         self.project_generics,
         project.get_generics(),
     )
 def testProjectConstraints(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the project constraints
     self.assertEqual(
         self.project_constraints,
         [os.path.basename(c.path) for c in project.get_constraints()],
     )
 def testSimulationDirectory(self):
     project = Project()
     project.load_project(self.project_path)
     abs_path = os.path.join(
         os.path.abspath(self.root),
         self.simulation_directory
     )
     self.assertEqual(project.get_simulation_directory(), abs_path)
 def testSynthesisDirectory(self):
     project = Project()
     project.load_project(self.project_path)
     abs_path = os.path.join(
         os.path.abspath(self.root),
         self.synthesis_directory
     )
     self.assertEqual(project.get_synthesis_directory(), abs_path)
示例#17
0
    def setUpClass(cls):
        """
        The *setUpClass* method prepares the ChipTools simulation environment
        if it has not already been loaded. 
        
        If this test case is loaded via the ChipTools Project API it will be
        initialised via a call to the *load_environment* method, which pulls
        the simulation environment information from the parent Project
        instance.

        If this test case is loaded via an external tool such as Nosetests the
        setUpClass method will attempt to load the project file pointed to by
        the project path stored in the *project* attribute. When you create
        your test case you can specify this attribute in your test class to
        allow an external runner like Nosetests to call your test cases.

        If the environment was not already initialised by ChipTools and a valid
        project file path is not stored in the *project* attribute, this method
        will raise an EnvironmentError and cause your test to fail.

        This method overloads the unittest.TestCase.setUpClass classmethod,
        which is called once when a TestCase class is instanced.
        """
        log.debug('setUpClass of {0} called...'.format(cls))
        # Check to see if the environment that this class is initialised for
        # matches the project path (if specified). If the environment was
        # initialised by the ChipTools internal loaded then skip these steps.
        if cls._environment_type != 'chiptools':
            if cls._loaded_path != cls.project:
                project = Project()
                project.load_project(cls.project)
                # Using external test runner (such as Nosetests) to execute this
                # test. The test environment therefore needs to be loaded from
                # the Project instance:
                simulator, root, libs = cls.get_environment(project)
                cls._loaded_path = cls.project
                cls._simulator = simulator
                cls._simulation_root = root
                cls._simulation_libraries = libs
                cls._environment_type = 'external'
                # Compile the design if required (simulators with caching will
                # perform this step once).
                cls._simulator.compile_project(
                    includes=cls._simulation_libraries
                )
                log.debug(
                    '...finished initialising environment for {0}'.format(cls)
                )
        if cls._environment_type is None:
            raise EnvironmentError(
                'The simulation environment for this TestCase is not ' +
                'initialised so the test cases cannot be executed. ' +
                'If you are running this test directly ensure that ' +
                'the TestCase class has a "project" attribute which ' +
                'holds a path to a valid ChipTools project file.'
            )
示例#18
0
 def test_preprocessor(self):
     project = Project()
     project.load_project(self.project_path)
     files = project.get_files()
     preprocessors = list(
         filter(
             lambda x: os.path.exists(x.preprocessor), files
         )
     )
     self.assertTrue(len(preprocessors) > 0)
     self.run_and_check_preprocessors(project)
 def testPreprocessor(self):
     project = Project()
     project.load_project(self.project_path)
     files = project.get_files()
     preprocessors = list(
         filter(
             lambda x: os.path.exists(x.preprocessor), files
         )
     )
     self.assertTrue(len(preprocessors) > 0)
     project.run_preprocessors()
示例#20
0
    def setUpClass(cls):
        """
        The *setUpClass* method prepares the ChipTools simulation environment
        if it has not already been loaded. 
        
        If this test case is loaded via the ChipTools Project API it will be
        initialised via a call to the *load_environment* method, which pulls
        the simulation environment information from the parent Project
        instance.

        If this test case is loaded via an external tool such as Nosetests the
        setUpClass method will attempt to load the project file pointed to by
        the project path stored in the *project* attribute. When you create
        your test case you can specify this attribute in your test class to
        allow an external runner like Nosetests to call your test cases.

        If the environment was not already initialised by ChipTools and a valid
        project file path is not stored in the *project* attribute, this method
        will raise an EnvironmentError and cause your test to fail.

        This method overloads the unittest.TestCase.setUpClass classmethod,
        which is called once when a TestCase class is instanced.
        """
        log.debug("setUpClass of {0} called...".format(cls))
        # Check to see if the environment that this class is initialised for
        # matches the project path (if specified). If the environment was
        # initialised by the ChipTools internal loaded then skip these steps.
        if cls._environment_type != "chiptools":
            if cls._loaded_path != cls.project:
                project = Project()
                project.load_project(cls.project)
                # Using external test runner (such as Nosetests) to execute this
                # test. The test environment therefore needs to be loaded from
                # the Project instance:
                simulator, root, libs = cls.get_environment(project)
                cls._loaded_path = cls.project
                cls._simulator = simulator
                cls._simulation_root = root
                cls._simulation_libraries = libs
                cls._environment_type = "external"
                # Compile the design if required (simulators with caching will
                # perform this step once).
                cls._simulator.compile_project(includes=cls._simulation_libraries)
                log.debug("...finished initialising environment for {0}".format(cls))
        if cls._environment_type is None:
            raise EnvironmentError(
                "The simulation environment for this TestCase is not "
                + "initialised so the test cases cannot be executed. "
                + "If you are running this test directly ensure that "
                + 'the TestCase class has a "project" attribute which '
                + "holds a path to a valid ChipTools project file."
            )
示例#21
0
    def test_file_set(self):
        project = Project()
        project.load_project(self.project_path)
        # Check the file set loaded from the project
        expected_files = []
        for libname in self.project_structure.keys():
            files = self.project_structure[libname]
            for path in files:
                expected_files.append(os.path.basename(path))

        self.assertEqual(
            sorted(expected_files),
            sorted([os.path.basename(f.path) for f in project.get_files()]),
        )
    def testFileSet(self):
        project = Project()
        project.load_project(self.project_path)
        # Check the file set loaded from the project
        expected_files = []
        for libname in self.project_structure.keys():
            files = self.project_structure[libname]
            for path in files:
                expected_files.append(os.path.basename(path))

        self.assertEqual(
            sorted(expected_files),
            sorted([os.path.basename(f.path) for f in project.get_files()]),
        )
示例#23
0
 def test_project_load(self):
     project = Project()
     project.load_project(self.project_path)
 def testProjectLoad(self):
     project = Project()
     project.load_project(self.project_path)