Example #1
0
def test_nodegen_errors(pgm, trace, exc_type, threads):
    """
    Test expected failure conditions where 
    the parser should throw an error.
    """

    with tempfile.NamedTemporaryFile() as tmp:
        # setup the mock trace
        w = ProvenanceTraceWriter(tmp.name)
        w.write_trace(trace, pc=0x1000)

        # get parsed graph
        parser = CheriMipsModelParser(pgm, trace_path=tmp.name, threads=threads)
        with pytest.raises(exc_type) as excinfo:
            parser.parse()
Example #2
0
def test_nodegen_simple(pgm, trace, threads):
    """Test provenance parser with the simplest trace possible."""

    with tempfile.NamedTemporaryFile() as tmp:
        # setup the mock trace
        w = ProvenanceTraceWriter(tmp.name)
        # multipart traces can be given so that common initialization
        # parts are not repeated
        w.write_trace(trace[0], pc=0x1000)
        for t in trace[1:]:
            w.write_trace(t)

        # get parsed graph
        parser = CheriMipsModelParser(pgm, trace_path=tmp.name, threads=threads)
        parser.parse()
        assert_graph_equal(w.pgm.graph, pgm.graph)
Example #3
0
def test_callgen_errors(pgm, test_data, threads):
    """Test provenance parser with the simplest trace possible."""

    with tempfile.NamedTemporaryFile() as tmp:
        # setup the mock trace
        w = ProvenanceTraceWriter(tmp.name)
        traces, error = test_data
        for base, model in traces:
            w.write_trace(model, pc=base)

        # get parsed graph
        parser = CheriMipsModelParser(pgm,
                                      trace_path=tmp.name,
                                      threads=threads)
        with pytest.raises(error):
            parser.parse()
Example #4
0
def test_callgen(pgm, traces, threads):
    """Test provenance parser with the simplest trace possible."""

    with tempfile.NamedTemporaryFile() as tmp:
        # setup the mock trace
        w = ProvenanceTraceWriter(tmp.name)
        for base, model in traces:
            w.write_trace(model, pc=base)

        # get parsed graph
        parser = CheriMipsModelParser(pgm,
                                      trace_path=tmp.name,
                                      threads=threads)
        parser.parse()
        # check the provenance graph model
        assert_graph_equal(w.pgm.graph, pgm.graph)
Example #5
0
def test_mem_errors(pgm, trace, exc_type, threads):
    """
    Test expected failure conditions where 
    the parser should throw an error.
    """

    with tempfile.NamedTemporaryFile() as tmp:
        # setup the mock trace
        w = ProvenanceTraceWriter(tmp.name)
        # multipart traces can be given so that common initialization
        # parts are not repeated
        w.write_trace(trace[0], pc=0x1000)
        for t in trace[1:]:
            w.write_trace(t)

        # get parsed graph
        parser = CheriMipsModelParser(pgm, trace_path=tmp.name, threads=threads)
        with pytest.raises(exc_type) as excinfo:
            parser.parse()
Example #6
0
    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        default_outfile = "{}_graph.gt".format(self.config.trace)
        outfile = self.config.outfile or default_outfile
        if self.config.cheri_cap_size == "128":
            cap_size = 16
        elif self.config.cheri_cap_size == "256":
            cap_size = 32
        else:
            raise ValueError("Invalid capability size {}".format(
                self.config.cheri_cap_size))

        self.pgm = ProvenanceGraphManager(outfile)
        """Graph manager."""

        self._parser = CheriMipsModelParser(self.pgm,
                                            capability_size=cap_size,
                                            trace_path=self.config.trace,
                                            threads=self.config.threads)
        """Graph parser strategy, depends on the architecture."""