1. Pypy
  2. Untitled project
  3. pypy

Commits

Gregor Wegberg  committed daf002a

generalize tests. tests pinning for minor collections and major ones now

  • Participants
  • Parent commits cd9ec65
  • Branches gc-incminimark-pinning

Comments (0)

Files changed (1)

File rpython/memory/gc/test/test_object_pinning.py

View file
  • Ignore whitespace
 class TestIncminimark(PinningGCTest):
     from rpython.memory.gc.incminimark import IncrementalMiniMarkGC as GCClass
 
-    def test_simple_pin_stack(self):
+    def simple_pin_stack(self, collect_func):
         # create object, pin it and point from stackroots to it
         ptr = self.malloc(S)
         ptr.someInt = 100
         adr = llmemory.cast_ptr_to_adr(ptr)
         assert self.gc.pin(adr)
 
-        self.gc.collect()
+        collect_func()
         
         assert self.gc.is_in_nursery(adr)
         assert ptr.someInt == 100
 
-    def test_simple_pin_unpin_stack(self):
+    def test_simple_pin_stack_full_collect(self):
+        self.simple_pin_stack(self.gc.collect)
+
+    def test_simple_pin_stack_minor_collect(self):
+        self.simple_pin_stack(self.gc.minor_collection)
+
+    def simple_pin_unpin_stack(self, collect_func):
         ptr = self.malloc(S)
         ptr.someInt = 100
         
         adr = llmemory.cast_ptr_to_adr(ptr)
         assert self.gc.pin(adr)
         
-        self.gc.collect()
+        collect_func()
 
         assert self.gc.is_in_nursery(adr)
         assert ptr.someInt == 100
         
         # unpin and check if object is gone from nursery
         self.gc.unpin(adr)
-        self.gc.collect()
+        collect_func()
         py.test.raises(RuntimeError, 'ptr.someInt')
         
         # check if we object is still accessible
         assert not self.gc.is_in_nursery(llmemory.cast_ptr_to_adr(ptr_old))
         assert ptr_old.someInt == 100
 
+    def test_simple_pin_unpin_stack_full_collect(self):
+        self.simple_pin_unpin_stack(self.gc.collect)
+
+    def test_simple_pin_unpin_stack_minor_collect(self):
+        self.simple_pin_unpin_stack(self.gc.minor_collection)
+
     def test_pin_referenced_from_stackroot_young(self):
         #
         # create two objects and reference the pinned one
         assert self.stackroots[0].next.someInt == 100
 
     def not_pinned_and_stackroots_point_to_pinned(self, make_old):
-        # In this test case we point to a pinned object from an old object
+        # In this test case we point to a pinned object from an (old) object
         # *and* from the stackroots
         obj_ptr = self.malloc(S)
         obj_ptr.someInt = 999