예제 #1
0
def run_cfg(filename):
    # create CFG
    graph = cfg.CFG(filename)
    graph.make_cfg()
    #cfg.show()

    # create graphml
    graphml = cfg2graphml.CFG2Graphml()
    graphml.make_graphml(graph, file_name='', yed_output=True)

    # generate DVFS-aware code
    cdvfs = cfg_cdvfs_generator.CFG_CDVFS()
예제 #2
0
def gen_cfg(filename=None):
    if filename is None:
        curdir = os.path.dirname(__file__)
        filename = os.path.join(curdir, 'c_files', 'test.c')

    graph = cfg.CFG(filename)
    graph.make_cfg()
    graph.show()

    # set file_name as empty to write graphml in stdout
    # set yed_output as true to write graphical information
    cfg2graph = cfg2graphml.CFG2Graphml()
    cfg2graph.make_graphml(graph, file_name='', yed_output=True)
예제 #3
0
def run_cfg(filename):
    # create CFG
    graph = cfg.CFG(filename)
    ast = graph.make_cfg()
    DG = graph.get_DG()
    #cfg.show()

    # create graphml
    graphml = cfg2graphml.CFG2Graphml()
    #graphml.add_boundaries(graph, file_name='', yed_output=True, 1)
    graphml.make_graphml(graph, 2, file_name='', yed_output=True)

    # generate DVFS-aware code
    cdvfs = cfg_cdvfs_generator.CFG_CDVFS()
    #cdvfs.gen(graph)

    #CHANGED.  Added a print for the results.
    generator = c_generator.CGenerator()
    print(generator.visit(ast))
    return (cfg, ast, DG)
예제 #4
0
    def test_while_graphml(self):
        test_name = self.test_while.__name__

        c_test_file = self._find_file(test_name + '.c')
        result_ok = self._find_file(test_name + '.graphml')
        result_check = self._find_file(test_name + '_check.graphml')

        graph = cfg.CFG(c_test_file)
        graph.make_cfg()
        cfg2graph = cfg2graphml.CFG2Graphml()
        cfg2graph.make_graphml(graph, result_check, True)

        test_assert = False
        with open(result_check, 'rU') as check_file,\
                open(result_ok, 'rU') as ok_file:
            check = check_file.read()
            ok = ok_file.read()
            test_assert = (check == ok)

        self.assertTrue(test_assert)
        os.remove(result_check)