[pypy-commit] pypy stm: (antocuni, arigo)

arigo noreply at buildbot.pypy.org
Mon Jan 16 18:56:27 CET 2012


Author: Armin Rigo <arigo at tunes.org>
Branch: stm
Changeset: r51361:1e52821ea7bc
Date: 2012-01-16 18:44 +0100
http://bitbucket.org/pypy/pypy/changeset/1e52821ea7bc/

Log:	(antocuni, arigo)

	Test (maybe) for inevitable transactions.

diff --git a/pypy/rlib/test/test_rstm.py b/pypy/rlib/test/test_rstm.py
--- a/pypy/rlib/test/test_rstm.py
+++ b/pypy/rlib/test/test_rstm.py
@@ -1,3 +1,4 @@
+import os
 from pypy.rlib.debug import debug_print
 from pypy.rlib import rstm
 from pypy.translator.stm.test.support import CompiledSTMTests
@@ -8,12 +9,15 @@
 
 def setx(arg):
     debug_print(arg.x)
+    if arg.x == 303:
+        # this will trigger stm_become_inevitable()
+        os.write(1, "hello\n")
     arg.x = 42
 
 
-def test_stm_perform_transaction():
+def test_stm_perform_transaction(initial_x=202):
     arg = Arg()
-    arg.x = 202
+    arg.x = initial_x
     rstm.descriptor_init()
     rstm.perform_transaction(setx, Arg, arg)
     rstm.descriptor_done()
@@ -42,3 +46,12 @@
         dataout, dataerr = cbuilder.cmdexec('', err=True)
         assert dataout == ''
         assert '202' in dataerr.splitlines()
+
+    def test_perform_transaction_inevitable(self):
+        def f(argv):
+            test_stm_perform_transaction(303)
+            return 0
+        t, cbuilder = self.compile(f)
+        dataout, dataerr = cbuilder.cmdexec('', err=True)
+        assert 'hello' in dataout.splitlines()
+        assert '303' in dataerr.splitlines()


More information about the pypy-commit mailing list