[pypy-commit] pypy reverse-debugger-updated: Test was already passing, just confused about debug_print().

arigo pypy.commits at gmail.com
Sun May 13 17:38:39 EDT 2018


Author: Armin Rigo <arigo at tunes.org>
Branch: reverse-debugger-updated
Changeset: r94549:3b526d4fd961
Date: 2018-05-13 23:38 +0200
http://bitbucket.org/pypy/pypy/changeset/3b526d4fd961/

Log:	Test was already passing, just confused about debug_print().

diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -1376,9 +1376,7 @@
     def finalizer_trigger(self):
         from rpython.rtyper.annlowlevel import hlstr
         from rpython.rtyper.lltypesystem import rstr
-        from rpython.rlib.debug import debug_print
         from rpython.rlib import objectmodel
-        debug_print("HI THERE")
         while True:
             gcptr = self.next_dead()
             if not gcptr:
@@ -1387,10 +1385,10 @@
             string = hlstr(ll_string)
             key = objectmodel.compute_unique_id(string)
             ptr = self.raw_copies.get(key, lltype.nullptr(CCHARP.TO))
-            debug_print(ptr)
             if ptr:
                 if self.print_debugging:
-                    debug_print("freeing [", ptr, "]")
+                    from rpython.rlib.debug import debug_print
+                    debug_print("freeing str [", ptr, "]")
                 free_charp(ptr, track_allocation=False)
 _fq_addr_from_string = _StrFinalizerQueue()
 _fq_addr_from_string.raw_copies = {}    # {GCREF: CCHARP}
diff --git a/rpython/rtyper/lltypesystem/test/test_rffi.py b/rpython/rtyper/lltypesystem/test/test_rffi.py
--- a/rpython/rtyper/lltypesystem/test/test_rffi.py
+++ b/rpython/rtyper/lltypesystem/test/test_rffi.py
@@ -826,7 +826,7 @@
                     assert p[j] == expected[j]
 
         def f(n):
-            strings = [str(i) for i in range(n)]
+            strings = ["foo%d" % i for i in range(n)]
             rawptrs = [rffi._get_raw_address_buf_from_string(s)
                        for s in strings]
             check_content(strings, rawptrs)
@@ -838,11 +838,24 @@
 
         rffi._StrFinalizerQueue.print_debugging = True
         try:
-            xf = self.compile(f, [int], gcpolicy="incminimark")
-            assert xf(10000) == 42
+            xf = self.compile(f, [int], gcpolicy="incminimark",
+                              return_stderr=True)
         finally:
             rffi._StrFinalizerQueue.print_debugging = False
 
+        os.environ['PYPYLOG'] = ':-'
+        try:
+            error = xf(10000)
+        finally:
+            del os.environ['PYPYLOG']
+
+        import re
+        r = re.compile(r"freeing str [[] [0-9a-fx]+ []]")
+        matches = r.findall(error)
+        assert len(matches) == 10000        # must be all 10000 strings,
+        assert len(set(matches)) == 10000   # and no duplicates
+
+
 def test_enforced_args():
     from rpython.annotator.model import s_None
     from rpython.rtyper.annlowlevel import MixLevelHelperAnnotator


More information about the pypy-commit mailing list