[pypy-commit] pypy stmgc-c7: more tests
arigo
noreply at buildbot.pypy.org
Mon Feb 2 22:10:09 CET 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: stmgc-c7
Changeset: r75662:255b484dd279
Date: 2015-02-02 22:09 +0100
http://bitbucket.org/pypy/pypy/changeset/255b484dd279/
Log: more tests
diff --git a/pypy/module/pypystm/test_pypy_c/support.py b/pypy/module/pypystm/test_pypy_c/support.py
--- a/pypy/module/pypystm/test_pypy_c/support.py
+++ b/pypy/module/pypystm/test_pypy_c/support.py
@@ -8,24 +8,27 @@
HEADER = """
import thread, pypystm
-def _run(lock, result, function):
+def _run(lock, result, function, args):
start = pypystm.time()
try:
while True:
- function()
+ function(*args)
if pypystm.time() - start >= 3.0:
break
result.append(1)
finally:
lock.release()
-def run_in_threads(function):
+def run_in_threads(function, arg_thread_num=False):
locks = []
result = []
for i in range(3):
lock = thread.allocate_lock()
lock.acquire()
- thread.start_new_thread(_run, (lock, result, function))
+ args = ()
+ if arg_thread_num:
+ args += (i,)
+ thread.start_new_thread(_run, (lock, result, function, args))
locks.append(lock)
for lock in locks:
lock._py3k_acquire(timeout=30)
diff --git a/pypy/module/pypystm/test_pypy_c/test_conflict.py b/pypy/module/pypystm/test_pypy_c/test_conflict.py
--- a/pypy/module/pypystm/test_pypy_c/test_conflict.py
+++ b/pypy/module/pypystm/test_pypy_c/test_conflict.py
@@ -14,3 +14,12 @@
run_in_threads(g)
#
self.check_many_conflicts(f)
+
+ def test_plain_dict_access(self):
+ def f():
+ d = {} # shared
+ def g(n):
+ d[n] = d.get(n, 0) + 1
+ run_in_threads(g, arg_thread_num=True)
+ #
+ self.check_many_conflicts(f)
diff --git a/pypy/module/pypystm/test_pypy_c/test_no_conflict.py b/pypy/module/pypystm/test_pypy_c/test_no_conflict.py
--- a/pypy/module/pypystm/test_pypy_c/test_no_conflict.py
+++ b/pypy/module/pypystm/test_pypy_c/test_no_conflict.py
@@ -17,3 +17,13 @@
run_in_threads(g)
#
self.check_almost_no_conflict(f)
+
+ def test_stmdict_access(self):
+ def f():
+ import pypystm
+ d = pypystm.stmdict() # shared
+ def g(n):
+ d[n] = d.get(n, 0) + 1
+ run_in_threads(g, arg_thread_num=True)
+ #
+ self.check_almost_no_conflict(f)
More information about the pypy-commit
mailing list