예제 #1
0
 def test_target_for_part(self):
     logging.info("********************************************")
     for target in TGT_DICT['HdlAllFamilies']:
         if 'HdlTargets_' + target in TGT_DICT:
             golden_list_of_parts = TGT_DICT['HdlTargets_' + target]
         else:
             golden_list_of_parts = [target]
         for part in golden_list_of_parts:
             logging.info("Target for part \"" + part + "\" should be: " + target)
             self.assertEqual(HdlTarget.get_target_for_part(part).name, target)
             self.assertEqual(str(HdlTarget.get_target_for_part(part)), target)
         self.assertEqual(HdlTarget.get_target_for_part("Not a target"), None)
예제 #2
0
    def test_all_targets(self):
        logging.info("********************************************")
        golden_targets = TGT_DICT['HdlAllFamilies']
        logging.info("All targets should be: " + str(golden_targets))

        self.assertEqual(set([tgt.name for tgt in HdlTarget.all()]), set(golden_targets))
        golden_non_sim_targets = []
        for target in golden_targets:
            if TGT_DICT['HdlToolSet_' + target][0]\
                                  not in TGT_DICT['HdlSimTools']:
                golden_non_sim_targets.append(target)
        logging.info("All targets except simulators should be: " + str(golden_non_sim_targets))
        self.assertEqual(set([tgt.name for tgt in HdlTarget.all_except_sims()]),
                         set(golden_non_sim_targets))
예제 #3
0
 def test_all_targets_for_toolset(self):
     logging.info("********************************************")
     for tool in HdlToolSet.all():
         alltargets0 = HdlTarget.get_all_targets_for_toolset(tool)
         alltargets1 = HdlTarget.get_all_targets_for_toolset(tool.name)
         golden_list_of_targets = []
         for target in TGT_DICT['HdlAllFamilies']:
             if TGT_DICT['HdlToolSet_' + target][0] == tool:
                 golden_list_of_targets.append(target)
         self.assertEqual(alltargets0, alltargets1)
         logging.info("Targets for toolset \"" + str(tool) +
                      "\" should be: " + str(golden_list_of_targets))
         self.assertEqual(set([tgt.name for tgt in alltargets0]), set(golden_list_of_targets))
         self.assertEqual(set([str(tgt) for tgt in alltargets0]), set(golden_list_of_targets))
예제 #4
0
 def test_top_targets(self):
     logging.info("********************************************")
     toptargets = TGT_DICT['HdlTopTargets']
     logging.info("List of top targets should be: " + str(toptargets))
     self.assertEqual(set(HdlTarget.get_all_vendors()), set(toptargets))
     logging.info("Testing target associations with top-targets/vendors")
     for top in toptargets:
         logging.info("--------------------------------------------")
         logging.info("Top target: " + top)
         if 'HdlTargets_' + top in TGT_DICT:
             logging.info("Children targets should be: " + str(TGT_DICT['HdlTargets_' + top]))
             for name in TGT_DICT['HdlTargets_' + top]:
                 self.assertEqual(HdlTarget.get(name).name, name)
                 self.assertEqual(HdlTarget.get(name).vendor, top)
         else:
             logging.info("Children targets should be: " + str([top]))
             self.assertEqual(HdlTarget.get(top).name, top)
             self.assertEqual(HdlTarget.get(top).vendor, top)
예제 #5
0
 def test_all_targets_for_vendor(self):
     logging.info("********************************************")
     for top in TGT_DICT['HdlTopTargets']:
         alltargets0 = HdlTarget.get_all_targets_for_vendor(top)
         if 'HdlTargets_' + top in TGT_DICT:
             golden_list_of_targets = TGT_DICT['HdlTargets_' + top]
         else:
             golden_list_of_targets = [top]
         logging.info("Targets for vendor \"" + top + "\" should be: " + str(golden_list_of_targets))
         self.assertEqual(set([tgt.name for tgt in alltargets0]), set(golden_list_of_targets))
         self.assertEqual(set([str(tgt) for tgt in alltargets0]), set(golden_list_of_targets))
