Author: Antonio Cuni <[email protected]>
Branch: fix-vmprof-stacklet-switch-2
Changeset: r93197:85cbd648e7dd
Date: 2017-11-28 17:24 +0100
http://bitbucket.org/pypy/pypy/changeset/85cbd648e7dd/
Log: WIP: add a failing test which shows that we are not taking samples
inside callbacks
diff --git a/pypy/module/_continuation/test/test_stacklet.py
b/pypy/module/_continuation/test/test_stacklet.py
--- a/pypy/module/_continuation/test/test_stacklet.py
+++ b/pypy/module/_continuation/test/test_stacklet.py
@@ -1,5 +1,7 @@
+import pytest
import os
from rpython.rlib.rvmprof.test.support import fakevmprof
+from pypy.interpreter.gateway import interp2app
from pypy.module._continuation.test.support import BaseAppTest
@@ -771,3 +773,41 @@
continulet.switch(c1, to=c2)
raises(error, continulet.switch, c1, to=c2)
+
+
[email protected]('init_method')
+class AppTestVMProf(BaseAppTest):
+
+ @pytest.fixture
+ def init_method(self, fakevmprof):
+ """
+ This is automaticaly re-initialized for every method
+ """
+ w = self.space.wrap
+ i2a = interp2app
+ def is_sampling_enabled(space):
+ return space.wrap(fakevmprof.is_sampling_enabled)
+ self.w_is_sampling_enabled = w(i2a(is_sampling_enabled))
+ #
+ def start_sampling(space):
+ fakevmprof.start_sampling()
+ self.w_start_sampling = w(i2a(start_sampling))
+ #
+ def stop_sampling(space):
+ fakevmprof.stop_sampling()
+ self.w_stop_sampling = w(i2a(stop_sampling))
+
+ def test_sampling_inside_callback(self):
+ from _continuation import continulet
+ #
+ def my_callback(c1):
+ assert self.is_sampling_enabled()
+ return 42
+ #
+ self.start_sampling()
+ assert self.is_sampling_enabled()
+ c = continulet(my_callback)
+ res = c.switch()
+ assert res == 42
+ assert self.is_sampling_enabled()
+ self.stop_sampling()
diff --git a/rpython/rlib/rvmprof/test/support.py
b/rpython/rlib/rvmprof/test/support.py
--- a/rpython/rlib/rvmprof/test/support.py
+++ b/rpython/rlib/rvmprof/test/support.py
@@ -20,7 +20,7 @@
# --- FakeVMProf specific API ---
# this API is not part of rvmprof, but available only inside tests using
- # fakervmprof
+ # fakevmprof
@property
def is_sampling_enabled(self):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit