[pypy-svn] r55873 - pypy/dist/pypy/rpython/lltypesystem/test

arigo at codespeak.net arigo at codespeak.net
Mon Jun 16 13:15:27 CEST 2008


Author: arigo
Date: Mon Jun 16 13:15:26 2008
New Revision: 55873

Modified:
   pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
Log:
Fix test.


Modified: pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py
==============================================================================
--- pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py	(original)
+++ pypy/dist/pypy/rpython/lltypesystem/test/test_rffi.py	Mon Jun 16 13:15:26 2008
@@ -469,19 +469,25 @@
         assert fn() == len(d)
 
     def test_nonmovingbuffer_semispace(self):
-        d = 'some cool data that should not move'
+        d = 'cool data'
         def f():
-            buf = get_nonmovingbuffer(d)
-            try:
-                counter = 0
-                for i in range(len(d)):
-                    if buf[i] == d[i]:
-                        counter += 1
-                return counter
-            finally:
-                free_nonmovingbuffer(d, buf)
+            counter = 0
+            for n in range(32):
+                buf = get_nonmovingbuffer(d)
+                try:
+                    for i in range(len(d)):
+                        if buf[i] == d[i]:
+                            counter += 1
+                finally:
+                    free_nonmovingbuffer(d, buf)
+            return counter
         fn = self.compile(f, [], gcpolicy='semispace')
-        assert fn(expected_extra_mallocs=9) == len(d)
+        # The semispace gc uses raw_malloc for its internal data structs
+        # but hopefully less than 30 times.  So we should get < 30 leaks
+        # unless the get_nonmovingbuffer()/free_nonmovingbuffer() pair
+        # leaks at each iteration.  This is what the following line checks.
+        res = fn(expected_extra_mallocs=range(30))
+        assert res == 32 * len(d)
 
 class TestRffiInternals:
     def test_struct_create(self):



More information about the Pypy-commit mailing list