예제 #6
0
def do_hdltargets(options):
    """
    Print out the list of available HdlTargets.
    Without options, this will just be a list.
    If the "dense" option is provided, print out an ugly but parsable list of targets and
    the details associated with each.
    If the "table" option is provided, print out a formatted table of the targets an
    the details associated with each.
    If the "json" option is provided, dump json output for the target details.
    """
    if options.details == "table":
        rows = [["Target", "Parts", "Vendor", "Toolset"]]
        rows += [["---------", "---------", "---------", "---------"]]
        # Collect the information for each target into a "row" list
        for target in HdlTarget.all():
            targetRow = [
                str(target), ','.join(target.parts), target.vendor,
                target.toolset.title
            ]
            rows.append(targetRow)
        ocpiutil.print_table(rows)
    elif options.details == "json":
        # Dump the json containing each platform's attributes
        vendorDict = {}
        for vendor in HdlTarget.get_all_vendors():
            targetDict = {}
            for target in HdlTarget.get_all_targets_for_vendor(vendor):
                targetDict[target.name] = {
                    "parts": target.parts,
                    "tool": target.toolset.title
                }
            vendorDict[vendor] = targetDict
        json.dump(vendorDict, sys.stdout)
        print()
    else:
        print(
            ocpiutil.python_list_to_bash(
                sorted([str(tgt) for tgt in HdlTarget.all()])))
예제 #7
0
 def test_platforms_inits(self):
     logging.info("********************************************")
     logging.info("Testing initialization of platforms")
     for name in TGT_DICT['HdlAllPlatforms']:
         logging.info("--------------------------------------------")
         logging.info("Initialization of platform: " + name)
         exactpart = TGT_DICT['HdlPart_' + name][0]
         target = TGT_DICT['HdlFamily_' + exactpart][0]
         logging.info("Fields should be: \"" + name + ", " + target + ", " + exactpart)
         platform = HdlPlatform.get(name)
         self.assertEqual(platform.name, name)
         # test __str__
         self.assertEqual(str(platform), name)
         self.assertEqual(platform.exactpart, exactpart)
         self.assertEqual(platform.target.name, target)
         toolname = str(HdlTarget.get(target).toolset)
         logging.info("Platform should have toolset: " + toolname)
         self.assertEqual(str(platform.get_toolset()), toolname)
     self.assertEqual(HdlPlatform.get("Not a valid name"), None)
예제 #8
0
 def test_toolset_inits(self):
     logging.info("********************************************")
     logging.info("Testing initialization of toolsets")
     for tgt, name in [(tgt, TGT_DICT['HdlToolSet_' + tgt][0])\
                          for tgt in TGT_DICT['HdlAllFamilies']]:
         logging.info("--------------------------------------------")
         logging.info("Target: \"" + tgt + "\" should have toolset: " + name)
         self.assertEqual(HdlTarget.get(tgt).toolset.name, name)
         self.assertEqual(HdlToolSet.get(name).name, name)
         title = TGT_DICT['HdlToolName_' + name][0]
         logging.info("Toolset: \"" + name + "\" should have title: " + title)
         self.assertEqual(HdlToolSet.get(name).title, title)
         # test __str__
         self.assertEqual(str(HdlToolSet.get(name)), name)
         if name in TGT_DICT['HdlSimTools']:
             logging.info("This SHOULD be a simulator tool")
             self.assertTrue(HdlToolSet.get(name).is_simtool)
         else:
             logging.info("This should NOT be a simulator tool")
             self.assertFalse(HdlToolSet.get(name).is_simtool)
     self.assertEqual(HdlToolSet.get("Not a valid name"), None)
예제 #9
0
 def test_targets_inits(self):
     logging.info("********************************************")
     logging.info("Testing initialization of targets")
     for name in TGT_DICT['HdlAllFamilies']:
         logging.info("--------------------------------------------")
         logging.info("Initialization of target: " + name)
         self.assertEqual(HdlTarget.get(name).name, name)
         # test __str__
         self.assertEqual(str(HdlTarget.get(name)), name)
         logging.info("Parts list of target: " + name)
         if 'HdlTargets_' + name in TGT_DICT:
             logging.info("Parts list should be: " + str(TGT_DICT['HdlTargets_' + name]))
             self.assertEqual(HdlTarget.get(name).parts,
                              TGT_DICT['HdlTargets_' + name])
         else:
             logging.info("Parts list should be: " + str([name]))
             self.assertEqual(HdlTarget.get(name).parts, [name])
         logging.info("ToolSet for should be: " + str(TGT_DICT['HdlToolSet_' + name][0]))
         self.assertEqual(HdlTarget.get(name).toolset.name,
                          TGT_DICT['HdlToolSet_' + name][0])
     self.assertEqual(HdlTarget.get("Not a valid name"), None)