Пример #1
0
    def test_graphutil_coverage(self):
        # FIXME: So fun anecdote for later, originally I wanted to use fva 0x804af40 (parse_ls_colors)
        # out of vdir for this test, but unfortunately, we detect the codeblock of that fva
        # as 0x804af09, which crosses function boundaries into the function decode_switches.
        # Reason being is that at VA 0x804af31, there's a call to error() with value 2 as the first
        # parameter, which according to the man page for error means it should quit out. We don't grab
        # that at codeflow time (because such things would require an emulator with knowledge of calling
        # conventions)
        # But that raises the question if makeFunction should split the codeblock
        # or if we ignore that and just let the CodeBlockGraph stuff do it all for us,
        # or if we should allow codeflow to carry an emulator with it.
        vw = self.vdir_vw
        fvas = [
            0x804c030,
            0x804ce40,
            0x804cec0,
            0x804d1a0,
        ]
        for fva in fvas:
            g = v_t_graphutil.buildFunctionGraph(vw, fva)  # print_dir
            hits = set()
            for path in v_t_graphutil.getCoveragePaths(g):
                for nid, edge in path:
                    hits.add(nid)

            self.assertEqual(len(hits), len(vw.getFunctionBlocks(fva)))
            for nid in hits:
                cb = vw.getCodeBlock(nid)
                self.assertEqual(nid, cb[0])
                self.assertEqual(fva, cb[2])
Пример #2
0
 def checkCoveragePaths(self, vw, fva):
     graph = viv_graph.buildFunctionGraph(vw, fva)
     paths = [path for path in viv_graph.getCoveragePaths(graph, 150)]
     self.codepaths = paths
     self.assertEqual(len(self.codepaths), 22)
Пример #3
0
 def checkCoveragePaths(self, vw, fva):
     graph = viv_graph.buildFunctionGraph(vw, fva)
     paths = [ path for path in viv_graph.getCoveragePaths(graph, 150) ]
     self.codepaths = paths
     self.assertEqual(len(self.codepaths), 22)