[pypy-commit] pypy default: (price, fijal) Split test_gc.py

Greg Price noreply at buildbot.pypy.org
Tue Mar 26 06:15:43 CET 2013


Author: Greg Price <price at mit.edu>
Branch: 
Changeset: r62797:25e41713c257
Date: 2013-03-25 22:12 -0700
http://bitbucket.org/pypy/pypy/changeset/25e41713c257/

Log:	(price, fijal) Split test_gc.py

	Each of these classes runs all the tests of the base class. Make
	them parallelize better, and make it easier to run just the relevant
	tests when doing development.

diff --git a/rpython/memory/test/test_gc.py b/rpython/memory/test/gc_test_base.py
rename from rpython/memory/test/test_gc.py
rename to rpython/memory/test/gc_test_base.py
diff --git a/rpython/memory/test/test_generational_gc.py b/rpython/memory/test/test_generational_gc.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_generational_gc.py
@@ -0,0 +1,4 @@
+from rpython.memory.test.test_semispace_gc import TestSemiSpaceGC
+
+class TestGenerationalGC(TestSemiSpaceGC):
+    from rpython.memory.gc.generation import GenerationGC as GCClass
diff --git a/rpython/memory/test/test_growingsemispace_gc.py b/rpython/memory/test/test_growingsemispace_gc.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_growingsemispace_gc.py
@@ -0,0 +1,8 @@
+from rpython.rlib.rarithmetic import LONG_BIT
+
+from rpython.memory.test.test_semispace_gc import TestSemiSpaceGC
+
+WORD = LONG_BIT // 8
+
+class TestGrowingSemiSpaceGC(TestSemiSpaceGC):
+    GC_PARAMS = {'space_size': 16*WORD}
diff --git a/rpython/memory/test/test_hybrid_gc.py b/rpython/memory/test/test_hybrid_gc.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_hybrid_gc.py
@@ -0,0 +1,76 @@
+import py
+
+from rpython.rtyper.lltypesystem import lltype
+from rpython.rtyper.lltypesystem.lloperation import llop
+
+from rpython.memory.test.test_generational_gc import TestGenerationalGC
+
+
+class TestHybridGC(TestGenerationalGC):
+    from rpython.memory.gc.hybrid import HybridGC as GCClass
+    GC_CAN_MALLOC_NONMOVABLE = True
+    GC_CAN_SHRINK_BIG_ARRAY = False
+
+    def test_ref_from_rawmalloced_to_regular(self):
+        import gc
+        def concat(j):
+            lst = []
+            for i in range(j):
+                lst.append(str(i))
+            gc.collect()
+            return len("".join(lst))
+        res = self.interpret(concat, [100])
+        assert res == concat(100)
+
+    def test_longliving_weakref(self):
+        # test for the case where a weakref points to a very old object
+        # that was made non-movable after several collections
+        import gc, weakref
+        class A:
+            pass
+        def step1(x):
+            a = A()
+            a.x = 42
+            ref = weakref.ref(a)
+            i = 0
+            while i < x:
+                gc.collect()
+                i += 1
+            assert ref() is a
+            assert ref().x == 42
+            return ref
+        def step2(ref):
+            gc.collect()       # 'a' is freed here
+            assert ref() is None
+        def f(x):
+            ref = step1(x)
+            step2(ref)
+        self.interpret(f, [10])
+
+    def test_longliving_object_with_finalizer(self):
+        class B(object):
+            pass
+        b = B()
+        b.nextid = 0
+        b.num_deleted = 0
+        class A(object):
+            def __init__(self):
+                self.id = b.nextid
+                b.nextid += 1
+            def __del__(self):
+                b.num_deleted += 1
+        def f(x):
+            a = A()
+            i = 0
+            while i < x:
+                i += 1
+                a = A()
+                llop.gc__collect(lltype.Void)
+            llop.gc__collect(lltype.Void)
+            llop.gc__collect(lltype.Void)
+            return b.num_deleted
+        res = self.interpret(f, [15])
+        assert res == 16
+
+    def test_malloc_nonmovable_fixsize(self):
+        py.test.skip("Not supported")
diff --git a/rpython/memory/test/test_hybrid_gc_smallheap.py b/rpython/memory/test/test_hybrid_gc_smallheap.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_hybrid_gc_smallheap.py
@@ -0,0 +1,56 @@
+import py
+
+from rpython.rlib.rarithmetic import LONG_BIT
+
+from rpython.memory.test.gc_test_base import GCTest
+
+WORD = LONG_BIT // 8
+
+class TestHybridGCSmallHeap(GCTest):
+    from rpython.memory.gc.hybrid import HybridGC as GCClass
+    GC_CAN_MOVE = False # with this size of heap, stuff gets allocated
+                        # in 3rd gen.
+    GC_CAN_MALLOC_NONMOVABLE = True
+    GC_PARAMS = {'space_size': 48*WORD,
+                 'min_nursery_size': 12*WORD,
+                 'nursery_size': 12*WORD,
+                 'large_object': 3*WORD,
+                 'large_object_gcptrs': 3*WORD,
+                 'generation3_collect_threshold': 5,
+                 }
+
+    def test_gen3_to_gen2_refs(self):
+        class A(object):
+            def __init__(self):
+                self.x1 = -1
+        def f(x):
+            loop = A()
+            loop.next = loop
+            loop.prev = loop
+            i = 0
+            while i < x:
+                i += 1
+                a1 = A()
+                a1.x1 = i
+                a2 = A()
+                a2.x1 = i + 1000
+                a1.prev = loop.prev
+                a1.prev.next = a1
+                a1.next = loop
+                loop.prev = a1
+                a2.prev = loop
+                a2.next = loop.next
+                a2.next.prev = a2
+                loop.next = a2
+            i = 0
+            a = loop
+            while True:
+                a = a.next
+                i += 1
+                if a is loop:
+                    return i
+        res = self.interpret(f, [200])
+        assert res == 401
+
+    def test_malloc_nonmovable_fixsize(self):
+        py.test.skip("Not supported")
diff --git a/rpython/memory/test/test_minimark_gc.py b/rpython/memory/test/test_minimark_gc.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_minimark_gc.py
@@ -0,0 +1,11 @@
+from rpython.rlib.rarithmetic import LONG_BIT
+
+from rpython.memory.test.test_semispace_gc import TestSemiSpaceGC
+
+WORD = LONG_BIT // 8
+
+class TestMiniMarkGC(TestSemiSpaceGC):
+    from rpython.memory.gc.minimark import MiniMarkGC as GCClass
+    GC_CAN_SHRINK_BIG_ARRAY = False
+    GC_CAN_MALLOC_NONMOVABLE = True
+    BUT_HOW_BIG_IS_A_BIG_STRING = 11*WORD
diff --git a/rpython/memory/test/test_minimark_gc_cardmarking.py b/rpython/memory/test/test_minimark_gc_cardmarking.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_minimark_gc_cardmarking.py
@@ -0,0 +1,4 @@
+from rpython.memory.test.test_minimark_gc import TestMiniMarkGC
+
+class TestMiniMarkGCCardMarking(TestMiniMarkGC):
+    GC_PARAMS = {'card_page_indices': 4}
diff --git a/rpython/memory/test/test_semispace_gc.py b/rpython/memory/test/test_semispace_gc.py
new file mode 100644
--- /dev/null
+++ b/rpython/memory/test/test_semispace_gc.py
@@ -0,0 +1,9 @@
+from rpython.memory.test import snippet
+from rpython.memory.test.gc_test_base import GCTest
+
+class TestSemiSpaceGC(GCTest, snippet.SemiSpaceGCTests):
+    from rpython.memory.gc.semispace import SemiSpaceGC as GCClass
+    GC_CAN_MOVE = True
+    GC_CAN_MALLOC_NONMOVABLE = False
+    GC_CAN_SHRINK_ARRAY = True
+    GC_CAN_SHRINK_BIG_ARRAY = True


More information about the pypy-commit mailing list