Author: Armin Rigo <ar...@tunes.org>
Branch: reverse-debugger
Changeset: r86154:1793bd4d7a98
Date: 2016-08-11 18:06 +0200
http://bitbucket.org/pypy/pypy/changeset/1793bd4d7a98/

Log:    Non-passing test

diff --git a/rpython/translator/revdb/test/test_thread.py 
b/rpython/translator/revdb/test/test_thread.py
--- a/rpython/translator/revdb/test/test_thread.py
+++ b/rpython/translator/revdb/test/test_thread.py
@@ -78,6 +78,64 @@
         rdb.write_call("AAAA\n")
         rdb.done()
 
+    def test_threadlocal(self):
+        class EC(object):
+            def __init__(self, value):
+                self.value = value
+        raw_thread_local = rthread.ThreadLocalReference(EC)
+
+        def bootstrap():
+            rthread.gc_thread_start()
+            _sleep(1)
+            ec = EC(4567)
+            raw_thread_local.set(ec)
+            print raw_thread_local.get().value
+            assert raw_thread_local.get() is ec
+            rthread.gc_thread_die()
+
+        def main(argv):
+            ec = EC(12)
+            raw_thread_local.set(ec)
+            rthread.start_new_thread(bootstrap, ())
+            _sleep(2)
+            print raw_thread_local.get().value
+            assert raw_thread_local.get() is ec
+            return 9
+
+        self.compile(main, backendopt=False, thread=True)
+        out = self.run('Xx')
+        # should have printed 4567 and 12
+        rdb = self.fetch_rdb([self.exename, 'Xx'])
+        th_A = rdb.main_thread_id
+        rdb.same_stack()      # RPyGilAllocate()
+        rdb.gil_release()
+
+        th_B = rdb.switch_thread()
+        assert th_B != th_A
+        b = rdb.next('!h'); assert 300 <= b < 310   # "callback": start thread
+        rdb.gil_acquire()
+        rdb.gil_release()
+
+        rdb.switch_thread(th_A)
+        rdb.same_stack()      # start_new_thread returns
+        x = rdb.next(); assert x == th_B    # result is the 'th_B' id
+        rdb.gil_acquire()
+        rdb.gil_release()
+
+        rdb.switch_thread(th_B)
+        rdb.same_stack()      # sleep() (finishes here)
+        rdb.next('i')         # sleep()
+        rdb.gil_acquire()
+        rdb.write_call("4567\n")
+        rdb.gil_release()
+
+        rdb.switch_thread(th_A)
+        rdb.same_stack()      # sleep()
+        rdb.next('i')         # sleep()
+        rdb.gil_acquire()
+        rdb.write_call("12\n")
+        rdb.done()
+
 
 class TestThreadInteractive(InteractiveTests):
     expected_stop_points = 5
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to