Author: Armin Rigo <[email protected]>
Branch: stacklet
Changeset: r46329:00b8af12cc72
Date: 2011-08-06 18:26 +0200
http://bitbucket.org/pypy/pypy/changeset/00b8af12cc72/

Log:    Improve testing

diff --git a/pypy/rlib/test/test_rstacklet.py b/pypy/rlib/test/test_rstacklet.py
--- a/pypy/rlib/test/test_rstacklet.py
+++ b/pypy/rlib/test/test_rstacklet.py
@@ -55,6 +55,7 @@
         self.status = 0
         while self.status < self.STATUSMAX or self.any_alive():
             self.tasks[0].withdepth(self.random.genrand32() % 50)
+            assert len(self.tasks[0].lst) == 0
 
     def any_alive(self):
         for task in self.tasks:
@@ -63,14 +64,32 @@
         return False
 
 
+class FooObj:
+    def __init__(self, n, d, next=None):
+        self.n = n
+        self.d = d
+        self.next = next
+
+
 class Task:
     def __init__(self, n):
         self.n = n
         self.h = lltype.nullptr(rstacklet.handle.TO)
+        self.lst = []
 
     def withdepth(self, d):
         if d > 0:
+            foo = FooObj(self.n, d)
+            foo2 = FooObj(self.n + 100, d, foo)
+            self.lst.append(foo)
             res = self.withdepth(d-1)
+            foo = self.lst.pop()
+            assert foo2.n == self.n + 100
+            assert foo2.d == d
+            assert foo2.next is foo
+            assert foo.n == self.n
+            assert foo.d == d
+            assert foo.next is None
         else:
             res = 0
             n = intmask(runner.random.genrand32() % 10)
@@ -154,8 +173,9 @@
     runner.gointo = -1
 
     while self.withdepth(runner.random.genrand32() % 20) == 0:
-        pass
+        assert len(self.lst) == 0
 
+    assert len(self.lst) == 0
     assert not self.h
     while 1:
         n = intmask(runner.random.genrand32() % 10)
@@ -209,16 +229,21 @@
         t, cbuilder = self.compile(entry_point)
 
         expected_data = "----- all done -----\n"
-        for i in range(20, 3):
-            print 'running %s/%s with argument %d' % (
-                self.gc, self.gcrootfinder, i)
-            data = cbuilder.cmdexec('%d' % i, env={})
+        for i in range(15):
+            if (i & 1) == 0:
+                env = {}
+            else:
+                env = {'PYPY_GC_NURSERY': '2k'}
+            print 'running %s/%s with arg=%d and env=%r' % (
+                self.gc, self.gcrootfinder, i, env)
+            data = cbuilder.cmdexec('%d' % i, env=env)
             assert data.endswith(expected_data)
-            #data = cbuilder.cmdexec('%d' % i, env={'PYPY_GC_NURSERY': '10k'})
-            #assert data.endswith(expected_data)
 
 
-class TestStackletBoehm(BaseTestStacklet):
+class DONTTestStackletBoehm(BaseTestStacklet):
+    # Boehm does not work well with stacklets, probably because the
+    # moved-away copies of the stack are parsed using a different
+    # selection logic than the real stack
     gc = 'boehm'
     gcrootfinder = None
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to