Ejemplo n.º 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()
Ejemplo n.º 2
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)
Ejemplo n.º 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()
Ejemplo n.º 4
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)
Ejemplo n.º 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()