Exemplo n.º 1
0
 def test_all_nodes_itr(self):
     """
     tests: Tree.all_nodes_iter
     Added by: William Rusnack
     """
     new_tree = Tree()
     self.assertEqual(len(new_tree.all_nodes_itr()), 0)
     nodes = list()
     nodes.append(new_tree.create_node('root_node'))
     nodes.append(new_tree.create_node('second', parent=new_tree.root))
     for nd in new_tree.all_nodes_itr():
         self.assertTrue(nd in nodes)
                       "Select extra knowledge to load mirror infomation")
    if filename is not None:
        with open(filename, 'r') as load_f:
            load_dict = json.load(load_f)
    mirror = get_mirror(root.startEA)
    procs = get_all_procs()
    tree.create_node(fname,
                     hex(root.startEA),
                     data=Xref_node(fname, hex(root.startEA), XType.code,
                                    mirror))
    if mirror == fname:
        add_xrefs(root.startEA, XType.code)
    Message("Reference Tree:\n\n")
    tree.show(line_type="ascii-em", idhidden=False, data_property='mirror')
    Message("Unique references:\n")
    for node in tree.all_nodes_itr():
        if type(node.data.mirror) is str:
            print node.identifier
    #hierarchical output
    for level in range(1, tree.depth()):
        Message("\nLevel %d: %d\n" % (level, tree.size(level)))
        for node in tree.all_nodes():
            if tree.level(node.identifier) == level and type(
                    node.data.mirror) is str:
                print node.identifier
    Message("\n%d subroutines in routine %s need transplanting.\n" %
            (Xref_node.xrefTrans - 1, fname))
    conn.close()
else:
    Warning("No function found at location %x" % here())