[pypy-commit] pypy default: Add a test for the thread-aware ticker.

arigo noreply at buildbot.pypy.org
Sun Oct 16 10:04:38 CEST 2011


Author: Armin Rigo <arigo at tunes.org>
Branch: 
Changeset: r48076:da46d9c97e58
Date: 2011-10-16 10:04 +0200
http://bitbucket.org/pypy/pypy/changeset/da46d9c97e58/

Log:	Add a test for the thread-aware ticker.

diff --git a/pypy/module/pypyjit/test_pypy_c/test_thread.py b/pypy/module/pypyjit/test_pypy_c/test_thread.py
new file mode 100644
--- /dev/null
+++ b/pypy/module/pypyjit/test_pypy_c/test_thread.py
@@ -0,0 +1,28 @@
+from pypy.module.pypyjit.test_pypy_c.test_00_model import BaseTestPyPyC
+
+
+class TestThread(BaseTestPyPyC):
+    def test_simple(self):
+        def main(n):
+            import thread
+            def f():
+                i = 0
+                while i < n:
+                    i += 1
+                done.release()
+
+            done = thread.allocate_lock()
+            done.acquire()
+            thread.start_new_thread(f, ())
+            done.acquire()
+            return 0
+        log = self.run(main, [500])
+        assert round(log.result, 6) == round(main(500), 6)
+        loop, = log.loops_by_filename(self.filepath)
+        assert loop.match("""
+            i2 = int_lt(i0, i1)
+            guard_true(i2, descr=...)
+            i3 = int_add(i0, 1)
+            --THREAD-TICK--
+            jump(..., descr=<Loop0>)
+        """)


More information about the pypy-commit mailing list