[pypy-svn] r45673 - pypy/dist/pypy/translator/c/test

arigo at codespeak.net arigo at codespeak.net
Wed Aug 15 13:20:28 CEST 2007


Author: arigo
Date: Wed Aug 15 13:20:27 2007
New Revision: 45673

Modified:
   pypy/dist/pypy/translator/c/test/test_boehm.py
Log:
Make this test fail.  Pfew, not an easy task to outguess both Boehm, gcc
and our translation toolchain.


Modified: pypy/dist/pypy/translator/c/test/test_boehm.py
==============================================================================
--- pypy/dist/pypy/translator/c/test/test_boehm.py	(original)
+++ pypy/dist/pypy/translator/c/test/test_boehm.py	Wed Aug 15 13:20:27 2007
@@ -97,6 +97,7 @@
 
     def test_id_is_weak(self):
         # test that id(obj) does not keep obj alive
+        py.test.skip("fails")
         from pypy.rpython.lltypesystem.lloperation import llop
         class State:
             pass
@@ -109,9 +110,7 @@
                 s.b_dels += 1
         class C(A):
             pass
-        def f():
-            s.a_dels = 0
-            s.b_dels = 0
+        def run_once():
             a = A()
             ida = id(a)
             b = B()
@@ -121,22 +120,31 @@
             llop.gc__collect(lltype.Void)
             llop.gc__collect(lltype.Void)
             llop.gc__collect(lltype.Void)
-            
-            # the strange additions at the end are to keep ida, idb alive
-            return s.a_dels * 10 + s.b_dels + ida + idb - idb - ida
-        fn = self.getcompiled(f)
+            return ida, idb, idc
+        def f(n):
+            s.a_dels = 0
+            s.b_dels = 0
+            a1, b1, c1 = run_once()
+            a2, b2, c2 = run_once()
+            a3, b3, c3 = run_once()
+            a4, b4, c4 = run_once()
+            a5, b5, c5 = run_once()
+            return (s.a_dels, s.b_dels,
+                    a1, b1, c1,
+                    a2, b2, c2,
+                    a3, b3, c3,
+                    a4, b4, c4,
+                    a5, b5, c5)
+        fn = self.getcompiled(f, [int])
         # we can't demand that boehm has collected all of the objects,
-        # even with the gc__collect call.  calling the compiled
-        # function twice seems to help, though.
-        res = 0
-        res += fn()
-        res += fn()
-        # if res is still 0, then we haven't tested anything so fail.
+        # even with the gc__collect call.
+        res = fn(50)
+        res1, res2 = res[:2]
+        # if res1 or res2 is still 0, then we haven't tested anything so fail.
         # it might be the test's fault though.
-        assert 0 < res <= 44
-        print res
-
-
+        print res1, res2
+        assert 0 < res1 <= 10
+        assert 0 < res2 <= 5
 
     def test_weakgcaddress_is_weak(self):
         py.test.skip("weakgcaddress as we know it is fragile")



More information about the Pypy-commit mailing list