[pypy-svn] r58847 - in pypy/build/benchmem: . testing

hpk at codespeak.net hpk at codespeak.net
Wed Oct 8 19:03:16 CEST 2008


Author: hpk
Date: Wed Oct  8 19:03:16 2008
New Revision: 58847

Modified:
   pypy/build/benchmem/smaps.py
   pypy/build/benchmem/testing/test_benchtool.py
Log:
fix parsing of smap to not confuse which mapping belongs to what


Modified: pypy/build/benchmem/smaps.py
==============================================================================
--- pypy/build/benchmem/smaps.py	(original)
+++ pypy/build/benchmem/smaps.py	Wed Oct  8 19:03:16 2008
@@ -32,11 +32,12 @@
                     sizeline = iterlines.next()
                     parts = sizeline.split()
                     if len(parts) != 3:
-                        headline = sizeline
+                        nextheadline = sizeline
                         break 
                     value = int(parts[1])
                     attrs.append(value)
                 append_attrs(attrs)
+                headline = nextheadline
         except StopIteration:
             append_attrs(attrs)
         self.stream.write(self.SEPSNAPSHOT)

Modified: pypy/build/benchmem/testing/test_benchtool.py
==============================================================================
--- pypy/build/benchmem/testing/test_benchtool.py	(original)
+++ pypy/build/benchmem/testing/test_benchtool.py	Wed Oct  8 19:03:16 2008
@@ -99,6 +99,38 @@
     l2 = " ".join(lines[2].split())
     assert l2 == "32,32,0,0,0,32 402c2000-402c4000 rw-p 402c2000 00:00 0"
 
+def test_log_mapping_two():
+    s = py.std.textwrap.dedent("""\
+0035a000-00503000 rw-p 0034a000 1f:04 52612      /root/pypy/dist/pypy-c-optmem
+Size:              1700 kB
+Rss:               1616 kB
+Shared_Clean:         0 kB
+Shared_Dirty:         0 kB
+Private_Clean:      380 kB
+Private_Dirty:     1236 kB
+00503000-00545000 rwxp 00503000 00:00 0          [heap]
+Size:               264 kB
+Rss:                232 kB
+Shared_Clean:         0 kB
+Shared_Dirty:         0 kB
+Private_Clean:        0 kB
+Private_Dirty:      232 kB
+""")
+    basedir = py.test.ensuretemp("log_mapping_two")
+    p = basedir.join("smaps.example")
+    p.write(s)
+
+    io = py.std.StringIO.StringIO()
+    rec = smaps.SmapsRecorder(os.getpid(), io)
+    rec.smapspath = p
+    rec.snapshot()
+    result = io.getvalue()
+    lines = result.split("\n")
+    l0 = " ".join(lines[0].split())
+    l1 = " ".join(lines[1].split())
+    assert l0 == "1700,1616,0,0,380,1236 0035a000-00503000 rw-p 0034a000 1f:04 52612 /root/pypy/dist/pypy-c-optmem"
+    assert l1 == "264,232,0,0,0,232 00503000-00545000 rwxp 00503000 00:00 0 [heap]"
+
 def test_parse_mapping():
     line = ("988,796,0,0,796,0 08048000-0813f000 "
             "r-xp 00000000 fd:00 75457      sometext")



More information about the Pypy-commit mailing list