Author: Remi Meier <[email protected]>
Branch: stmgc-c8
Changeset: r85652:e5f4066bc640
Date: 2016-07-11 11:34 +0200
http://bitbucket.org/pypy/pypy/changeset/e5f4066bc640/
Log: add very direct test for the previous commit
diff --git a/pypy/module/pypystm/test/test_local.py
b/pypy/module/pypystm/test/test_local.py
--- a/pypy/module/pypystm/test/test_local.py
+++ b/pypy/module/pypystm/test/test_local.py
@@ -11,3 +11,37 @@
import pypystm
return pypystm.local
""")
+
+
+def test_direct_call_to_become_inevitable():
+ # this test directly checks if we call rstm.become_inevitable() in the
+ # right places (before modifying the real threadlocal). Could possibly be
+ # tested in a better way...
+ from pypy.module.pypystm.threadlocals import STMThreadLocals
+ from rpython.rlib import rstm
+ from pypy.interpreter.executioncontext import ExecutionContext
+
+ class FakeEC(ExecutionContext):
+ def __init__(self): pass
+ class FakeConfig:
+ class translation:
+ rweakref = False
+ class FakeSpace:
+ config = FakeConfig()
+ def createexecutioncontext(self):
+ return FakeEC()
+ call_counter = [0]
+ def fake_become_inevitable():
+ call_counter[0] += 1
+ rstm.become_inevitable = fake_become_inevitable
+
+ space = FakeSpace()
+
+ l = STMThreadLocals(space)
+ assert call_counter[0] == 0
+ l.try_enter_thread(space)
+ assert call_counter[0] == 1
+ l.enter_thread(space)
+ assert call_counter[0] == 2
+ l.leave_thread(space)
+ assert call_counter[0] == 3
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit