Author: Armin Rigo <[email protected]>
Branch: stmgc-c7
Changeset: r75659:3ab2ca363785
Date: 2015-02-02 22:01 +0100
http://bitbucket.org/pypy/pypy/changeset/3ab2ca363785/
Log: Improve the basic 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
@@ -72,7 +72,10 @@
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
stdout, stderr = pipe.communicate()
- if getattr(pipe, 'returncode', 0) < 0:
+ if pipe.returncode > 0:
+ raise IOError("subprocess error %d:\n%s" % (pipe.returncode,
+ stderr))
+ if pipe.returncode < 0:
raise IOError("subprocess was killed by signal %d" % (
pipe.returncode,))
@@ -80,8 +83,18 @@
from pypy.stm.print_stm_log import StmLog
return StmLog(str(self.logfile))
- def check_almost_no_conflict(self, func_or_src, args=[]):
+ def _check_count_conflicts(self, func_or_src, args=[]):
self._write_source(func_or_src, args)
self._execute()
stmlog = self._parse_log()
- assert stmlog.get_total_aborts_and_pauses() < 1000
+ count = stmlog.get_total_aborts_and_pauses()
+ print 'stmlog.get_total_aborts_and_pauses():', count
+ return count
+
+ def check_almost_no_conflict(self, *args):
+ count = self._check_count_conflicts(*args)
+ assert count < 500
+
+ def check_many_conflicts(self, *args):
+ count = self._check_count_conflicts(*args)
+ assert count > 20000
diff --git a/pypy/module/pypystm/test_pypy_c/test_conflict.py
b/pypy/module/pypystm/test_pypy_c/test_conflict.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypystm/test_pypy_c/test_conflict.py
@@ -0,0 +1,16 @@
+from pypy.module.pypystm.test_pypy_c.support import BaseTestSTM
+
+
+class TestConflict(BaseTestSTM):
+
+ def test_obvious(self):
+ def f():
+ class X(object):
+ pass
+ x = X() # shared
+ x.a = 0
+ def g():
+ x.a += 1
+ run_in_threads(g)
+ #
+ self.check_many_conflicts(f)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit