summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorArthur Pastel <arthur.pastel@gmail.com>2023-05-07 19:42:26 (GMT)
committerGitHub <noreply@github.com>2023-05-07 19:42:26 (GMT)
commit8d95012c95988dc517db6e09348aab996868699c (patch)
treed964d20c0877c551d81d644e22e013a54fb06fe6 /Lib/test
parente8d77b03e08a4c7e7dde0830c5a12a0b41ff7c33 (diff)
downloadcpython-8d95012c95988dc517db6e09348aab996868699c.zip
cpython-8d95012c95988dc517db6e09348aab996868699c.tar.gz
cpython-8d95012c95988dc517db6e09348aab996868699c.tar.bz2
gh-103650: Fix perf maps address format (#103651)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_perf_profiler.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/Lib/test/test_perf_profiler.py b/Lib/test/test_perf_profiler.py
index 2b977d7..5418f9f 100644
--- a/Lib/test/test_perf_profiler.py
+++ b/Lib/test/test_perf_profiler.py
@@ -1,4 +1,5 @@
import unittest
+import string
import subprocess
import sys
import sysconfig
@@ -70,9 +71,14 @@ class TestPerfTrampoline(unittest.TestCase):
perf_file = pathlib.Path(f"/tmp/perf-{process.pid}.map")
self.assertTrue(perf_file.exists())
perf_file_contents = perf_file.read_text()
- self.assertIn(f"py::foo:{script}", perf_file_contents)
- self.assertIn(f"py::bar:{script}", perf_file_contents)
- self.assertIn(f"py::baz:{script}", perf_file_contents)
+ perf_lines = perf_file_contents.splitlines();
+ expected_symbols = [f"py::foo:{script}", f"py::bar:{script}", f"py::baz:{script}"]
+ for expected_symbol in expected_symbols:
+ perf_line = next((line for line in perf_lines if expected_symbol in line), None)
+ self.assertIsNotNone(perf_line, f"Could not find {expected_symbol} in perf file")
+ perf_addr = perf_line.split(" ")[0]
+ self.assertFalse(perf_addr.startswith("0x"), "Address should not be prefixed with 0x")
+ self.assertTrue(set(perf_addr).issubset(string.hexdigits), "Address should contain only hex characters")
def test_trampoline_works_with_forks(self):
code = """if 1: