コード例 #1
0
 def testReporter(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis reporter
     self.assertTrue(
         callable(project.get_reporter())
     )
コード例 #2
0
ファイル: test_project.py プロジェクト: kayws426/chiptools
 def test_reporter(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis reporter
     self.assertTrue(
         callable(project.get_reporter())
     )
コード例 #3
0
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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
                     )
                 )
コード例 #4
0
 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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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()],
     )
コード例 #6
0
 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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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)
コード例 #11
0
 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()
     )
コード例 #12
0
 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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 def test_generics(self):
     project = Project()
     project.load_project(self.project_path)
     # Check the synthesis generics
     self.assertDictEqual(
         self.project_generics,
         project.get_generics(),
     )
コード例 #14
0
 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()],
     )
コード例 #15
0
 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)
コード例 #16
0
 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
ファイル: testloader.py プロジェクト: kayws426/chiptools
    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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 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)
コード例 #19
0
 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
ファイル: testloader.py プロジェクト: pabennett/chiptools
    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
ファイル: test_project.py プロジェクト: kayws426/chiptools
    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()]),
        )
コード例 #22
0
    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
ファイル: test_project.py プロジェクト: kayws426/chiptools
 def test_project_load(self):
     project = Project()
     project.load_project(self.project_path)
コード例 #24
0
 def testProjectLoad(self):
     project = Project()
     project.load_project(self.project_path)