Author: Armin Rigo <ar...@tunes.org> Branch: hashtable Changeset: r1495:9633e4f3f503 Date: 2014-11-07 18:42 +0100 http://bitbucket.org/pypy/stmgc/changeset/9633e4f3f503/
Log: Add a passing test diff --git a/c7/test/test_finalizer.py b/c7/test/test_finalizer.py --- a/c7/test/test_finalizer.py +++ b/c7/test/test_finalizer.py @@ -139,12 +139,17 @@ class TestRegularFinalizer(BaseTest): + expect_content_character = None def setup_method(self, meth): BaseTest.setup_method(self, meth) # @ffi.callback("void(object_t *)") def finalizer(obj): + print "finalizing!", obj + assert stm_get_obj_size(obj) in [16, 32, 48, 56] + if self.expect_content_character is not None: + assert stm_get_char(obj) == self.expect_content_character self.finalizers_called.append(obj) self.finalizers_called = [] lib.stmcb_finalizer = finalizer @@ -175,6 +180,21 @@ stm_major_collect() self.expect_finalized([lp1, lp2, lp3]) + def test_finalizer_from_other_thread(self): + self.start_transaction() + lp1 = stm_allocate_with_finalizer(48) + stm_set_char(lp1, 'H') + self.expect_content_character = 'H' + print lp1 + # + self.switch(1) + self.start_transaction() + stm_major_collect() + self.expect_finalized([]) # marked as dead, but wrong thread + # + self.switch(0) + self.expect_finalized([lp1]) # now it has been finalized + def test_finalizer_ordering(self): self.start_transaction() lp1 = stm_allocate_with_finalizer_refs(1) _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit