コード例 #1
0
def interpret(func,
              values,
              view='auto',
              viewbefore='auto',
              policy=None,
              backendopt=False,
              config=None,
              malloc_check=True,
              **kwargs):
    interp, graph = get_interpreter(func,
                                    values,
                                    view,
                                    viewbefore,
                                    policy,
                                    backendopt=backendopt,
                                    config=config,
                                    **kwargs)
    if not malloc_check:
        result = interp.eval_graph(graph, values)
    else:
        prev = leakfinder.start_tracking_allocations()
        try:
            result = interp.eval_graph(graph, values)
        finally:
            leaks = leakfinder.stop_tracking_allocations(False, prev)
        if leaks:
            raise leakfinder.MallocMismatch(leaks)
    return result
コード例 #2
0
ファイル: test_leakfinder.py プロジェクト: sbw111/lab4
def test_malloc_mismatch():
    import sys, traceback, cStringIO
    sio = cStringIO.StringIO()
    traceback.print_stack(sys._getframe(), limit=10, file=sio)
    tb = sio.getvalue()
    e = leakfinder.MallocMismatch({1234: tb, 2345: tb})
    print str(e)
    # grouped entries for 1234 and 2345
    assert '1234:\n2345:\n' in str(e) or '2345:\n1234:\n' in str(e)
    assert tb[-80:] in str(e)
コード例 #3
0
ファイル: conftest.py プロジェクト: sota/pypy-old
    def pytest_runtest_teardown(self, __multicall__, item):
        __multicall__.execute()
        if not isinstance(item, py.test.collect.Function):
            return
        if (not getattr(item.obj, 'dont_track_allocations', False)
                and leakfinder.TRACK_ALLOCATIONS):
            item._pypytest_leaks = leakfinder.stop_tracking_allocations(False)
        else:  # stop_tracking_allocations() already called
            item._pypytest_leaks = None

        # check for leaks, but only if the test passed so far
        if getattr(item, '_success', False) and item._pypytest_leaks:
            raise leakfinder.MallocMismatch(item._pypytest_leaks)
コード例 #4
0
ファイル: conftest.py プロジェクト: zcxowwww/pypy
    def pytest_runtest_teardown(self, item):
        if not isinstance(item, py.test.collect.Function):
            return
        if (not getattr(item.obj, 'dont_track_allocations', False)
                and leakfinder.TRACK_ALLOCATIONS):
            kwds = {}
            try:
                kwds['do_collection'] = item.track_allocations_collect
            except AttributeError:
                pass
            item._pypytest_leaks = leakfinder.stop_tracking_allocations(
                False, **kwds)
        else:  # stop_tracking_allocations() already called
            item._pypytest_leaks = None

        # check for leaks, but only if the test passed so far
        if getattr(item, '_success', False) and item._pypytest_leaks:
            raise leakfinder.MallocMismatch(item._pypytest_leaks)