OpenCores
URL https://opencores.org/ocsvn/radiohdl/radiohdl/trunk

Subversion Repositories radiohdl

[/] [radiohdl/] [trunk/] [base/] [test/] [t_hdl_configtree.py] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
import unittest
2
from configtree import *
3
from hdl_configtree import *
4
 
5
class Test_construction(unittest.TestCase):
6
    "Class to the various ways of construction"
7
 
8
    def test_wrong_filename(self):
9
        "Test constructor with non-existing rootdir"
10
        self.assertRaises(ConfigFileException, ConfigTree, "/Is/Not/A/Valid/Directory", "dict.txt")
11
 
12
    def test_empty_dictfile(self):
13
        "Test constructor with empty config file"
14
        tree = ConfigTree("./cdf_dir/empty_file", "empty_dict.txt")
15
        self.assertEqual(len(tree.configfiles), 1)
16
 
17
    def test_comment_only_dictfile(self):
18
        "Test constructor with comment-only config files"
19
        tree = ConfigTree("./cdf_dir/empty_file", "comment_only_dict.txt")
20
        self.assertEqual(len(tree.configfiles), 1)
21
 
22
 
23
class Test_tree_behaviour(unittest.TestCase):
24
    "Class to test the 'tree' functionality of the class"
25
 
26
    def test_tree_with_configfiles(self):
27
        "Test constructor with a tree with configfiles all containing a 'key_1' label"
28
        "that holds its relative path in the tree"
29
        tree = ConfigTree("./cdf_dir/tree/cfgfile", "dict.txt")
30
        for cfg in tree.configfiles.values():
31
            #print cfg.ID, cfg.content
32
            expected_value = cfg.ID.replace("./cdf_dir/tree/cfgfile" , "top_dir").replace("/dict.txt", "")
33
            self.assertEqual(expected_value, cfg.key_1)
34
 
35
    def test_hdllib_tree(self):
36
        "Test if we can read in a tree with hdllib files."
37
        tree = HdlLibTree("./cdf_dir/tree/hdllib", "test_hdllib.cfg")
38
        self.assertEqual(len(tree.configfiles), 2)
39
        util = tree.configfiles['util']
40
        self.assertEqual(util.hdl_library_clause_name, 'util_lib')
41
        self.assertEqual(util.synth_files, 'src/vhdl/util_logic.vhd src/vhdl/util_heater_pkg.vhd src/vhdl/util_heater.vhd')
42
        technology = tree.configfiles['technology']
43
        self.assertEqual(technology.hdl_library_clause_name, 'technology_lib')
44
        self.assertEqual(technology.synth_files, 'technology_pkg.vhd $HDL_BUILD_DIR/<buildset_name>/modelsim/technology/technology_select_pkg.vhd')
45
 
46
    def test_hdlbuildset_tree(self):
47
        "Test if we can read in a tree with hdlbuildset files."
48
        tree = HdlBuildsetTree("./cdf_dir/tree/hdlbuildset", "hdl_buildset_*.cfg")
49
        self.assertEqual(len(tree.configfiles), 2)
50
        rsp = tree.configfiles['rsp']
51
        self.assertEqual(rsp.technology_names, 'ip_virtex4')
52
        self.assertEqual(rsp.model_tech_altera_lib, '/home/software/modelsim_altera_libs/<synth_tool_version>')
53
        unb1 = tree.configfiles['unb1']
54
        self.assertEqual(unb1.technology_names, 'ip_stratixiv')
55
        self.assertEqual(unb1.model_tech_altera_lib, '/home/software/modelsim_altera_libs/<synth_tool_version>')
56
 
57
    def test_hdltool_tree(self):
58
        "Test if we can read in a tree with hdltool files."
59
        tree = HdlToolTree("./cdf_dir/tree/hdltool", "hdl_tool_*.cfg")
60
        self.assertEqual(len(tree.configfiles), 2)
61
        altera = tree.configfiles['./cdf_dir/tree/hdltool/hdl_tool_altera.cfg']
62
        self.assertEqual(altera.altera_rootdir, "${ALTERA_DIR}/altera")
63
        quartus = tree.configfiles['./cdf_dir/tree/hdltool/hdl_tool_quartus.cfg']
64
        self.assertEqual(quartus.quartus_rootdir, "${QUARTUS_DIR}/quartus")
65
 
66
if __name__ == '__main__':
67
    unittest.main(verbosity=2)
68
 

powered by: WebSVN 2.1.0

© copyright 1999-2019 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.